Skip to content

Programmatically change combobox selected value. #880

Answered by WinXaito
Pololot64 asked this question in Q&A
Discussion options

You must be logged in to vote

I think you do something wrong, see an example:

void main() async {
  runApp(
    FluentApp(
      debugShowCheckedModeBanner: false,
      title: 'Title',
      home: Center(child: Demo()),
    ),
  );
}

class Demo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _DemoState();
}

class _DemoState extends State<Demo> {
  int selected = 0;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        ComboBox<int>(
          value: selected,
          items: const [
            ComboBoxItem(value: 0,child: Text('Item1'),),
            ComboBoxItem(value: 1,child: Text('Item2'),),
            ComboBoxItem(value: 2,child: Text('…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by Pololot64
Comment options

You must be logged in to vote
1 reply
@WinXaito
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants