|
1 | 1 | import 'package:flutter/material.dart'; |
2 | | -import 'package:wp_json_api/enums/WPAuthType.dart'; |
3 | | -import 'package:wp_json_api/models/responses/WPUserInfoResponse.dart'; |
4 | | -import 'package:wp_json_api/models/responses/WPUserLoginResponse.dart'; |
| 2 | +import 'package:wp_json_api/enums/wp_auth_type.dart'; |
| 3 | +import 'package:wp_json_api/models/responses/wp_user_info_response.dart'; |
| 4 | +import 'package:wp_json_api/models/responses/wp_user_login_response.dart'; |
5 | 5 | import 'package:wp_json_api/wp_json_api.dart'; |
6 | 6 |
|
7 | 7 | void main() => runApp(MyApp()); |
@@ -50,12 +50,17 @@ class _MyHomePageState extends State<MyHomePage> { |
50 | 50 | String email = _tfEmailController.text; |
51 | 51 | String password = _tfPasswordController.text; |
52 | 52 |
|
| 53 | + WPUserLoginResponse wpUserLoginResponse; |
53 | 54 | // LOGIN |
54 | | - WPUserLoginResponse wpUserLoginResponse = |
55 | | - await WPJsonAPI.instance.api((request) { |
56 | | - return request.wpLogin( |
57 | | - email: email, password: password, authType: WPAuthType.WpEmail); |
58 | | - }); |
| 55 | + try { |
| 56 | + wpUserLoginResponse = |
| 57 | + await WPJsonAPI.instance.api((request) { |
| 58 | + return request.wpLogin( |
| 59 | + email: email, password: password, authType: WPAuthType.WpEmail); |
| 60 | + }); |
| 61 | + } on Exception catch (e) { |
| 62 | + print(e); |
| 63 | + } |
59 | 64 |
|
60 | 65 | if (wpUserLoginResponse != null) { |
61 | 66 | print(wpUserLoginResponse.data.userToken); |
|
0 commit comments