Skip to content

Commit 8b67369

Browse files
committed
run flutter format
1 parent 574c0db commit 8b67369

File tree

10 files changed

+55
-44
lines changed

10 files changed

+55
-44
lines changed

example/main.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ class _MyHomePageState extends State<MyHomePage> {
5353
late WPUserLoginResponse? wpUserLoginResponse;
5454
// LOGIN
5555
try {
56-
wpUserLoginResponse =
57-
await WPJsonAPI.instance.api((request) => request.wpLogin(
58-
email: email, password: password, authType: WPAuthType.WpEmail)
59-
);
56+
wpUserLoginResponse = await WPJsonAPI.instance.api((request) =>
57+
request.wpLogin(
58+
email: email, password: password, authType: WPAuthType.WpEmail));
6059
} on Exception catch (e) {
6160
print(e);
6261
}

lib/exceptions/existing_user_email_exception.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
class ExistingUserEmailException implements Exception {
1717
String message;
1818
ExistingUserEmailException(this.message);
19-
}
19+
}

lib/exceptions/existing_user_login_exception.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
class ExistingUserLoginException implements Exception {
1717
String message;
1818
ExistingUserLoginException(this.message);
19-
}
19+
}

lib/exceptions/invalid_email_exception.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
class InvalidEmailException implements Exception {
1717
String message;
1818
InvalidEmailException(this.message);
19-
}
19+
}

lib/models/responses/wc_customer_info_response.dart

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Data {
5555
this.avatar,
5656
this.shipping,
5757
this.billing,
58-
this.metaData});
58+
this.metaData});
5959

