bdlukaa / fluent_ui

Implements Microsoft's WinUI3 in Flutter.
https://bdlukaa.github.io/fluent_ui/
BSD 3-Clause "New" or "Revised" License
2.79k stars 435 forks source link

šŸ›In the document, there is a bug in the source code of the AutoSuggestBox component. #1069

Closed avensteven closed 1 week ago

avensteven commented 1 month ago

Describe the bug In the document, there is a bug in the source code of the AutoSuggestBox component. The placeholder property does not exist in the AutoSuggestBoxItem component, but should be in the AutoSuggestBox component.

error code

String? selectedCat;

AutoSuggestBox<String>(
  items: cats.map((cat) {
    return AutoSuggestBoxItem<String>(
      placeholder: 'Type a cat name',
      value: cat,
      label: cat,
      onFocusChange: (focused) {
        if (focused) { 
          debugPrint('Focused $cat');
        }
      }
    );
  }).toList(),
  onSelected: (item) {
    setState(() => selected = item);
  },
),

const cats = <String>[
  'Abyssinian',
  'Aegean',
  'American Bobtail',
  'American Curl',
  ...
];

right code

String? selectedCat;

AutoSuggestBox<String>(
  placeholder: 'Type a cat name',
  items: cats.map((cat) {
    return AutoSuggestBoxItem<String>(
      value: cat,
      label: cat,
      onFocusChange: (focused) {
        if (focused) { 
          debugPrint('Focused $cat');
        }
      }
    );
  }).toList(),
  onSelected: (item) {
    setState(() => selected = item);
  },
),

const cats = <String>[
  'Abyssinian',
  'Aegean',
  'American Bobtail',
  'American Curl',
  ...
];