Dialog In Flutter :
This flutter tutorial post is dialog in flutter. That is used to logout, exit your application etc.
widget use
- Center
- RaisedButton
- showDialog
- Container
- Stack
- Positioned
- SizedBox
- Align
- FlatButton
Screenshot 1 :

Screenshot 2 :

main.dart
import 'package:flutter/material.dart'; import 'screen/page/ChipListPage.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Tutorial', debugShowCheckedModeBanner: false, home: MyHomePage(title: 'Dialog in Flutter'), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text(widget.title)), body: Center( child: RaisedButton( child: Text('Click'), onPressed: () { showDialog( context: context, builder: (BuildContext context) => CustomDialog( title: "Success", description: "Flutter Tutorial is best provide tutorial.", buttonText: "Okay", ), ); }))); } } class CustomDialog extends StatelessWidget { final String title, description, buttonText; final Image image; CustomDialog({ @required this.title, @required this.description, @required this.buttonText, this.image, }); @override Widget build(BuildContext context) { return Dialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), ), elevation: 0.0, backgroundColor: Colors.transparent, child: dialogContent(context), ); } dialogContent(BuildContext context) { const double padding = 16.0; const double avatarRadius = 40.0; return Stack(children: <Widget>[ Container( padding: EdgeInsets.only( top: avatarRadius + padding, left: padding, right: padding, ), margin: EdgeInsets.only(top: avatarRadius), decoration: new BoxDecoration( color: Colors.white, shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(padding), boxShadow: [ BoxShadow( color: Colors.black26, blurRadius: 10.0, offset: const Offset(0.0, 10.0), ) ]), child: Column(mainAxisSize: MainAxisSize.min, // To make the card compact children: <Widget>[ Text( this.title, style: TextStyle( fontSize: 24.0, fontWeight: FontWeight.w700, ), ), SizedBox(height: 16.0), Text(description, textAlign: TextAlign.center, style: TextStyle( fontSize: 16.0, )), SizedBox(height: 24.0), Align( alignment: Alignment.bottomRight, child: FlatButton( onPressed: () { Navigator.of(context).pop(); // To close the dialog }, child: Text(buttonText), )) ])), Positioned( left: padding, right: padding, child: CircleAvatar( backgroundColor: Colors.blue.withOpacity(0.9), radius: avatarRadius, )) ]); } }
The flutter tutorial is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application
For more information about Flutter. visit www.fluttertutorial.in