Android 工作室一直告诉我工厂 class 需要 body,有什么问题吗?
Android studio keeps telling me that the factory class needs a body, what could be wrong?
class WallpaperModel{
late String photographer;
late String photographer_url;
late int photographer_id;
SrcModel src;
WallpaperModel({ required this.src, required this.photographer_url,required this.photographer_id, required this.photographer})
factory WallpaperModel.fromMap(Map<String,dynamic> jsonData){
return WallpaperModel(src: jsonData['src'],
photographer_url: jsonData['photographer_url'],
photographer_id: jsonData['photographer_id'],
photographer: jsonData['photographer']);
}
}
我正在尝试将 Pexels API 实施到壁纸应用程序中,但 Android 工作室将工厂 class 标记为需要 body 的错误。可能出了什么问题?
问题是此行缺少分号 ;
。
WallpaperModel({ required this.src, required this.photographer_url,required this.photographer_id, required this.photographer});
class WallpaperModel{
late String photographer;
late String photographer_url;
late int photographer_id;
SrcModel src;
WallpaperModel({ required this.src, required this.photographer_url,required this.photographer_id, required this.photographer})
factory WallpaperModel.fromMap(Map<String,dynamic> jsonData){
return WallpaperModel(src: jsonData['src'],
photographer_url: jsonData['photographer_url'],
photographer_id: jsonData['photographer_id'],
photographer: jsonData['photographer']);
}
}
我正在尝试将 Pexels API 实施到壁纸应用程序中,但 Android 工作室将工厂 class 标记为需要 body 的错误。可能出了什么问题?
问题是此行缺少分号 ;
。
WallpaperModel({ required this.src, required this.photographer_url,required this.photographer_id, required this.photographer});