@@ -395,56 +395,63 @@ class FormBuilderChoiceChip<T> extends FormBuilderFieldDecoration<T> {
395395 }) : super (builder: (FormFieldState <T ?> field) {
396396 final state = field as _FormBuilderChoiceChipState <T >;
397397
398- return InputDecorator (
399- decoration: state.decoration,
400- child: Wrap (
401- direction: direction,
402- alignment: alignment,
403- crossAxisAlignment: crossAxisAlignment,
404- runAlignment: runAlignment,
405- runSpacing: runSpacing,
406- spacing: spacing,
407- textDirection: textDirection,
408- verticalDirection: verticalDirection,
409- children: < Widget > [
410- for (FormBuilderChipOption <T > option in options)
411- ChoiceChip (
412- label: option,
413- side: side,
414- shape: shape,
415- selected: field.value == option.value,
416- onSelected: state.enabled
417- ? (selected) {
418- final choice = selected ? option.value : null ;
419- state.didChange (choice);
420- }
421- : null ,
422- avatar: option.avatar,
423- selectedColor: selectedColor,
424- disabledColor: disabledColor,
425- backgroundColor: backgroundColor,
426- shadowColor: shadowColor,
427- selectedShadowColor: selectedShadowColor,
428- elevation: elevation,
429- pressElevation: pressElevation,
430- materialTapTargetSize: materialTapTargetSize,
431- labelStyle: labelStyle,
432- labelPadding: labelPadding,
433- padding: padding,
434- visualDensity: visualDensity,
435- avatarBorder: avatarBorder,
436- showCheckmark: showCheckmark,
437- surfaceTintColor: surfaceTintColor,
438- clipBehavior: clipBehavior,
439- checkmarkColor: checkmarkColor,
440- autofocus: autofocus,
441- avatarBoxConstraints: avatarBoxConstraints,
442- chipAnimationStyle: chipAnimationStyle,
443- color: color,
444- iconTheme: iconTheme,
445- tooltip: tooltip,
446- ),
447- ],
398+ return Focus (
399+ focusNode: state.effectiveFocusNode,
400+ skipTraversal: true ,
401+ canRequestFocus: state.enabled,
402+ debugLabel: 'FormBuilderChoiceChip-$name ' ,
403+ child: InputDecorator (
404+ decoration: state.decoration,
405+ isFocused: state.effectiveFocusNode.hasFocus,
406+ child: Wrap (
407+ direction: direction,
408+ alignment: alignment,
409+ crossAxisAlignment: crossAxisAlignment,
410+ runAlignment: runAlignment,
411+ runSpacing: runSpacing,
412+ spacing: spacing,
413+ textDirection: textDirection,
414+ verticalDirection: verticalDirection,
415+ children: < Widget > [
416+ for (FormBuilderChipOption <T > option in options)
417+ ChoiceChip (
418+ label: option,
419+ side: side,
420+ shape: shape,
421+ selected: field.value == option.value,
422+ onSelected: state.enabled
423+ ? (selected) {
424+ final choice = selected ? option.value : null ;
425+ state.didChange (choice);
426+ }
427+ : null ,
428+ avatar: option.avatar,
429+ selectedColor: selectedColor,
430+ disabledColor: disabledColor,
431+ backgroundColor: backgroundColor,
432+ shadowColor: shadowColor,
433+ selectedShadowColor: selectedShadowColor,
434+ elevation: elevation,
435+ pressElevation: pressElevation,
436+ materialTapTargetSize: materialTapTargetSize,
437+ labelStyle: labelStyle,
438+ labelPadding: labelPadding,
439+ padding: padding,
440+ visualDensity: visualDensity,
441+ avatarBorder: avatarBorder,
442+ showCheckmark: showCheckmark,
443+ surfaceTintColor: surfaceTintColor,
444+ clipBehavior: clipBehavior,
445+ checkmarkColor: checkmarkColor,
446+ autofocus: autofocus,
447+ avatarBoxConstraints: avatarBoxConstraints,
448+ chipAnimationStyle: chipAnimationStyle,
449+ color: color,
450+ iconTheme: iconTheme,
451+ tooltip: tooltip,
452+ ),
453+ ],
454+ ),
448455 ),
449456 );
450457 });
@@ -455,4 +462,27 @@ class FormBuilderChoiceChip<T> extends FormBuilderFieldDecoration<T> {
455462}
456463
457464class _FormBuilderChoiceChipState <T >
458- extends FormBuilderFieldDecorationState <FormBuilderChoiceChip <T >, T > {}
465+ extends FormBuilderFieldDecorationState <FormBuilderChoiceChip <T >, T > {
466+ void handleFocusChange () {
467+ setState (() {});
468+ }
469+
470+ @override
471+ void initState () {
472+ super .initState ();
473+ effectiveFocusNode.addListener (handleFocusChange);
474+ }
475+
476+ @override
477+ void dispose () {
478+ effectiveFocusNode.removeListener (handleFocusChange);
479+ super .dispose ();
480+ }
481+
482+ @override
483+ void didChange (T ? value) {
484+ focus ();
485+ // effectiveFocusNode.requestFocus();
486+ super .didChange (value);
487+ }
488+ }
0 commit comments