Skip to content

Instantly share code, notes, and snippets.

@machinescream
Created January 27, 2021 20:11
Show Gist options
  • Save machinescream/1572e5090075fd79251d4fd4543d7274 to your computer and use it in GitHub Desktop.
Save machinescream/1572e5090075fd79251d4fd4543d7274 to your computer and use it in GitHub Desktop.
flutter dialog junk
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() async {
runApp(MyApp());
await Future.delayed(Duration(seconds: 5));
runApp(MyApp2());
}
class MyApp2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.red,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: TextDirection.ltr,
child: Stack(
children: [
MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
),
Container(
color: Colors.redAccent,
)
],
),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
void initState() {
Future.delayed(Duration(seconds: 2), () {
showCupertinoDialog(
context: context,
builder: (_) {
return CupertinoAlertDialog(
title: Text('123456789'),
content: Container(
width: 100,
height: 100,
color: Colors.red,
),
actions: [
CupertinoDialogAction(
child: Text('pop'),
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
});
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(),
floatingActionButton: FloatingActionButton(
onPressed: () {},
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment