Created
February 3, 2020 13:00
-
-
Save ryanlid/9803b4e354316149f8745a8e8214d76c to your computer and use it in GitHub Desktop.
SnackBar 轻量提示组件
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: "SnackBar 示例", | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text('SnackBar 示例'), | |
), | |
body: Center( | |
child: Text( | |
'SnackBar 示例', | |
style: TextStyle(fontSize: 28.0), | |
), | |
), | |
floatingActionButton: Builder( | |
builder: (BuildContext context) { | |
return FloatingActionButton( | |
child: const Icon(Icons.add), | |
onPressed: () { | |
Scaffold.of(context).showSnackBar(SnackBar( | |
content: Text('显示 SnackBar'), | |
)); | |
}, | |
shape: CircleBorder(), | |
); | |
}, | |
), | |
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment