- 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.
66 lines
1.6 KiB
Dart
66 lines
1.6 KiB
Dart
|
|
import 'dart:convert';
|
|
|
|
import 'package:flutter_wisetronic/models/product_attribute.dart';
|
|
|
|
class Subproduct {
|
|
int? id;
|
|
SimpleProduct? product;
|
|
double? quantity;
|
|
|
|
Subproduct.fromJson(Map<String, dynamic> json) :
|
|
id = json['id'],
|
|
product = SimpleProduct.fromJson(json['product']),
|
|
quantity = double.parse(json['quantity'].toString());
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'product': product,
|
|
'quantity': quantity,
|
|
};
|
|
|
|
@override
|
|
String toString() {
|
|
return json.encode(this);
|
|
}
|
|
}
|
|
|
|
class SimpleProduct {
|
|
int? id;
|
|
String? name;
|
|
String? sku;
|
|
double? price;
|
|
String? description;
|
|
String? image;
|
|
List<ProductAttribute>? productAttributes;
|
|
double? customerLastPrice;
|
|
String? extraData;
|
|
|
|
SimpleProduct.fromJson(Map<String, dynamic> json) :
|
|
id = json['id'],
|
|
name = json['name'],
|
|
sku = json['sku'],
|
|
price = double.parse(json['price'].toString()),
|
|
description = json['description'],
|
|
image = json['image'],
|
|
productAttributes = (json['productattributes'] as List).map((i) => ProductAttribute.fromJson(i)).toList(),
|
|
customerLastPrice = double.parse(json['customer_last_price'].toString()),
|
|
extraData = json['extra_data'];
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'name': name,
|
|
'sku': sku,
|
|
'price': price,
|
|
'description': description,
|
|
'image': image,
|
|
'productattributes': productAttributes,
|
|
'customer_last_price': customerLastPrice,
|
|
'extra_data': extraData,
|
|
};
|
|
|
|
@override
|
|
String toString() {
|
|
return json.encode(this);
|
|
}
|
|
} |