dialog flutter example
showDialog(context: context, builder: (BuildContext context){
return AlertDialog(
title: Text("Success"),
content: Text("Saved successfully"),
);
});
dialog flutter example
showDialog(context: context, builder: (BuildContext context){
return AlertDialog(
title: Text("Success"),
content: Text("Saved successfully"),
);
});
Flutter form dialog
import 'package:flutter/material.dart';
class StatefulDialog extends StatefulWidget {
@override
_StatefulDialogState createState() => _StatefulDialogState();
}
class _StatefulDialogState extends State<StatefulDialog> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
final TextEditingController _textEditingController = TextEditingController();
Future<void> showInformationDialog(BuildContext context) async {
return await showDialog(
context: context,
builder: (context) {
bool isChecked = false;
return StatefulBuilder(builder: (context, setState) {
return AlertDialog(
content: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextFormField(
controller: _textEditingController,
validator: (value) {
return value.isNotEmpty ? null : "Enter any text";
},
decoration:
InputDecoration(hintText: "Please Enter Text"),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Choice Box"),
Checkbox(
value: isChecked,
onChanged: (checked) {
setState(() {
isChecked = checked;
});
})
],
)
],
)),
title: Text('Stateful Dialog'),
actions: <Widget>[
InkWell(
child: Text('OK '),
onTap: () {
if (_formKey.currentState.validate()) {
// Do something like updating SharedPreferences or User Settings etc.
Navigator.of(context).pop();
}
},
),
],
);
});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Center(
child: FlatButton(
color: Colors.deepOrange,
onPressed: () async {
await showInformationDialog(context);
},
child: Text(
"Stateful Dialog",
style: TextStyle(color: Colors.white, fontSize: 16),
)),
),
),
);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us