flutter SnackBar 底部消息提示
Posted loaderman
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了flutter SnackBar 底部消息提示相关的知识,希望对你有一定的参考价值。
具有可选操作的轻量级消息提示,在屏幕的底部显示
文档:https://api.flutter.dev/flutter/material/SnackBar-class.html
demo:
import ‘package:flutter/material.dart‘; class SnackBarDemo extends StatefulWidget @override _SnackBarDemoState createState() => _SnackBarDemoState(); class _SnackBarDemoState extends State<SnackBarDemo> @override Widget build(BuildContext context) return Scaffold( appBar: AppBar( title: Text(‘SnackBarDemo‘), elevation: 0.0, ), body: Container( padding: EdgeInsets.all(16.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ SnackBarButton(), ] ), ], ), ), ); class SnackBarButton extends StatelessWidget @override Widget build(BuildContext context) return FlatButton( child: Text(‘Open SnackBar‘), onPressed: () Scaffold.of(context).showSnackBar( SnackBar( content: Text(‘Processing...‘), action: SnackBarAction( label: ‘OK‘, onPressed: () , ), ) ); , );
效果:
以上是关于flutter SnackBar 底部消息提示的主要内容,如果未能解决你的问题,请参考以下文章