美文网首页
flutter操作提示栏SnackBar

flutter操作提示栏SnackBar

作者: wrootlflvl | 来源:发表于2019-07-11 09:56 被阅读0次
    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(onPressed: () {
          Scaffold.of(context).showSnackBar( // 打开操作提示栏
            SnackBar(
              content: Text('Processing...'),
              action: SnackBarAction(label: 'OK', onPressed: () {}),
            )
          );
        }, child: Text('Open SnackBar'));
      }
    }
    

    相关文章

      网友评论

          本文标题:flutter操作提示栏SnackBar

          本文链接:https://www.haomeiwen.com/subject/fhfrkctx.html