flutter 型别'Null'不是型别'bool'的子型别

f45qwnt8  于 2022-12-14  发布在  Flutter
关注(0)|答案(1)|浏览(177)

我在测试应用程序时发现错误:

PS C:\Expert1\Tvseries-master> flutter test --coverage
02:28 +26 -1: loading C:\Expert1\Tvseries-master\test\data\datasources\televisi_remote_data\televisi_remote_data_source_test.dart [E]
  Failed to load "C:\Expert1\Tvseries-master\test\data\datasources\televisi_remote_data\televisi_remote_data_source_test.dart": type 'Null' is not a subtype of type 'bool'
  package:ditonton/data/models/televisi_model/televisi_detail_model.dart 50:20             new TelevisiDetailResponse.fromJson
  test\data\datasources\televisi_remote_data\televisi_remote_data_source_test.dart 118:52  main.<fn>  
  package:test_api                                                                         Declarer.group
  package:flutter_test/src/test_compat.dart 189:13                                         group      
  test\data\datasources\televisi_remote_data\televisi_remote_data_source_test.dart 116:3   main

错误的原因是什么?如何修复?

epggiuax

epggiuax1#

在此文件package:ditonton/data/models/televisi_model/televisi_detail_model.dart 50:20 new TelevisiDetailResponse.fromJson中,某个字段需要布尔值,但收到的是空值。您可以通过使布尔字段可为空来修复此问题。示例:bool? isWorking;

相关问题