xxxxxxxxxx
Future<void> _showMyDialog() async {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: Text('AlertDialog Title'),
content: SingleChildScrollView(
child: Column(
children: <Widget>[
Text('This is a demo alert dialog.'),
Text('Would you like to confirm this message?'),
],
),
),
actions: <Widget>[
TextButton(
child: Text('Confirm'),
onPressed: () {
print('Confirmed');
Navigator.of(context).pop();
},
),
TextButton(
child: Text('Cancel'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
xxxxxxxxxx
showDialog(Dialog(
backgroundColor: Colors.transparent,
insetPadding: EdgeInsets.all(10),
child: Stack(
overflow: Overflow.visible,
alignment: Alignment.center,
children: <Widget>[
Container(
width: double.infinity,
height: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.lightBlue
),
padding: EdgeInsets.fromLTRB(20, 50, 20, 20),
child: Text("You can make cool stuff!",
style: TextStyle(fontSize: 24),
textAlign: TextAlign.center
),
),
Positioned(
top: -100,
child: Image.network("https://i.imgur.com/2yaf2wb.png", width: 150, height: 150)
)
],
)
));
xxxxxxxxxx
import 'package:flutter/material.dart';
// Function to show the dialog box
void showDialogBox(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text("Dialog Box"),
content: Text("This is a sample dialog box."),
actions: <Widget>[
FlatButton(
child: Text("Close"),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
// Usage example
class MyExampleScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Dialog Box Example"),
),
body: Center(
child: RaisedButton(
child: Text("Show Dialog Box"),
onPressed: () {
showDialogBox(context); // Call the function to show the dialog box
},
),
),
);
}
}
xxxxxxxxxx
showDialog(
context: context,
builder: (context) => AboutDialog(
applicationName: 'AllAboutFlutter',
applicationVersion: '1.0.0',
applicationIcon: CircleAvatar(
child: Image.network(
'https://static.wixstatic.com/media/73e5ab_e0a33a24b96c4e09a876668a29fd73c4~mv2.png'),
),
applicationLegalese:
'© 2023 AllAboutFlutter. All rights reserved.',
children: const [
Text(
'AllAboutFlutter is a website that provides tutorials on Flutter and Dart.'),
],
),
);