Skip to content

Instantly share code, notes, and snippets.

@hellohejinyu
Last active September 24, 2020 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellohejinyu/802a997a4f2832b80f92ddd9ed814ba0 to your computer and use it in GitHub Desktop.
Save hellohejinyu/802a997a4f2832b80f92ddd9ed814ba0 to your computer and use it in GitHub Desktop.
flutter_intro
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatefulWidget {
@override
_MyWidgetState createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
OverlayEntry overlayEntry;
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
RaisedButton(
onPressed: () {
overlayEntry = OverlayEntry(
builder: (context) => Container(
color: Colors.white.withOpacity(.4),
child: Center(
child: RaisedButton(
onPressed: () {
overlayEntry.remove();
},
child: Text('点我关闭 OverlayEntry'),
),
),
),
);
Overlay.of(context).insert(overlayEntry);
},
child: Text('点我康康 Overlay 的用法'),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment