简体   繁体   English

Flutter:发布结束,退出代码为 255

[英]Flutter: pub finished with exit code 255

I am making models for my flutter application via build runner,json model and json serializable.我正在通过构建运行器为我的 flutter 应用程序制作模型,json model 和 json 可序列化。 But i got this error但我得到了这个错误

Unhandled exception:
RangeError (index): Invalid value: Valid value range is empty: 0
#0      _StringBase.[] (dart:core-patch/string_patch.dart:247:55)
#1      changeFirstChar (file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/json_model-0.0.2/bin/json_model.dart:89:41)
#2      getType (file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/json_model-0.0.2/bin/json_model.dart:116:20)
#3      walk.<anonymous closure>.<anonymous closure> (file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/json_model-0.0.2/bin/json_model.dart:62:23)
#4      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
#5      walk.<anonymous closure> (file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/json_model-0.0.2/bin/json_model.dart:50:37)
#6      List.forEach (dart:core-patch/growable_array.dart:282:8)
#7      walk (file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/json_model-0.0.2/bin/json_model.dart:38:8)
#8      main (file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/json_model-0.0.2/bin/json_model.dart:18:6)
#9      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#10     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
pub finished with exit code 255

In my pubspec.yaml file i added these flutter packages in dev dependencies:在我的 pubspec.yaml 文件中,我在开发依赖项中添加了这些 flutter 包:

dev_dependencies:
  flutter_test:
    sdk: flutter
  json_model: ^0.0.2
  json_serializable:
  build_runner:

My Json files for which i want to make models:我要为其制作模型的 Json 文件:

1st json file第一个 json 文件

{
  "id": 1,
  "country": "Australia",
  "currencySymbol": "$"
}

2nd Json file第二个 Json 文件

{
  "currencylist": "$[]currency"
}

Can you please help me where i am doing wrong in this and why i am getting this error when i run command in terminal flutter packages pub run json_model .你能帮我看看我在这方面做错了什么吗?为什么当我在终端flutter packages pub run json_model中运行命令时出现这个错误。

this is too late but someone might get use of it, this worked for me:这为时已晚,但有人可能会使用它,这对我有用:

I think this might happen when you change something in your model and you run agin我认为当您更改模型中的某些内容并运行 agin 时,可能会发生这种情况

flutter pub run build_runner build

update:更新:

run this and it will do the job for you:运行它,它会为你完成这项工作:

flutter pub run build_runner build  --delete-conflicting-outputs 

old : so first try to delete all generated files that ends with old : 所以首先尝试删除所有以

XXX.g.dart XXX.g.dart

and run并运行

flutter clean 

then然后

flutter pub get

Finally最后

flutter pub run build_runner build

Check your pubspec.yaml file.检查您的 pubspec.yaml 文件。

dependencies:依赖:

  json_annotation: ^2.0.0

dev_dependencies: dev_dependencies:

  json_model: //it is required to add for your error
  build_runner: ^1.0.0
  json_serializable: ^2.0.0

You can simple run the你可以简单地运行

1.flutter clean.
2.flutter pub get.

This saves my several hours.这节省了我几个小时。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter flutter_launcher_icons 错误:发布完成,退出代码为 255 - Flutter flutter_launcher_icons error: pub finished with exit code 255 Flutter 构建运行器 - 发布完成,退出代码为 65 - Flutter build runner - pub finished with exit code 65 flutter pub 添加 google_sign_in 已完成,退出代码为 65 - flutter pub add google_sign_in finished with exit code 65 发布 package 时出错:发布完成,退出代码为 1 - Error in publishing package: pub finished with exit code 1 解决依赖关系:pub 以退出代码 1 结束 - Resolving dependencies: pub finished with exit code 1 试图做一个 flutter pub get 并完成了进程并退出代码 66 - Trying to do a flutter pub get and got Process finished with exit code 66 Flutter - iOS:命令/ bin / sh失败,退出代码为255 - Flutter - iOS: Command /bin/sh failed with exit code 255 未找到设置为参数“图像”的文件“assets/background.png”。 pub 完成退出代码 1 - The file "assets/background.png" set as the parameter "image" was not found. pub finished with exit code 1 Flutter 错误“以错误完成:Gradle 任务 assembleDebug 失败,退出代码 -1” - Flutter error “Finished with error: Gradle task assembleDebug failed with exit code -1” (Flutter) pub get failed chat 依赖于 charts_flutter &gt;=0.0.1+1 &lt;0.4.0 which requires SDK version &gt;=1.23.0 &lt;2.0.0 exit code 1 - (Flutter) pub get failed chat depends on charts_flutter >=0.0.1+1 <0.4.0 which requires SDK version >=1.23.0 <2.0.0 exit code 1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM