import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';

extension IntValue on int{
  /// 返回根据屏幕宽高适配后尺寸（单位 dp or pt）
  double dp(){
    return toDouble().dp();
  }

  /// 返回间距，应用于四个位置：top，bottom，left，right
  EdgeInsets spacingAll(){
    return EdgeInsets.all(dp());
  }
  EdgeInsets spacingLeft(){
    return EdgeInsets.only(left: dp());
  }
  EdgeInsets spacingRight(){
    return EdgeInsets.only(right: dp());
  }
  EdgeInsets spacingTop(){
    return EdgeInsets.only(top: dp());
  }
  EdgeInsets spacingBottom(){
    return EdgeInsets.only(bottom: dp());
  }
  EdgeInsets spacingVertical(){
    return EdgeInsets.symmetric(vertical: dp());
  }
  EdgeInsets spacingHorizontal(){
    return EdgeInsets.symmetric(horizontal: dp());
  }
}

extension DoubleValue on double{
  /// 返回根据屏幕宽高适配后尺寸（单位 dp or pt）
  double dp(){
    return ScreenUtil.getInstance().getAdapterSize(this);
  }

  EdgeInsets spacingAll(){
    return EdgeInsets.all(dp());
  }
  EdgeInsets spacingLeft(){
    return EdgeInsets.only(left: dp());
  }
  EdgeInsets spacingRight(){
    return EdgeInsets.only(right: dp());
  }
  EdgeInsets spacingTop(){
    return EdgeInsets.only(top: dp());
  }
  EdgeInsets spacingBottom(){
    return EdgeInsets.only(bottom: dp());
  }
  EdgeInsets spacingVertical(){
    return EdgeInsets.symmetric(vertical: dp());
  }
  EdgeInsets spacingHorizontal(){
    return EdgeInsets.symmetric(horizontal: dp());
  }
}