6060
Data.fromJson(Map<String, dynamic> json) {
6161
firstName = json['first_name'];
@@ -98,19 +98,21 @@ class Data {
9898
///
9999
/// Returns List<dynamic>
100100
List<dynamic>? getMetaDataArrayWhere(String key) {
101-
MetaData? metaData = this.metaData!.firstWhereOrNull((e) => e.key == key);
102-
if (metaData == null || metaData.value == null) {
103-
return null;
104-
}
105-
return metaData.value;
101+
MetaData? metaData = this.metaData!.firstWhereOrNull((e) => e.key == key);
102+
if (metaData == null || metaData.value == null) {
103+
return null;
104+
}
105+
return metaData.value;
106106
}
107107

108108
/// Returns a single meta data value from a WP MetaData [key]
109109
///
110110
/// Returns dynamic
111111
dynamic getMetaDataFirstWhere(String key) {
112112
MetaData? metaData = this.metaData!.firstWhereOrNull((e) => e.key == key);
113-
if (metaData == null || metaData.value == null || metaData.value!.length < 1) {
113+
if (metaData == null ||
114+
metaData.value == null ||
115+
metaData.value!.length < 1) {
114116
return null;
115117
}
116118
return metaData.value!.first;
@@ -235,10 +237,11 @@ class MetaData {
235237
}
236238

237239
Map<String?, dynamic> toJson() {
238-
final Map<String?, List<dynamic>?> data = new Map<String?, List<dynamic>?>();
240+
final Map<String?, List<dynamic>?> data =
241+
new Map<String?, List<dynamic>?>();
239242
if (key != null) {
240243
data[key] = this.value;
241244
}
242245
return data;
243246
}
244-
}
247+
}

lib/models/responses/wp_user_info_response.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ class Data {
5454

5555
Data(
5656
{this.id,
57-
this.firstName,
58-
this.lastName,
59-
this.username,
60-
this.userNicename,
61-
this.displayName,
62-
this.userStatus,
63-
this.email,
64-
this.avatar,
65-
this.metaData,
66-
this.createdAt});
57+
this.firstName,
58+
this.lastName,
59+
this.username,
60+
this.userNicename,
61+
this.displayName,
62+
this.userStatus,
63+
this.email,
64+
this.avatar,
65+
this.metaData,
66+
this.createdAt});
6767

6868
Data.fromJson(Map<String, dynamic> json) {
6969
id = json['id'];
@@ -118,7 +118,9 @@ class Data {
118118
/// Returns dynamic
119119
dynamic getMetaDataFirstWhere(String key) {
120120
MetaData? metaData = this.metaData!.firstWhereOrNull((e) => e.key == key);
121-
if (metaData == null || metaData.value == null || metaData.value!.length < 1) {
121+
if (metaData == null ||
122+
metaData.value == null ||
123+
metaData.value!.length < 1) {
122124
return null;
123125
}
124126
return metaData.value!.first;
@@ -137,7 +139,8 @@ class MetaData {
137139
}
138140

139141
Map<String?, dynamic> toJson() {
140-
final Map<String?, List<dynamic>?> data = new Map<String?, List<dynamic>?>();
142+
final Map<String?, List<dynamic>?> data =
143+
new Map<String?, List<dynamic>?>();
141144
if (key != null) {
142145
data[key] = this.value;
143146
}

lib/models/wp_meta_meta.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ class UserMetaDataItem {
2121
WPMetaDataActionType action;
2222
int? unique;
2323

24-
UserMetaDataItem({this.key, this.value, this.action = WPMetaDataActionType.Update, this.unique});
24+
UserMetaDataItem(
25+
{this.key,
26+
this.value,
27+
this.action = WPMetaDataActionType.Update,
28+
this.unique});
2529

2630
Map<String, dynamic> toJson() {
2731
final Map<String, dynamic> data = new Map<String, dynamic>();

lib/networking/network_manager.dart

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class WPAppNetworkManager {
6969
required String password,
7070
WPAuthType authType = WPAuthType.WpEmail,
7171
String? tokenExpiryAt}) async {
72-
7372
// Get nonce from WordPress
7473
WPNonceResponse wpNonceResponse = await wpNonce();
7574

@@ -168,8 +167,7 @@ class WPAppNetworkManager {
168167
///
169168
/// Returns a [WPNonceVerifiedResponse] future.
170169
/// Throws an [Exception] if fails
171-
Future<WPNonceVerifiedResponse> wpNonceVerify(
172-
{required String nonce}) async {
170+
Future<WPNonceVerifiedResponse> wpNonceVerify({required String nonce}) async {
173171
Map<String, dynamic> payload = {"nonce": nonce};
174172

175173
// send http request
@@ -212,7 +210,10 @@ class WPAppNetworkManager {
212210
/// Returns a [WPUserInfoUpdatedResponse] future.
213211
/// Throws an [Exception] if fails.
214212
Future<WPUserInfoUpdatedResponse> wpUpdateUserInfo(userToken,
215-
{String? firstName, String? lastName, String? displayName, List<UserMetaDataItem>? wpUserMetaData}) async {
213+
{String? firstName,
214+
String? lastName,
215+
String? displayName,
216+
List<UserMetaDataItem>? wpUserMetaData}) async {
216217
Map<String, dynamic> payload = {};
217218
if (firstName != null) payload["first_name"] = firstName;
218219
if (lastName != null) payload["last_name"] = lastName;
@@ -242,7 +243,8 @@ class WPAppNetworkManager {
242243
///
243244
/// Returns a [WPUserInfoUpdatedResponse] future.
244245
/// Throws an [Exception] if fails.
245-
Future<WPUserAddRoleResponse> wpUserAddRole(userToken, {required String role}) async {
246+
Future<WPUserAddRoleResponse> wpUserAddRole(userToken,
247+
{required String role}) async {
246248
Map<String, dynamic> payload = {};
247249
payload["role"] = role;
248250

@@ -265,7 +267,8 @@ class WPAppNetworkManager {
265267
///
266268
/// Returns a [WPUserInfoUpdatedResponse] future.
267269
/// Throws an [Exception] if fails.
268-
Future<WPUserRemoveRoleResponse> wpUserRemoveRole(userToken, {required String role}) async {
270+
Future<WPUserRemoveRoleResponse> wpUserRemoveRole(userToken,
271+
{required String role}) async {
269272
Map<String, dynamic> payload = {};
270273
payload["role"] = role;
271274

@@ -541,11 +544,11 @@ class WPAppNetworkManager {
541544
{
542545
return "/wpapp/api/$apiVersion/update/user/info";
543546
}
544-
case WPRouteType.UserAddRole:
547+
case WPRouteType.UserAddRole:
545548
{
546549
return "/wpapp/api/$apiVersion/update/user/role/add";
547550
}
548-
case WPRouteType.UserRemoveRole:
551+
case WPRouteType.UserRemoveRole:
549552
{
550553
return "/wpapp/api/$apiVersion/update/user/role/remove";
551554
}
@@ -603,9 +606,11 @@ class WPAppNetworkManager {
603606
throw new UserAlreadyExistException();
604607
case 542:
605608
throw new EmptyUsernameException();
606-
default: {
607-
throw new Exception('Something went wrong, please check server response');
608-
}
609+
default:
610+
{
611+
throw new Exception(
612+
'Something went wrong, please check server response');
613+
}
609614
}
610615
}
611616
}

lib/wp_json_api.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import 'package:wp_json_api/networking/network_manager.dart';
2020

2121
/// The base class to initialize and use WPJSONAPI
2222
class WPJsonAPI {
23-
2423
/// Private constructor for WPJSONAPI
2524
WPJsonAPI._privateConstructor();
2625

test/wp_json_api_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
void main() {
2-
3-
}
1+
void main() {}

0 commit comments

Comments
 (0)