t static method

Widget t({
  1. required bool value,
  2. required GestureTapCallback onTap,
  3. required ValueChanged<bool> onChange,
  4. Widget? text_child,
  5. String? text = "",
  6. double? size_scale = 1.0,
  7. EdgeInsets? margin,
  8. EdgeInsets? padding,
  9. bool? removePaddingClick = true,
  10. Decoration? decoration,
  11. Color? colorBackground,
})

Implementation

static Widget  t(
    {


      //  action
      required bool value,

      //tap
      required GestureTapCallback onTap,
      required ValueChanged<bool> onChange,

      //test
      Widget? text_child ,
      String? text = "",

      //size
      double? size_scale = 1.0,

      //space
      EdgeInsets? margin,
      EdgeInsets? padding,
      bool? removePaddingClick = true,

      //
      Decoration? decoration,
      Color? colorBackground,
    }
    ){

  // text used in second pirority
  if( text_child == null ) {
    text_child = TextTemplate.t( text, levelDS: LevelDS.l3);
  }

  //sw
  var sw = Switch(
      activeColor: DSColor.switch_active,
      inactiveTrackColor: DSColor.switch_inactive,
      value: value,
      onChanged: onChange);


  // default padding size
  final double defaultPaddingSizeClick = 20;

  /**
   * - why 40?
   *    because the default padding is 40
   */
  double paddingCheckBoxClick = 40;
  if ( removePaddingClick! ) {
    paddingCheckBoxClick = defaultPaddingSizeClick;
  }

  //fix : remove default
  var sizeBox = SizedBox( child:  sw, width: paddingCheckBoxClick, height: paddingCheckBoxClick   );

  //fix material
  var material = Material(child:  sizeBox    );

  //size by scale
  var scale = Transform.scale(scale: size_scale!, child:  material );

  //space between title
  var spaceBetweenTitle = EmptyView.empty( 13, 5);

  //row
  var row = RowTemplate.wrapChildren( [ scale, spaceBetweenTitle, text_child ]);

  //case: have custome padding
  //fix default padding at the container when there is padding for click
  if(removePaddingClick == false ){
    padding = EdgeInsetsTools.fixDefaultSpace( padding, defaultPaddingSizeClick);
  }

  // space
  var ct = Container(
      color:  colorBackground,
      decoration: decoration,
      margin: margin ,
      padding: padding,
      child:  row );

  //tab on
  var tab = GestureDetector( child:  ct ,
      onTap: onTap,
      // onTap: () {
      //
      //   onChange(value);
      // }
  );
  return tab;

}