英文:
Dart Data Class Generator is not working it is showing: item couldn't be converted to a data class: Class doesn't have unique property names
问题
Dart Data Class Generator不起作用,显示:无法将项目转换为数据类:类没有唯一的属性名称。
英文:
[[]3
Dart Data Class Generator is not working it is showing: item couldn't be converted to a data class: Class doesn't have unique property names
答案1
得分: 2
import 'dart:convert';
import 'model_exports.dart';
class FIDS_FlightUpdate {
GreatCircleDistance? greatCircleDistance ;
DepartingDepartureInfo? departure;
DepartingArrivalInfo? arrival;
String? lastUpdatedTimeUtc ; //Example:"2021-10-04 18:20Z"
String? number; //Example:"AF 3139"
String? callSign;
String? status; //Example:"Departed"
String? codeshareStatus; //example:"IsCodeshared"
bool? isCargo; //Example:false
FIDS_Aircraft? aircraft;
FIDS_Airline? airline;
}
Gives error message......
FIDS_FlightUpdate couldn't be converted to a data class: Class doesn't have unique property names!
I do not see any duplicate property names.
英文:
I am having the same issue (it used to work)..
import 'dart:convert';
import 'model_exports.dart';
class FIDS_FlightUpdate {
GreatCircleDistance? greatCircleDistance ;
DepartingDepartureInfo? departure;
DepartingArrivalInfo? arrival;
String? lastUpdatedTimeUtc ; //Example:"2021-10-04 18:20Z"
String? number; //Example:"AF 3139"
String? callSign;
String? status; //Example:"Departed"
String? codeshareStatus; //example:"IsCodeshared"
bool? isCargo; //Example:false
FIDS_Aircraft? aircraft;
FIDS_Airline? airline;
}
Gives error message......
FIDS_FlightUpdate couldn't be converted to a data class: Class doesn't have unique property names!
I do not see any duplicate property names.
答案2
得分: 0
在同一个dart文件中有两个模型。首先将它们分离到各自的dart文件中。
对于要使用生成器的每个模型,请确保在使用快捷键组合之前定义它们的属性:
Ctrl + Shift + P
然后键入Dart Data类生成器:从类属性生成,并按Enter键。
确保你没有重复的属性。
完成上述步骤后,它应该正常工作。但如果不行,请在此处发布更多关于错误的详细信息。
英文:
You have two models in the same dart file. Start by separating them into their respective dart files.
For each model u want to use the generator on, make sure you have defined their properties before applying the generator using short-cut key combination:
> Ctrl + Shift + P
and type Dart Data class Generator: Generate from class properties and strike enter key.
Make sure you don't have duplicate properties.
with the above done, it should work fine. However, if it doesn't, please post here with more details about the error.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论