Last active
February 9, 2021 08:54
-
-
Save Zujaj/379da35c443f32d16293772757d53fc6 to your computer and use it in GitHub Desktop.
A Demo page that displays an Elevated Button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:multiple_selection_dialogue_app/widgets/multi_select_dialog.dart'; | |
/// A demo page that displays an [ElevatedButton] | |
class DemoPage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
/// Stores the selected flavours | |
List<String> flavours = []; | |
return ElevatedButton( | |
child: Text('Flavours'), | |
onPressed: () async { | |
flavours = await showDialog<List<String>>( | |
context: context, | |
builder: (_) => MultiSelectDialog( | |
question: Text('Select Your Flavours'), | |
answers: [ | |
'Chocolate', | |
'Caramel', | |
'Vanilla', | |
'Peanut Butter' | |
])) ?? | |
[]; | |
print(flavours); | |
// Logic to save selected flavours in the database | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment