美文网首页
Flutter-SnackBar(操作提示栏)

Flutter-SnackBar(操作提示栏)

作者: 梦幽辰 | 来源:发表于2020-01-03 13:35 被阅读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'),
          ),
          body: Container(
            padding: EdgeInsets.all(16),
            child: Center(
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  SnackButton(),
                ],
              ),
            ),
          ),
        );
      }
    }
    
    class SnackButton 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: (){},
                ),
              )
            );
          },
        );
      }
    }
    
    image.png

    相关文章

      网友评论

          本文标题:Flutter-SnackBar(操作提示栏)

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