我想创建一个嵌套对象作为请求发送给 api。非常感谢您的帮助。
下面是嵌套的内置值类
abstract class BuiltUpdateProfileRequest
implements
Built<BuiltUpdateProfileRequest, BuiltUpdateProfileRequestBuilder> {
// fields go here
String get firstName;
String get lastName;
String get phoneNumber;
@nullable
ProfileBilling get billing;
BuiltUpdateProfileRequest._();
factory BuiltUpdateProfileRequest(
[updates(BuiltUpdateProfileRequestBuilder b)]) =
_$BuiltUpdateProfileRequest;
static Serializer<BuiltUpdateProfileRequest> get serializer =>
_$builtUpdateProfileRequestSerializer;
}
abstract class ProfileBilling
implements Built<ProfileBilling, ProfileBillingBuilder> {
// fields go here
@nullable
String get address1;
@nullable
String get address2;
@nullable
String get city;
@nullable
String get state;
@nullable
String get country;
@nullable
String get zip;
ProfileBilling._();
factory ProfileBilling([updates(ProfileBillingBuilder b)]) = _$ProfileBilling;
static Serializer<ProfileBilling> get serializer =>
_$profileBillingSerializer;
}
下面是请求对象,但它在电话号码下的计费时引发错误,说明不能将配置文件计费类型的值分配给 ProfileBillingBuilder 类型的变量。
final ProfileBilling profileBilling = ProfileBilling((b) => b
..address1 = ""
..address2 = ""
..city = ""
..state = ""
..country = ""
..zip = "");
final BuiltUpdateProfileRequest builtUpdateProfileRequest =
BuiltUpdateProfileRequest((b) => b
..firstName = firstName
..lastName = lastName
..phoneNumber = phoneNo
..billing = profileBilling);