第5章MaterialDesign风格组件-SnackBar轻量提示组件

防采集标记:亢少军老师的课程和资料

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('SnackBar示例'),
        ),
        body: Center(
          child: Text(
            'SnackBar示例',
            style: TextStyle(fontSize: 28.0),
          ),
        ),
        floatingActionButton: new Builder(builder: (BuildContext context) {
          return new FloatingActionButton(
            child: const Icon(Icons.add),
            onPressed: () {
              //点击回调事件 弹出一句提示语句
              Scaffold.of(context).showSnackBar(new SnackBar(
                content: new Text("显示SnackBar"),
              ));
            },
            shape: new CircleBorder(),
          );
        }),
        floatingActionButtonLocation:
        FloatingActionButtonLocation.endFloat, //居中放置 位置可以设置成左中右
      ),
    );
  }
}
  • Flutter技术入门与实战: http://product.dangdang.com/26485813.html
  • Flutter交流学习群:894109159
  • Flutter开源项目请关注: https://github.com/kangshaojun
  • Flutter视频教程:https://edu.csdn.net/lecturer/2436

@作者: 亢少军

你可能感兴趣的:(第5章MaterialDesign风格组件-SnackBar轻量提示组件)