import 'package:flutter/material.dart';
import 'dart:ui';
import 'dart:async';
enum Option{A,B,C}
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
Future dialogBox()async{
final option=await showDialog(
context: context,
builder: (BuildContext context){
return SimpleDialog(
title: Text('this is a dialog'),
children: <Widget>[
SimpleDialogOption(
child: Text('option A'),
onPressed: (){
Navigator.pop(context,Option.A);
},
),
SimpleDialogOption(
child: Text('option B'),
onPressed: (){
Navigator.pop(context,Option.B);
},
),
SimpleDialogOption(
child: Text('option C'),
onPressed: (){
Navigator.pop(context,Option.C);
},
),
],
);
}
);
switch(option){
case Option.C:
debugPrint('your choice is C');
break;
case Option.A:
debugPrint('your choice is A');
break;
case Option.B:
debugPrint('your choice is B');
break;
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
width: window.physicalSize.width,
height: window.physicalSize.height,
child: Image.network(
'http://www.ecobentech.com/img/a.jpg',
fit: BoxFit.cover,
),
),
floatingActionButton: FloatingActionButton(
onPressed:(){dialogBox();},
child: Icon(Icons.text_fields),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
);
}
}