Skip to content

Instantly share code, notes, and snippets.

@rydmike
Created March 2, 2021 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rydmike/69574c0a9b469921515873f8188f0d50 to your computer and use it in GitHub Desktop.
Save rydmike/69574c0a9b469921515873f8188f0d50 to your computer and use it in GitHub Desktop.
Example: One way to make a dialog bigger
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