-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathmain.dart
More file actions
196 lines (187 loc) · 7 KB
/
main.dart
File metadata and controls
196 lines (187 loc) · 7 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:go_router/go_router.dart';
import 'package:tree_planting_protocol/pages/home_page.dart';
import 'package:tree_planting_protocol/pages/mint_nft/mint_nft_details.dart';
import 'package:tree_planting_protocol/pages/mint_nft/mint_nft_images.dart';
import 'package:tree_planting_protocol/pages/mint_nft/mint_nft_organisation.dart';
import 'package:tree_planting_protocol/pages/mint_nft/submit_nft_page.dart';
import 'package:tree_planting_protocol/pages/organisations_pages/create_organisation.dart';
import 'package:tree_planting_protocol/pages/organisations_pages/organisation_details_page.dart';
import 'package:tree_planting_protocol/pages/organisations_pages/user_organisations_page.dart';
import 'package:tree_planting_protocol/pages/register_user_page.dart';
import 'package:tree_planting_protocol/pages/settings_page.dart';
import 'package:tree_planting_protocol/pages/tree_details_page.dart';
import 'package:tree_planting_protocol/pages/trees_page.dart';
import 'package:tree_planting_protocol/pages/user_profile_page.dart';
import 'package:tree_planting_protocol/pages/mint_nft/mint_nft_coordinates.dart';
import 'package:tree_planting_protocol/pages/nearby_trees_map_page.dart';
import 'package:tree_planting_protocol/providers/wallet_provider.dart';
import 'package:tree_planting_protocol/providers/theme_provider.dart';
import 'package:tree_planting_protocol/providers/mint_nft_provider.dart';
import 'package:tree_planting_protocol/utils/constants/route_constants.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:tree_planting_protocol/utils/logger.dart';
class NavigationService {
static GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
}
void main() async {
try {
await dotenv.load(fileName: ".env");
} catch (e) {
logger.d("No .env file found or error loading it: $e");
}
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
final GoRouter router = GoRouter(
initialLocation: RouteConstants.homePath,
routes: [
GoRoute(
path: RouteConstants.homePath,
name: RouteConstants.home,
builder: (BuildContext context, GoRouterState state) {
return const HomePage();
},
),
GoRoute(
path: '/register-user',
name: 'Register_user',
builder: (BuildContext context, GoRouterState state) {
return const RegisterUserPage();
},
),
GoRoute(
path: '/settings',
name: 'settings_page',
builder: (BuildContext context, GoRouterState state) {
return const SettingsPage();
},
),
GoRoute(
path: '/organisations',
name: 'organisations_page',
builder: (BuildContext context, GoRouterState state) {
return const OrganisationsPage();
},
routes: [
GoRoute(
path: ':address',
name: 'organisation_details',
builder: (BuildContext context, GoRouterState state) {
final address = state.pathParameters['address'];
return OrganisationDetailsPage(organisationAddress: address!);
},
),
],
),
GoRoute(
path: '/create-organisation',
name: 'create_organisation_page',
builder: (BuildContext context, GoRouterState state) {
return const CreateOrganisationPage();
},
),
GoRoute(
path: '/user-profile/:address',
name: 'user_profile',
builder: (BuildContext context, GoRouterState state) {
final address = state.pathParameters['address'].toString();
return UserProfilePage(
userAddress: address.isNotEmpty ? address : '');
},
),
GoRoute(
path: RouteConstants.mintNftOrganisationPath,
name: RouteConstants.mintNftOrganisation,
builder: (BuildContext context, GoRouterState state) {
return const MintNftOrganisationPage();
},
),
GoRoute(
path: RouteConstants.mintNftPath,
name: RouteConstants.mintNft,
builder: (context, state) => const MintNftCoordinatesPage(),
routes: [
GoRoute(
path: 'details',
name: '${RouteConstants.mintNft}_details',
builder: (BuildContext context, GoRouterState state) {
return const MintNftDetailsPage();
},
),
GoRoute(
path: 'images',
name: '${RouteConstants.mintNft}_images',
builder: (BuildContext context, GoRouterState state) {
return const MultipleImageUploadPage();
},
),
GoRoute(
path: 'submit-nft',
name: '${RouteConstants.mintNft}_submit',
builder: (BuildContext context, GoRouterState state) {
return const SubmitNFTPage();
},
),
]),
GoRoute(
path: '/nearby-trees',
name: 'nearby_trees',
builder: (BuildContext context, GoRouterState state) {
return const NearbyTreesMapPage();
},
),
GoRoute(
path: RouteConstants.allTreesPath,
name: RouteConstants.allTrees,
builder: (BuildContext context, GoRouterState state) {
return const AllTreesPage();
},
routes: [
GoRoute(
path: ':id',
name: '${RouteConstants.allTrees}_details',
builder: (BuildContext context, GoRouterState state) {
final id = state.pathParameters['id']; // read the dynamic ID
return TreeDetailsPage(treeId: id!);
},
),
],
),
],
errorBuilder: (context, state) => Scaffold(
body: Center(
child: Text('Page not found: ${state.uri.toString()}'),
),
),
);
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => WalletProvider()),
ChangeNotifierProvider(create: (context) => ThemeProvider()),
ChangeNotifierProvider(create: (context) => MintNftProvider()),
],
child: Consumer<ThemeProvider>(
builder: (context, themeProvider, child) {
return MaterialApp.router(
title: 'WalletConnect Demo',
routerConfig: router,
theme: ThemeData(
brightness: Brightness.light,
primarySwatch: Colors.blue,
),
darkTheme: ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.blue,
),
themeMode: themeProvider.themeMode,
);
},
),
);
}
}