Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UserDialog extends StatefulWidget{
- @override
- _addToCMSState createState() => _addToCMSState();
- }
- enum Answer{AdminUser, StdUser, AuthUser, BasicUser}
- class _addToCMSState extends State<UserDialog> {
- String _answer = "";
- void setUserAuth(String value) {
- setState(() {
- _answer = value;
- });
- }
- Future<Null> _askUser() async {
- switch (
- await showDialog(context: context, builder: (BuildContext context) {
- return SimpleDialog(
- title: Text('Choose User Rights'),
- children: <Widget>[
- SimpleDialogOption(
- onPressed: () {
- Navigator.pop(context, Answer.AdminUser);
- },
- child: Text('Admin User'),
- ),
- SimpleDialogOption(
- onPressed: () {
- Navigator.pop(context, Answer.StdUser);
- },
- child: Text('Standard User'),
- ), SimpleDialogOption(
- onPressed: () {
- Navigator.pop(context, Answer.AuthUser);
- },
- child: Text('Author User'),
- ),
- SimpleDialogOption(
- onPressed: () {
- Navigator.pop(context, Answer.BasicUser);
- },
- child: Text('Basic User'),
- ),
- ],
- );
- }
- )) {
- case Answer.AdminUser:
- setUserAuth('Admin User');
- break;
- case Answer.StdUser:
- setUserAuth('Standard User');
- break;
- case Answer.AuthUser:
- setUserAuth('Author User');
- break;
- case Answer.BasicUser:
- setUserAuth('Basic User');
- break;
- }
- }
- noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement