Field.chips constructor

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

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

Implementation

Field.chips(
  this.key, {
  this.value,
  this.validate,
  this.autofocus = false,
  this.dummyData,
  this.header,
  this.footer,
  this.titleStyle,
  this.style,
  this.metaData = const {},
  this.hidden = false,
  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;
  }
}