AboutDialog flutter
"name": "AboutDialog",
"parent": "StatelessWidget",
"library": "material",
"description": "An about box. This is a dialog box with
the application's icon, name, version number, and copyright,
plus a button to show licenses for software used by the application."
If your application is made by using Flutter and you need to display information such as application version, legalese, and licenses, Flutter already has a widget that allows you to display that information easily. The widget is AboutDialog
.
Showing AboutDialog
Widget
To show AboutDialog
, call showAboutDialog
method, which is available after importing 'package:flutter/material.dart'
. Below is the method you need to invoke.
void showAboutDialog({ | |
@required BuildContext context, | |
String applicationName, | |
String applicationVersion, | |
Widget applicationIcon, | |
String applicationLegalese, | |
List<Widget> children, | |
bool useRootNavigator = true, | |
RouteSettings routeSettings, | |
}) |
Here's the description of each parameter
BuildContext context
: The build context.String applicationName
: The name of the application.String applicationVersion
: The build version of the application.Widget applicationIcon
: The icon to show next to the application name.String applicationLegalese
: A string to show in small print.List<Widget> children
: Widgets to add to the dialog box below the name, version, and legalese.bool useRootNavigator
: Whether to use root navigator.RouteSettings routeSettings
: Contains data that might be useful in constructing aRoute
.
In the below example, an about dialog popup will be shown by clicking a button
RaisedButton( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
child: Text('Show AboutDialog'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
onPressed: () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
showAboutDialog( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context: context, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
applicationIcon: FlutterLogo(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
applicationName: 'Woolha.com App', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
applicationVersion: '0.0.1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
applicationLegalese: '©2020 Woolha.com', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
children: <Widget>[ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Padding( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
padding: EdgeInsets.only(top: 15), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
child: Text('This is an about dialog in Flutter') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) Output: Adding Licenses1 As you can see in the above example, Flutter automatically adds the licenses of all libraries used to create the application. What if you need to add an additional license. You can do it using 1 Output:
Full CodeBelow is the full code of this tutorial. 1 |
No comments: