Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flutter运行命令后报错:RangeError: Value not in range: -1 #45

Open
ZainCheung opened this issue Apr 24, 2021 · 8 comments
Open

flutter运行命令后报错:RangeError: Value not in range: -1 #45

ZainCheung opened this issue Apr 24, 2021 · 8 comments

Comments

@ZainCheung
Copy link

Unhandled exception:
RangeError: Value not in range: -1
#0 _StringBase.substring (dart:core-patch/string_patch.dart:399:7)
#1 _parsePackageLocations (package:build_runner_core/src/package_graph/package_graph.dart:162:21)
#2 new PackageGraph.forPath (package:build_runner_core/src/package_graph/package_graph.dart:67:30)
#3 new PackageGraph.forThisPackage (package:build_runner_core/src/package_graph/package_graph.dart:98:57)
#4 new BuildCommandRunner (package:build_runner/src/entrypoint/runner.dart:27:37)
#5 run (file:///D:/A%20Program%20Files/flutter/.pub-cache/hosted/pub.flutter-io.cn/json_model-0.0.2/bin/build_runner.dart:25:23)#6 main (file:///D:/A%20Program%20Files/flutter/.pub-cache/hosted/pub.flutter-io.cn/json_model-0.0.2/bin/json_model.dart:19:5)
#7 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:281:32)
#8 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
pub finished with exit code 255

@KevinnZou
Copy link

我也遇到了同样的问题,你是windows吗?

@ZainCheung
Copy link
Author

我也遇到了同样的问题,你是windows吗?

是的

@duyu648780240
Copy link

我也遇到了同样的问题,你是windows吗?

是的

我在mac上也遇到这个问题,请问解决了吗

@ZainCheung
Copy link
Author

@KevinnZou @duyu648780240 我放弃了用命令自动生成,然后copy了一份官方给的案例文件:https://github.com/flutterchina/json_model/blob/master/example/lib/models/user.dart
以及.g.dart文件
https://github.com/flutterchina/json_model/blob/master/example/lib/models/user.g.dart
然后根据自己的需求改就好了

@NicolasHuangDF
Copy link

我也遇到了,而且连报错的每一个条目都一模一样,我怀疑是flutter sdk的问题

@Yechuanjie
Copy link

image
同样的问题,但是能生成对应dart model,不过生成的文件缺少xxx.g.dart

@Yechuanjie
Copy link

可以使用pub上的 json_to_model

@my-petrichor
Copy link

我也是 RangeError: Value not in range: -1 的问题,mac 电脑
@Yechuanjie 非常感谢,json_to_model 解决了我的问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants