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

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, //居中放置 位置可以设置成左中右
      ),
    );
  }
}

@作者: 亢少军

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

相关文章:

  • 2021-06-04
  • 2021-06-26
  • 2021-07-08
  • 2021-09-10
  • 2021-12-02
  • 2021-12-17
  • 2021-06-15
猜你喜欢
  • 2021-09-07
  • 2021-11-13
  • 2021-05-24
  • 2021-07-10
  • 2021-08-17
  • 2021-05-09
  • 2021-06-22
相关资源
相似解决方案