fluttercandies / FlutterJsonBeanFactory

What I do is generate dart beans based on json, as well as generics parameters and json build instances
Apache License 2.0
565 stars 56 forks source link

[Bug report] #137

Closed islinjj closed 1 year ago

islinjj commented 1 year ago

Version

4.5.2

Platforms

dart, Android, iOS

Device Model

all device

flutter info

[✓] Flutter (Channel stable, 3.10.2, on macOS 13.3.1 22E772610a darwin-x64, locale zh-Hans-CN)
    • Flutter version 3.10.2 on channel stable at /Users/linvi7/project/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9cd3d0d9ff (7 days ago), 2023-05-23 20:57:28 -0700
    • Engine revision 90fa3ae28f
    • Dart version 3.0.2
    • DevTools version 2.23.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/linvi7/Library/Android/sdk
    • Platform android-33, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio 2.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio 2.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.1.4)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 44.0.1
    • Dart plugin version 191.8593

[✓] VS Code (version 1.77.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • iPhone 14 Pro Max (mobile) • C063CAE9-DEAA-486A-A8DC-4D8132C42B5E • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)            • macos                                • darwin-x64     • macOS 13.3.1 22E772610a darwin-x64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 113.0.5672.126

[✓] Network resources
    • All expected network resources are available.

How to reproduce?

when I build FlutterBeanFactory and generated document, and then it throw some error logs after I run the project.

I try to restart my pc, upgrade Android Studio, but it doesn't work.

Logs

lib/generated/json/base/json_convert_content.dart:26:51: Error: Member not found: 'fromJson'.
        (GetRequestEntity).toString(): GetRequestEntity.fromJson,
                                                        ^^^^^^^^
lib/generated/json/base/json_convert_content.dart:27:53: Error: Member not found: 'fromJson'.
        (PostRequestEntity).toString(): PostRequestEntity.fromJson,
                                                          ^^^^^^^^
lib/generated/json/base/json_convert_content.dart:28:53: Error: Member not found: 'fromJson'.
        (GetResponseEntity).toString(): GetResponseEntity.fromJson,
                                                          ^^^^^^^^
lib/generated/json/base/json_convert_content.dart:29:55: Error: Member not found: 'fromJson'.
        (PostResponseEntity).toString(): PostResponseEntity.fromJson,

Example code (optional)

@JsonSerializable()
class GetRequestEntity {

    GetRequestEntity();

    factory GetRequestEntity.fromJson(Map<String, dynamic> json) => $GetRequestEntityFromJson(json);
    String? getNumber;
    String? getName;

    Map<String, dynamic> toJson() => $GetRequestEntityToJson(this);

}

@JsonSerializable()
class PostRequestEntity {

    PostRequestEntity();

    factory PostRequestEntity.fromJson(Map<String, dynamic> json) => $PostRequestEntityFromJson(json);
    String? postNumber;
    String? postName;

    Map<String, dynamic> toJson() => $PostRequestEntityToJson(this);
}

...

class JsonConvert {
    static final Map<String, JsonConvertFunction> convertFuncMap = {
        (GetRequestEntity).toString(): GetRequestEntity.fromJson,
        (PostRequestEntity).toString(): PostRequestEntity.fromJson,
        (GetResponseEntity).toString(): GetResponseEntity.fromJson,
        (PostResponseEntity).toString(): PostResponseEntity.fromJson,
    };

......

}

Contact

No response

zhangruiyu commented 1 year ago

Screenshot_20230531_093304_com.github.android.png

islinjj commented 1 year ago

Thanks