- http_util.dart: dio4->5 (DioException, nullable params, drop unused statusCode, null-safe e.response!.data), countryCode ?? '' - models/* (39 files): make all instance fields nullable (fromJson initializer-list pattern forces nullable); fix internal method usages (cart_info/cart_line_item/ order/shipping_rate) with !/?? - models/ now passes dart analyze with 0 errors Widget-level null-safety + remaining utils/store continue in next batch.
63 lines
1.7 KiB
Dart
63 lines
1.7 KiB
Dart
|
|
import 'dart:convert';
|
|
|
|
class User {
|
|
int? id;
|
|
String? username;
|
|
String? nickname;
|
|
String? mobile;
|
|
String? email;
|
|
String? avatarUrl;
|
|
int? lastAddressId;
|
|
String? passCode;
|
|
double? credit;
|
|
double? wallet;
|
|
int? coupon;
|
|
int? points;
|
|
int? orderNum;
|
|
double? pointsToCreditsConversionRate;
|
|
String? contactNumber;
|
|
String? flutterMiniStoreToken;
|
|
|
|
User.fromJson(Map<String, dynamic> json)
|
|
: id = json['id'],
|
|
username = json['username'],
|
|
nickname = json['nickname'],
|
|
mobile = json['mobile'],
|
|
email = json['email'],
|
|
avatarUrl = json['avatar_url'],
|
|
lastAddressId = json['last_address_id'],
|
|
passCode = json['pass_code'],
|
|
credit = double.parse(json['credit'].toString()),
|
|
wallet = double.parse((json['wallet'] == null) ? "0": json['wallet'].toString()),
|
|
coupon = json['coupon'],
|
|
points = json['points'],
|
|
orderNum = json['order_num'],
|
|
pointsToCreditsConversionRate = double.parse(json['points_to_credits_conversion_rate'].toString()),
|
|
contactNumber = json['contact_number'],
|
|
flutterMiniStoreToken = json['flutter_ministore_token'];
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'username': username,
|
|
'nickname': nickname,
|
|
'mobile': mobile,
|
|
'email': email,
|
|
'avatar_url': avatarUrl,
|
|
'last_address_id': lastAddressId,
|
|
'pass_code': passCode,
|
|
'credit': credit,
|
|
'wallet': wallet,
|
|
'coupon': coupon,
|
|
'points': points,
|
|
'order_num': orderNum,
|
|
'points_to_credits_conversion_rate': pointsToCreditsConversionRate,
|
|
'contact_number': contactNumber,
|
|
'flutter_ministore_token': flutterMiniStoreToken,
|
|
};
|
|
|
|
@override
|
|
String toString() {
|
|
return json.encode(this);
|
|
}
|
|
} |