matthinc / flutter_cupertino_settings

A Flutter widget to create an iOS settings-table (static TableView).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug with CSSelection

antonvolokha opened this issue · comments

Selection not changed after currentSelection value changed in state

Platform: IOS, Android
Flutter 1.17.2
Dart 2.8.3

Example

class _SettingPageState extends State<SettingPage> {
  String _company = 'Example1';

  @override
  void initState() {
    super.initState();

    //Bug here
    asyncGet().then((value) => setState(() => _company = value));
  }

  @override
  Widget build(BuildContext context) {
     return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        CSSelection<String>(
          items: const <CSSelectionItem<String>>[
            CSSelectionItem<String>(text: 'Example1', value: 'Example1'),
            CSSelectionItem<String>(text: 'Example2', value: 'Example2'),
          ],
          onSelected: (value) {
            setState(() => _company = value);
          },
          currentSelection: _company,
        ),
      ],
    );
  }

}