【问题标题】:Android studio keeps telling me that the factory class needs a body, what could be wrong?Android Studio 一直告诉我工厂类需要一个主体,有什么问题吗?
【发布时间】:2021-12-13 11:27:55
【问题描述】:
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 Studio 将工厂类标记为需要主体的错误。可能出了什么问题?

【问题讨论】:

    标签: flutter api android-studio dart factory


    【解决方案1】:

    问题是这一行缺少分号;

      WallpaperModel({ required this.src, required this.photographer_url,required this.photographer_id, required this.photographer});
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-16
      • 1970-01-01
      • 1970-01-01
      • 2023-01-14
      • 1970-01-01
      • 2022-11-07
      • 2018-06-30
      • 2015-07-09
      相关资源
      最近更新 更多