-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path#51 - navigation_pass_data_named_routes.dart
63 lines (54 loc) · 1.64 KB
/
#51 - navigation_pass_data_named_routes.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
initialRoute: '/', // home
routes: {
'/' : (context) => MyFirstPage(),
MySecondPage.pageRoute : (context) => MySecondPage(),
},
debugShowCheckedModeBanner: false,
);
}
}
class MyFirstPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Programming తెలుగులో")),
body: Scaffold(
body: Container(
alignment: Alignment.center,
child: RaisedButton(onPressed: (){
//Navigator.push(context, MaterialPageRoute(builder: (context) => MySecondPage() ));
Navigator.pushNamed(context, MySecondPage.pageRoute,arguments: MySecondPageArguments(title: "Second Screen",message: "This hello from Programming తెలుగులో"));
},child: Text("Go To Second Screen"),),
),
)
);
}
}
class MySecondPageArguments{
String title;
String message;
MySecondPageArguments({this.title,this.message});
}
class MySecondPage extends StatelessWidget {
static String pageRoute = "/SecondPage";
@override
Widget build(BuildContext context) {
MySecondPageArguments mySecondPageArguments = ModalRoute.of(context).settings.arguments;
return Scaffold(
appBar: AppBar(title: Text(mySecondPageArguments.title)),
body: Scaffold(
body: Container(
child: Center(child: Text(mySecondPageArguments.message)),
),
)
);
}
}