Created
October 25, 2019 04:43
-
-
Save Kurogoma4D/525fbce24561e8aab0c5741813b30de1 to your computer and use it in GitHub Desktop.
画面遷移後の処理例
This file contains 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: 'Flutter Demo', | |
home: HomePage(), | |
); | |
} | |
} | |
class HomePage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(title: const Text('TEST')), | |
body: Center( | |
child: FlatButton( | |
child: Text("to B"), | |
onPressed: () => Navigator.of(context).push( | |
MaterialPageRoute(builder: (BuildContext context) => ScreenB())), | |
)), | |
); | |
} | |
} | |
class ScreenB extends StatefulWidget { | |
@override | |
_ScreenBState createState() => _ScreenBState(); | |
} | |
class _ScreenBState extends State<ScreenB> { | |
@override | |
void initState() { | |
super.initState(); | |
Future.delayed(Duration(seconds: 3)).then( | |
((_) => showDialog( | |
context: context, | |
builder: (context) { | |
return AlertDialog( | |
content: Container( | |
child: Text("dialog"), | |
), | |
); | |
})), | |
); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Screen B"), | |
), | |
body: Center( | |
child: Text("HI."), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment