1
1
import 'dart:async' ;
2
2
import 'dart:collection' ;
3
+ import 'dart:developer' ;
3
4
import 'dart:io' ;
4
5
5
6
import 'package:flutter/material.dart' ;
@@ -16,7 +17,7 @@ class MyApp extends StatefulWidget {
16
17
const MyApp ({Key ? key}) : super (key: key);
17
18
18
19
@override
19
- _MyAppState createState () => _MyAppState ();
20
+ State < MyApp > createState () => _MyAppState ();
20
21
}
21
22
22
23
class _MyAppState extends State <MyApp > {
@@ -45,22 +46,26 @@ class _MyAppState extends State<MyApp> {
45
46
throw UnKnownException ('Unknown platform' );
46
47
}
47
48
48
- await Web3AuthFlutter .init (Web3AuthOptions (
49
+ await Web3AuthFlutter .init (
50
+ Web3AuthOptions (
49
51
clientId:
50
52
'BHgArYmWwSeq21czpcarYh0EVq2WWOzflX-NTK-tY1-1pauPzHKRRLgpABkmYiIV_og9jAvoIxQ8L3Smrwe04Lw' ,
51
53
network: Network .sapphire_devnet,
52
54
buildEnv: BuildEnv .testing,
53
55
redirectUrl: redirectUrl,
54
56
whiteLabel: WhiteLabelData (
55
- mode: ThemeModes .dark,
56
- defaultLanguage: Language .en,
57
- appName: "Web3Auth Flutter App" ,
58
- theme: themeMap)));
57
+ mode: ThemeModes .dark,
58
+ defaultLanguage: Language .en,
59
+ appName: "Web3Auth Flutter App" ,
60
+ theme: themeMap,
61
+ ),
62
+ ),
63
+ );
59
64
60
65
await Web3AuthFlutter .initialize ();
61
66
62
67
final String res = await Web3AuthFlutter .getPrivKey ();
63
- print (res);
68
+ log (res);
64
69
if (res.isNotEmpty) {
65
70
setState (() {
66
71
logoutVisible = true ;
@@ -123,22 +128,26 @@ class _MyAppState extends State<MyApp> {
123
128
height: 20 ,
124
129
),
125
130
ElevatedButton (
126
- onPressed: _login (_withGoogle),
127
- child: const Text ('Google' )),
131
+ onPressed: _login (_withGoogle),
132
+ child: const Text ('Google' ),
133
+ ),
128
134
ElevatedButton (
129
- onPressed: _login (_withFacebook),
130
- child: const Text ('Facebook' )),
135
+ onPressed: _login (_withFacebook),
136
+ child: const Text ('Facebook' ),
137
+ ),
131
138
ElevatedButton (
132
- onPressed: _login (_withEmailPasswordless),
133
- child: const Text ('Email Passwordless' )),
139
+ onPressed: _login (_withEmailPasswordless),
140
+ child: const Text ('Email Passwordless' ),
141
+ ),
134
142
ElevatedButton (
135
- onPressed: _login (_withDiscord),
136
- child: const Text ('Discord' )),
143
+ onPressed: _login (_withDiscord),
144
+ child: const Text ('Discord' ),
145
+ ),
137
146
],
138
147
),
139
148
),
140
149
Visibility (
141
- // ignore: sort_child_properties_last
150
+ visible : logoutVisible,
142
151
child: Column (
143
152
children: [
144
153
Center (
@@ -155,14 +164,15 @@ class _MyAppState extends State<MyApp> {
155
164
)),
156
165
),
157
166
ElevatedButton (
158
- onPressed: _privKey (_getPrivKey),
159
- child: const Text ('Get PrivKey' )),
167
+ onPressed: _privKey (_getPrivKey),
168
+ child: const Text ('Get PrivKey' ),
169
+ ),
160
170
ElevatedButton (
161
- onPressed: _userInfo (_getUserInfo),
162
- child: const Text ('Get UserInfo' )),
171
+ onPressed: _userInfo (_getUserInfo),
172
+ child: const Text ('Get UserInfo' ),
173
+ ),
163
174
],
164
175
),
165
- visible: logoutVisible,
166
176
),
167
177
Padding (
168
178
padding: const EdgeInsets .all (8.0 ),
@@ -178,14 +188,14 @@ class _MyAppState extends State<MyApp> {
178
188
VoidCallback _login (Future <Web3AuthResponse > Function () method) {
179
189
return () async {
180
190
try {
181
- final Web3AuthResponse response = await method ();
191
+ final Web3AuthResponse _ = await method ();
182
192
setState (() {
183
193
logoutVisible = true ;
184
194
});
185
195
} on UserCancelledException {
186
- print ("User cancelled." );
196
+ log ("User cancelled." );
187
197
} on UnKnownException {
188
- print ("Unknown exception occurred" );
198
+ log ("Unknown exception occurred" );
189
199
}
190
200
};
191
201
}
@@ -199,9 +209,9 @@ class _MyAppState extends State<MyApp> {
199
209
logoutVisible = false ;
200
210
});
201
211
} on UserCancelledException {
202
- print ("User cancelled." );
212
+ log ("User cancelled." );
203
213
} on UnKnownException {
204
- print ("Unknown exception occurred" );
214
+ log ("Unknown exception occurred" );
205
215
}
206
216
};
207
217
}
@@ -215,9 +225,9 @@ class _MyAppState extends State<MyApp> {
215
225
logoutVisible = true ;
216
226
});
217
227
} on UserCancelledException {
218
- print ("User cancelled." );
228
+ log ("User cancelled." );
219
229
} on UnKnownException {
220
- print ("Unknown exception occurred" );
230
+ log ("Unknown exception occurred" );
221
231
}
222
232
};
223
233
}
@@ -231,26 +241,32 @@ class _MyAppState extends State<MyApp> {
231
241
logoutVisible = true ;
232
242
});
233
243
} on UserCancelledException {
234
- print ("User cancelled." );
244
+ log ("User cancelled." );
235
245
} on UnKnownException {
236
- print ("Unknown exception occurred" );
246
+ log ("Unknown exception occurred" );
237
247
}
238
248
};
239
249
}
240
250
241
251
Future <Web3AuthResponse > _withGoogle () {
242
252
return Web3AuthFlutter .login (
243
- LoginParams (loginProvider: Provider .google, mfaLevel: MFALevel .NONE ));
253
+ LoginParams (loginProvider: Provider .google, mfaLevel: MFALevel .NONE ),
254
+ );
244
255
}
245
256
246
257
Future <Web3AuthResponse > _withFacebook () {
247
258
return Web3AuthFlutter .login (LoginParams (loginProvider: Provider .facebook));
248
259
}
249
260
250
261
Future <Web3AuthResponse > _withEmailPasswordless () {
251
- return Web3AuthFlutter .login (LoginParams (
262
+ return Web3AuthFlutter .login (
263
+ LoginParams (
252
264
loginProvider: Provider .email_passwordless,
253
- extraLoginOptions
: ExtraLoginOptions (login_hint
: "[email protected] " )));
265
+ extraLoginOptions: ExtraLoginOptions (
266
+
267
+ ),
268
+ ),
269
+ );
254
270
}
255
271
256
272
Future <Web3AuthResponse > _withDiscord () {
0 commit comments