flutter build runner 不工作 - getter 'uri' 被调用为 null [英] flutter build runner not working - The getter 'uri' was called on null
本文介绍了flutter build runner 不工作 - getter 'uri' 被调用为 null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我完美地将 flutter 与 build runner 一起使用,但今天它只是收到此 null 错误.甚至以为我恢复了我的代码更改,但仍然是同样的错误.
错误:
>[SEVERE] json_serializable:json_serializable on test/widget_test.dart:>NoSuchMethodError: getter 'uri' 在 null 上被调用.>接收者:空>尝试调用:uri>[INFO] 3.3 秒过去,1/17 动作完成.>[INFO] 4.4 秒过去,1/17 动作完成.>[INFO] 5.4 秒过去,1/17 动作完成.>[INFO] 6.4 秒过去,1/17 动作完成.>[INFO] 7.5 秒过去,1/17 动作完成.>[INFO] 8.5 秒过去,1/17 动作完成.>[INFO] 9.6 秒过去,1/17 动作完成.>[INFO] 10.7 秒过去,1/17 动作完成.>[INFO] 11.8 秒过去,1/17 动作完成.>[INFO] 12.9 秒过去,1/17 动作完成.>[INFO] 14.0 秒过去,1/17 动作完成.>[INFO] 15.0 秒过去,1/17 动作完成.>[INFO] 16.1 秒过去,1/17 动作完成.>[INFO] 17.1 秒过去,1/17 动作完成.>[警告] 15.1 秒内未完成任何操作,等待:>json_serializable:json_serializable 在 lib/common_widgets/alert_screens.dart>json_serializable:json_serializable 在 lib/common_widgets/app_logo.dart 上>json_serializable:json_serializable 在 lib/common_widgets/app_tab_bar.dart 上>json_serializable:json_serializable 在 lib/common_widgets/buttons_widgets.dart>json_serializable:json_serializable 在 lib/common_widgets/cards.dart 上>.. 还有 11 个>[INFO] 18.2 秒过去,1/17 动作完成.>[信息] 19.3 秒过去了,1/17 操作已完成.
而且一直这样.
我正在使用:
sdk:>=2.7.0 <3.0.0";颤动:^1.22.0build_runner: ^1.10.0json_serializable: ^3.5.0分析器:^0.41.1
我试图生成的模型:
<预><代码>导入 'package:flutter/foundation.dart';导入'包:json_annotation/json_annotation.dart';诊所.g.dart"部分;@JsonSerializable()班级诊所{最终成立年;最终字符串工作时间;最终字符串电话号码;最终字符串位置;诊所({@required this.establishmentYear,@required this.workingHours,@required this.phoneNumber,@required this.location,});factory Clinic.fromJson(Map解决方案
更新到最新的flutter版本解决了这个问题
I was using flutter with build runner perfectly , but today it just getting this null error . Even thought I reverted my code changes but still the same error .
the error :
>[SEVERE] json_serializable:json_serializable on test/widget_test.dart:
>NoSuchMethodError: The getter 'uri' was called on null.
>Receiver: null
>Tried calling: uri
>[INFO] 3.3s elapsed, 1/17 actions completed.
>[INFO] 4.4s elapsed, 1/17 actions completed.
>[INFO] 5.4s elapsed, 1/17 actions completed.
>[INFO] 6.4s elapsed, 1/17 actions completed.
>[INFO] 7.5s elapsed, 1/17 actions completed.
>[INFO] 8.5s elapsed, 1/17 actions completed.
>[INFO] 9.6s elapsed, 1/17 actions completed.
>[INFO] 10.7s elapsed, 1/17 actions completed.
>[INFO] 11.8s elapsed, 1/17 actions completed.
>[INFO] 12.9s elapsed, 1/17 actions completed.
>[INFO] 14.0s elapsed, 1/17 actions completed.
>[INFO] 15.0s elapsed, 1/17 actions completed.
>[INFO] 16.1s elapsed, 1/17 actions completed.
>[INFO] 17.1s elapsed, 1/17 actions completed.
>[WARNING] No actions completed for 15.1s, waiting on:
> json_serializable:json_serializable on lib/common_widgets/alert_screens.dart
> json_serializable:json_serializable on lib/common_widgets/app_logo.dart
> json_serializable:json_serializable on lib/common_widgets/app_tab_bar.dart
> json_serializable:json_serializable on lib/common_widgets/buttons_widgets.dart
> json_serializable:json_serializable on lib/common_widgets/cards.dart
> .. and 11 more
> [INFO] 18.2s elapsed, 1/17 actions completed.
> [INFO] 19.3s elapsed, 1/17 actions completed.
and it keeps going on like that .
I am using :
sdk: ">=2.7.0 <3.0.0"
flutter: ^1.22.0
build_runner: ^1.10.0
json_serializable: ^3.5.0
analyzer: ^0.41.1
the model I am trying to generate :
import 'package:flutter/foundation.dart';
import 'package:json_annotation/json_annotation.dart';
part 'clinic.g.dart';
@JsonSerializable()
class Clinic {
final int establishmentYear;
final String workingHours;
final String phoneNumber;
final String location;
Clinic({
@required this.establishmentYear,
@required this.workingHours,
@required this.phoneNumber,
@required this.location,
});
factory Clinic.fromJson(Map<String, dynamic> json) => _$ClinicFromJson(json);
Map<String, dynamic> toJson() => _$ClinicToJson(this);
}
解决方案
Updating to latest flutter version solved the issue
这篇关于flutter build runner 不工作 - getter 'uri' 被调用为 null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文