flutter_in_action_2nd icon indicating copy to clipboard operation
flutter_in_action_2nd copied to clipboard

第15章的一些建议

Open mjiee opened this issue 3 years ago • 1 comments

1、建议将 pubspec.yaml 文件中的依赖项配置贴出 2、代码块中建议不要将import语句省略 3、15.3小节中 “生成Dart Model类” 小节的 “flutter packages pub run json_model” 无法生成Dart Model类

$ flutter pub run json_model Unhandled exception: FileSystemException: Directory listing failed, path = './Jsons/' (OS Error: No such file or directory, errno = 2) #0 _Directory._fillWithDirectoryListing (dart:io-patch/directory_patch.dart:42:24) #1 _Directory.listSync (dart:io/directory_impl.dart:243:5) #2 generateModelClass (file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/json_model-1.0.0/bin/json_model.dart:62:24) #3 main (file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/json_model-1.0.0/bin/json_model.dart:46:14) #4 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:295:32) #5 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12) pub finished with exit code 255

我的 pubspec.yaml 依赖配置如下 dependencies: flutter: sdk: flutter cupertino_icons: ^1.0.2 json_annotation: ^4.4.0 dio: ^4.0.6

dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^1.0.0 build_runner: ^2.1.8 json_serializable: ^6.1.5 json_model: ^1.0.

我运行:flutter pub run json_model src=jsons dist=lib/models 也无法解决问题 将根目录下的 jsons目录 修改为 Jsons 方可生成Model文件

mjiee avatar Apr 06 '22 12:04 mjiee

第15章这么重要,整个逻辑框架很好,结果代码小问题挺多。

zhurizhao avatar Mar 15 '23 08:03 zhurizhao