精华 get-cli生成模型类的时候报错提示Null check operator used on a null value

98a37b36ebae3e3396f4a9cb2a38b28.png get-cli生成模型类的时候报错提示Null check operator used on a null value,错误代码如下

get generate model on models from "https://miapp.itying.com/api/bestCate"
无法自动设置model名称,你想用什么名称? category
Unhandled exception:
Null check operator used on a null value
#0      PubspecUtils.nullSafeSupport (package:get_cli/common/utils/pubspec/pubspec_utils.dart:146:76)
#1      new TypeDefinition (package:get_cli/common/utils/json_serialize/sintaxe.dart:81:22)
#2      new TypeDefinition.fromDynamic (package:get_cli/common/utils/json_serialize/sintaxe.dart:65:14)
#3      ModelGenerator._generateClassDefinition (package:get_cli/common/utils/json_serialize/model_generator.dart:68:36)
#4      ModelGenerator.generateUnsafeDart (package:get_cli/common/utils/json_serialize/model_generator.dart:148:9)
#5      ModelGenerator.generateDartClasses (package:get_cli/common/utils/json_serialize/model_generator.dart:181:28)
#6      GenerateModelCommand.execute (package:get_cli/commands/impl/generate/model/model.dart:41:35)
<asynchronous suspension>
#7      main.<anonymous closure> (file:///D:/FlutterCache/hosted/pub.flutter-io.cn/get_cli-1.9.1/bin/get.dart:18:38)
<asynchronous suspension>
#8      main (file:///D:/FlutterCache/hosted/pub.flutter-io.cn/get_cli-1.9.1/bin/get.dart:18:9)
<asynchronous suspension>
无法自动设置model名称,你想用什么名称? category
Unhandled exception:
Null check operator used on a null value
#0      PubspecUtils.nullSafeSupport (package:get_cli/common/utils/pubspec/pubspec_utils.dart:146:76)
#1      new TypeDefinition (package:get_cli/common/utils/json_serialize/sintaxe.dart:81:22)
#2      new TypeDefinition.fromDynamic (package:get_cli/common/utils/json_serialize/sintaxe.dart:65:14)
#3      ModelGenerator._generateClassDefinition (package:get_cli/common/utils/json_serialize/model_generator.dart:68:36)
#4      ModelGenerator.generateUnsafeDart (package:get_cli/common/utils/json_serialize/model_generator.dart:148:9)
#5      ModelGenerator.generateDartClasses (package:get_cli/common/utils/json_serialize/model_generator.dart:181:28)
#6      GenerateModelCommand.execute (package:get_cli/commands/impl

解决方案

1、使用在线网址生成模型类,参考:https://bbs.itying.com/topic/5d22b027fb714f06a4b0188c 2、使用下面命令安装getx

dart pub global deactivate get_cli

dart pub global activate -s git https://github.com/knottx/get_cli.git --git-ref fix-generate-model

详情也可以参考https://github.com/jonataslaw/get_cli/pull/283


1 回复

get-cli生成模型类的时候报错提示Null check operator used on a null value 使用下面方法【可用

dart pub global deactivate get_cli

dart pub global activate -s git https://github.com/knottx/get_cli.git --git-ref fix-generate-model
回到顶部