Commit 2d266fe7 authored by 窦文's avatar 窦文

奇怪的问题又增加了

parent c89d948f
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'second1.dart';
void main() {
runApp(MyApp());
// runApp(Login());
// runApp(TestPage());
print("启动");
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return WillPopScope(
child: MaterialApp(
title: 'Flutter Demo',
initialRoute: "/key1",
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Scaffold(
appBar: AppBar(
title: Text("路由"),
),
body: RouterNavigator(title: 'Flutter Demo Home Page'),
),
// routes: <String, WidgetBuilder>{"/key2": (context) => second()},
),
onWillPop: () async {
Fluttertoast.showToast(msg: "退出");
return true;
});
}
}
class RouterNavigator extends StatefulWidget {
RouterNavigator({Key key, this.title}) : super(key: key);
final String title;
@override
_RouterNavigatorState createState() => _RouterNavigatorState();
}
class _RouterNavigatorState extends State<RouterNavigator> {
bool byName = false;
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: [
_item("跳转", () {
Navigator.push(
context, MaterialPageRoute(builder: (context) => Second()));
})
],
),
);
}
_item(String title, VoidCallback onPressed) {
return Container(
child: RaisedButton(
onPressed: onPressed,
child: Text(title),
),
);
}
}
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
class Second extends StatelessWidget{
@override
Widget build(BuildContext context) {
return WillPopScope(
child: MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Scaffold(
appBar: AppBar(
title: Text("·2"),
),
body: RouterNavigator(title: 'Flutter Demo Home Page'),
),
),
onWillPop: () async {
Fluttertoast.showToast(msg: "˳");
return true;
});
}
}
class RouterNavigator extends StatefulWidget {
RouterNavigator({Key key, this.title}) : super(key: key);
final String title;
@override
_RouterNavigatorState createState() => _RouterNavigatorState();
}
class _RouterNavigatorState extends State<RouterNavigator> {
bool byName = false;
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: [
_item("ת", () {
Navigator.push(
context, MaterialPageRoute(builder: (context) => Second()));
})
],
),
);
}
_item(String title, VoidCallback onPressed) {
return Container(
child: RaisedButton(
onPressed: onPressed,
child: Text(title),
),
);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment