Your experience on this site will be improved by allowing cookies
The dialog is a type of widget which comes on the window or the screen which contains any critical information or can ask for any decision. When a dialog box is popped up all the other functions get disabled until you close the dialog box or provide an answer. We use a dialog box for a different type of condition such as an alert notification, or simple notification in which different options are shown, or we can also make a dialog box that can be used as a tab for showing the dialog box.
Alert dialog tells the user about any condition that requires any recognition. The alert dialog contains an optional title and an optional list of actions. We have different no of actions as our requirements. Sometimes the content is too large compared to the screen size so for resolving this problem we may have to use the expanded class.
Properties:
Constructor:
AlertDialog( { Key key, Widget title, EdgeInsetsGeometry titlePadding, TextStyle titleTextStyle, Widget content, EdgeInsetsGeometry contentPadding: const EdgeInsets.fromLTRB(24.0, 20.0, 24.0, 24.0), TextStyle contentTextStyle, List actions, EdgeInsetsGeometry actionsPadding: EdgeInsets.zero, VerticalDirection actionsOverflowDirection, double actionsOverflowButtonSpacing, EdgeInsetsGeometry buttonPadding, Color backgroundColor, double elevation, String semanticLabel, EdgeInsets insetPadding: _defaultInsetPadding, Clip clipBehavior: Clip.none, ShapeBorder shape, bool scrollable: false } )
Here is the snippet code for creating a dialog box.
|
Output:
Alert dialog
A simple dialog allows the user to choose from different choices. It contains the title which is optional and presented above the choices. We can show options by using the padding also. Padding is used to make a widget more flexible.
Properties:
Constructor:
const SimpleDialog( { Key key, Widget title, EdgeInsetsGeometry titlePadding: const EdgeInsets.fromLTRB(24.0, 24.0, 24.0, 0.0), TextStyle titleTextStyle, List children, EdgeInsetsGeometry contentPadding: const EdgeInsets.fromLTRB(0.0, 12.0, 0.0, 16.0), Color backgroundColor, double elevation, String semanticLabel, ShapeBorder shape } )
Here is the snippet code for Simple dialog
|
Output:
SimpleDialog
It basically used to change the current screen of our app to show the dialog popup. You must call before the dialog popup. It exits the current animation and presents a new screen animation. We use this dialog box when we want to show a tab that will popup any type of dialog box, or we create a front tab to show the background process.
Properties:
Constructor:
Future showDialog ( { @required BuildContext context, WidgetBuilder builder, bool barrierDismissible: true, Color barrierColor, bool useSafeArea: true, bool useRootNavigator: true, RouteSettings routeSettings, @Deprecated(It returns the child from the closure provided to the builder class ) Widget child } )
Here is the snippet for the showDialog function.
|
Output:
AlertDialog
SimpleDialog
ShowDialog
0 comments