MaterialBanner In Flutter

MaterialBanner In Flutter :

This flutter tutorial post is MaterialBanner widget in flutter.
A banner displays very important, message, and other provides actions. Actions using MaterialBanner widget dismissed or other action.

const MaterialBanner({
   Key key,
   @required this.content,
   this.contentTextStyle,
   @required this.actions,
   this.leading,
   this.backgroundColor,
   this.padding,
   this.leadingPadding,
   this.forceActionsBelow = false,
 })  

Screenshot :

MaterialBanner In Flutter

Material Banner.dart

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final TextStyle whiteText = TextStyle(
    color: Colors.white,
  );

  bool shouldShowBanner = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("Material Banner"),
        ),
        body: Column(children: <Widget>[
          if (shouldShowBanner)
            MaterialBanner(
                padding: const EdgeInsets.all(20),
                contentTextStyle: whiteText,
                content: Text(
                  "Flutter Tutorial",
                ),
                leading: Icon(Icons.credit_card, color: Colors.white),
                backgroundColor: Colors.indigo,
                actions: <Widget>[
                  FlatButton(
                      child: Text("UPDATE", style: whiteText),
                      onPressed: _hideBanner),
                  FlatButton(
                      child: Text("DISMISS", style: whiteText),
                      onPressed: _hideBanner)
                ])
        ]));
  }

  void _hideBanner() {
    setState(() => shouldShowBanner = false);
  }
}

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