Created
March 2, 2021 13:05
-
-
Save rydmike/69574c0a9b469921515873f8188f0d50 to your computer and use it in GitHub Desktop.
Example: One way to make a dialog bigger
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'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Alert', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MyView(), | |
); | |
} | |
} | |
class MyView extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Sized Alert Dialog'), | |
), | |
body: Center( | |
child: ElevatedButton( | |
child: Text('Alert Dialog'), | |
onPressed: () { | |
_showDialog(context); | |
}, | |
), | |
), | |
); | |
} | |
} | |
void _showDialog(BuildContext context) { | |
showDialog( | |
context: context, | |
builder: (BuildContext context) { | |
return AlertDialog( | |
title: Text("Alert!!"), | |
content: ConstrainedBox( | |
constraints: const BoxConstraints( | |
minHeight: 400, minWidth: 400, maxWidth: 700), | |
child: Text("I am biger than normal"), | |
), | |
actions: <Widget>[ | |
TextButton( | |
child: new Text("OK"), | |
onPressed: () { | |
Navigator.of(context).pop(); | |
}, | |
), | |
], | |
); | |
}, | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment