-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib file
99 lines (82 loc) · 2.14 KB
/
lib file
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import 'package:flutter/material.dart';
import 'first_screen.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: HomePage('flutter demo', Colors.brown, true),
);
}
}
import 'package:flutter/material.dart';
import 'package:myapp/center_widget.dart';
import 'package:myapp/second_screen.dart';
class HomePage extends StatefulWidget {
const HomePage(this.title, this.color, this.center, {super.key});
final String title;
final Color color;
final bool center;
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
var activeScreen = 'centerWidget';
void switchScreen() {
setState(() {
activeScreen = 'secondScreen';
});
}
import 'package:flutter/material.dart';
class CenterWidget extends StatelessWidget {
const CenterWidget(this.press,this.text, {super.key});
final void Function() press;
final String text;
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
container,
SizedBox(height: 39),
OutlinedButton.icon(
style: OutlinedButton.styleFrom(
),
onPressed: press,
icon: Icon(Icons.person_search),
label: Text(text),
),
],
),
);
}
}
Container container = Container(width: 110, height: 150, color: Colors.brown);
import 'package:flutter/material.dart';
class SecondScreen extends StatelessWidget {
const SecondScreen(this.text1, {super.key});
final String text1;
@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width:150,
height: 200,
color: Colors.brown,
),
Text(text1),
],
),
);
}
}