flutter AboutListTile widget

ListTile that shows an about box.

This widget is often added to an app's Drawer. When tapped it shows an about box dialog with showAboutDialog.

The about box will include a button that shows licenses for software used by the application. The licenses shown are those returned by the LicenseRegistry API, which can be used to add more licenses to the list.

If your application does not have a Drawer, you should provide an affordance to call showAboutDialog or (at least) showLicensePage.


Implementation:

AboutListTile({Key keyWidget iconWidget childString applicationNameString applicationVersionWidget applicationIconString applicationLegaleseList<Widget> aboutBoxChildrenbool dense})
Creates a list tile for showing an about box. [...]
const

Properties

aboutBoxChildren → List<Widget>
Widgets to add to the AboutDialog after the name, version, and legalese. [...]
final
applicationIcon → Widget
The icon to show next to the application name in the AboutDialog[...]
final
applicationLegalese → String
A string to show in small print in the AboutDialog[...]
final
applicationName → String
The name of the application. [...]
final
applicationVersion → String
The version of this build of the application. [...]
final
child → Widget
The label to show on this drawer item. [...]
final
dense → bool
Whether this list tile is part of a vertically dense list. [...]
final
hashCode → int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
icon → Widget
The icon to show for this drawer item. [...]
final

Example Code:

// Flutter code sample for AboutListTile

// This sample shows two ways to open [AboutDialog]. The first one
// uses an [AboutListTile], and the second uses the [showAboutDialog] function.

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

/// This Widget is the main application widget.
class MyApp extends StatelessWidget {
  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: MyStatelessWidget(),
    );
  }
}

/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends StatelessWidget {
  MyStatelessWidget({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final TextStyle textStyle = Theme.of(context).textTheme.bodyText2;
    final List<Widget> aboutBoxChildren = <Widget>[
      SizedBox(height: 24),
      RichText(
        text: TextSpan(
          children: <TextSpan>[
            TextSpan(
                style: textStyle,
                text: 'Flutter is Google’s UI toolkit for building beautiful, '
                    'natively compiled applications for mobile, web, and desktop '
                    'from a single codebase. Learn more about Flutter at '),
            TextSpan(
                style: textStyle.copyWith(color: Theme.of(context).accentColor),
                text: 'https://flutter.dev'),
            TextSpan(style: textStyle, text: '.'),
          ],
        ),
      ),
    ];

    return Scaffold(
      appBar: AppBar(
        title: Text('Show About Example'),
      ),
      drawer: Drawer(
        child: SingleChildScrollView(
          child: SafeArea(
            child: AboutListTile(
              icon: Icon(Icons.info),
              applicationIcon: FlutterLogo(),
              applicationName: 'Show About Example',
              applicationVersion: 'August 2019',
              applicationLegalese: '© 2014 The Flutter Authors',
              aboutBoxChildren: aboutBoxChildren,
            ),
          ),
        ),
      ),
      body: Center(
        child: RaisedButton(
          child: Text('Show About Example'),
          onPressed: () {
            showAboutDialog(
              context: context,
              applicationIcon: FlutterLogo(),
              applicationName: 'Show About Example',
              applicationVersion: 'August 2019',
              applicationLegalese: '© 2014 The Flutter Authors',
              children: aboutBoxChildren,
            );
          },
        ),
      ),
    );
  }
}


flutter AboutListTile widget flutter AboutListTile widget Reviewed by Admin on 4:49 AM Rating: 5

No comments:

Powered by Blogger.