Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created February 3, 2020 13:00
Show Gist options
  • Save ryanlid/9803b4e354316149f8745a8e8214d76c to your computer and use it in GitHub Desktop.
Save ryanlid/9803b4e354316149f8745a8e8214d76c to your computer and use it in GitHub Desktop.
SnackBar 轻量提示组件
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