Skip to content

Instantly share code, notes, and snippets.

@Kurogoma4D
Created October 25, 2019 04:43
Show Gist options
  • Save Kurogoma4D/525fbce24561e8aab0c5741813b30de1 to your computer and use it in GitHub Desktop.
Save Kurogoma4D/525fbce24561e8aab0c5741813b30de1 to your computer and use it in GitHub Desktop.
画面遷移後の処理例
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