-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.dart
139 lines (129 loc) · 4.6 KB
/
main.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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import 'package:example/routes/delegate.dart';
import 'package:flutter/material.dart';
import 'package:url_strategy/url_strategy.dart';
// with 2.0 navigation
//complex example
void main() {
setPathUrlStrategy();
runApp(MaterialApp.router(
routerConfig: GoRootDelegate.router,
));
}
/******************
* uncomment the rest of the file to use this
* simpler example, comment out the previous main
* simple example
******************/
// void main() {
// runApp(MaterialApp(
// home: MinProvider(controller: MyController(), child: MyPage()),
// ));
// // runApp(const MaterialApp()); //normal navigation
// }
// class MyController extends MinController {
// @override
// void onInit() {
// print('init controller');
// super.onInit();
// }
// final count = 0.minx;
// ValueNotifier<User> user = User().minx;
// increment() => count.value++;
// decrement() => count.value--;
// refresh() => count.value = 0;
// onChangedName(str) => user.update((val) => val.name = str);
// onSaveName(str) => user.update((val) => val.name = str);
// validateName(str) => str.length < 2 ? 'insert valid name' : null;
// }
// class MyPage extends StatelessWidget {
// final GlobalKey<FormState> formKey = GlobalKey<FormState>();
// MyPage({super.key});
// @override
// Widget build(BuildContext context) => Scaffold(
// floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
// floatingActionButton: MinX<MyController>(
// builder: (context, controller) => Column(
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// FloatingActionButton(
// backgroundColor: Colors.lightGreen,
// onPressed: () => controller.increment(),
// child: const Icon(Icons.add),
// ),
// const SizedBox(
// height: 16.0,
// ),
// FloatingActionButton(
// backgroundColor: Colors.redAccent,
// onPressed: () => controller.decrement(),
// child: const Icon(Icons.remove),
// ),
// const SizedBox(
// height: 16.0,
// ),
// FloatingActionButton(
// onPressed: () => controller.refresh(),
// child: const Icon(Icons.refresh),
// ),
// ],
// ),
// ),
// body: SafeArea(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// const Text('check out the full example in the example folder'),
// Container(
// margin: const EdgeInsets.only(
// left: 32.0, right: 32.0, bottom: 32.0),
// child: Form(
// key: formKey,
// child: MinX<MyController>(
// builder: (context, controller) => Column(
// children: [
// $(controller.user,
// (user) => Text('${user.name}'),
// ),
// TextFormField(
// onChanged: (value) => controller.onChangedName(value),
// validator: (value) => controller.validateName(value),
// onSaved: (newValue) =>
// controller.onSaveName(newValue),
// ),
// ],
// ),
// ),
// ),
// ),
// Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// MinX<MyController>(
// builder: (context, controller) => $(
// controller.count,
// (count) => Text(
// 'Count $count',
// style: const TextStyle(
// fontSize: 24.0,
// fontWeight: FontWeight.w600,
// ),
// ),
//
// ),
// ),
// ],
// ),
// ],
// ),
// ],
// ),
// ),
// );
// }
// class User {
// User({this.name});
// String? name;
// }