application: json["application"]!=null?Application.fromJson(json["application"]):null,…
- User
application: json["application"]!=null?Application.fromJson(json["application"]):null, when try to add null checker as mendtioned editor gives The argument type 'Application?' can't be assigned to the parameter type 'Application
- Assistant
The error you're encountering is because the
Application.fromJsonmethod is likely returning a non-nullable type (Application), while you’re trying to assign it to a nullable context. In Dart, if a method is expected to return a non-nullable type, it cannot be assigned to a variable that can be null (). - User
class Application { String id; String name; String token; String identifierType; String identifierValue; String customerContextId; bool deactivated; String defaultLocale; List allowedLocales; String defaultCurrency; List allowedCurrencies; Attributes attributes; List isolatedCatalogs; ContextState contextState; bool marketplace;
Application({ required this.id, required this.name, required this.token, required this.identifierType, required this.identifierValue, required this.customerContextId, required this.deactivated, required this.defaultLocale, required this.allowedLocales, required this.defaultCurrency, required this.allowedCurrencies, required this.attributes, required this.isolatedCatalogs, required this.contextState, required this.marketplace, });
factory Application.fromJson(Map<String, dynamic> json) => Application( id: json["id"], name: json["name"], token: json["token"], identifierType: json["identifierType"], identifierValue: json["identifierValue"], customerContextId: json["customerContextId"], deactivated: json["deactivated"], defaultLocale: json["defaultLocale"], allowedLocales: List.from(json["allowedLocales"].map((x) => x)), defaultCurrency: json["defaultCurrency"], allowedCurrencies: List.from(json["allowedCurrencies"].map((x) => x)), attributes: Attributes.fromJson(json["attributes"]), isolatedCatalogs: List.from( json["isolatedCatalogs"].map((x) => IsolatedCatalog.fromJson(x))), contextState: ContextState.fromJson(json["contextState"]), marketplace: json["marketplace"], );
- Assistant