Field.chips constructor

Field.chips(
  1. String key, {
  2. String? label,
  3. dynamic value,
  4. FormValidator? validate,
  5. bool autofocus = false,
  6. String? dummyData,
  7. Widget? header,
  8. Widget? footer,
  9. TextStyle? titleStyle,
  10. dynamic style,
  11. Map<String, NyTextField Function(NyTextField nyTextField)>? metaData = const {},
  12. bool? hidden = false,
  13. bool? readOnly,
  14. required List options,
  15. Color? backgroundColor,
  16. Color? selectedColor,
  17. double headerSpacing = 5,
  18. double footerSpacing = 5,
  19. OutlinedBorder shape = const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(8))),
  20. BorderSide unselectedSide = const BorderSide(color: Colors.grey, width: 1),
  21. BorderSide selectedSide = const BorderSide(color: Colors.grey, width: 1),
  22. TextStyle labelStyle = const TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
  23. TextStyle unselectedTextStyle = const TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
  24. TextStyle selectedTextStyle = const TextStyle(fontWeight: FontWeight.bold, color: Colors.white),
  25. EdgeInsets padding = const EdgeInsets.all(8.0),
  26. double runSpacing = 8.0,
  27. double spacing = 8.0,
  28. Color checkmarkColor = Colors.white,
})

Field.chips is a constructor that helps in managing chips fields

Implementation

Field.chips(
  this.key, {
  this.label,
  this.value,
  this.validate,
  this.autofocus = false,
  this.dummyData,
  this.header,
  this.footer,
  this.titleStyle,
  this.style,
  this.metaData = const {},
  this.hidden = false,
  this.readOnly,
  required List<dynamic> options,
  Color? backgroundColor,
  Color? selectedColor,
  double headerSpacing = 5,
  double footerSpacing = 5,
  OutlinedBorder shape = const RoundedRectangleBorder(
      borderRadius: BorderRadius.all(Radius.circular(8))),
  BorderSide unselectedSide = const BorderSide(color: Colors.grey, width: 1),
  BorderSide selectedSide = const BorderSide(color: Colors.grey, width: 1),
  TextStyle labelStyle =
      const TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
  TextStyle unselectedTextStyle =
      const TextStyle(fontWeight: FontWeight.bold, color: Colors.black),
  TextStyle selectedTextStyle =
      const TextStyle(fontWeight: FontWeight.bold, color: Colors.white),
  EdgeInsets padding = const EdgeInsets.all(8.0),
  double runSpacing = 8.0,
  double spacing = 8.0,
  Color checkmarkColor = Colors.white,
}) : cast = FormCast.chips(
          options: options,
          backgroundColor: backgroundColor,
          selectedColor: selectedColor,
          headerSpacing: headerSpacing,
          footerSpacing: footerSpacing,
          shape: shape,
          unselectedSide: unselectedSide,
          selectedSide: selectedSide,
          labelStyle: labelStyle,
          unselectedTextStyle: unselectedTextStyle,
          selectedTextStyle: selectedTextStyle,
          padding: padding,
          runSpacing: runSpacing,
          spacing: spacing,
          checkmarkColor: checkmarkColor) {
  if (style == null) return;

  metaData = {};
  if (style is String) {
    style = style;
    return;
  }
  if (style is Map) {
    style as Map<String, dynamic>;
    metaData!["decoration_style"] =
        (style as Map<String, dynamic>).entries.first.value;
    style = (style as Map<String, dynamic>).entries.first.key;
  }
}