• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

fluttercandies/FlutterJsonBeanFactory

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

fluttercandies/FlutterJsonBeanFactory

开源软件地址:

https://github.com/fluttercandies/FlutterJsonBeanFactory

开源编程语言:

Kotlin 100.0%

开源软件介绍:

FlutterJsonBeanFactory

Hi,Welcome to come to see me! What I do is generate dart beans based on json, as well as generics parameters and json build instances

Language: English | 中文(qq群963752388)

Easy Use

image

Known issue

  • If "No classes that inherit JsonConvert were found" is displayed, delete the ". Idea "directory under the project and click" invalidate Caches"in your (Andorid Studio or IDEA) button to restart the IDE
  • Two (and more)-dimensional array is not supported

Template ToDo list

  • Support for instantiation through generics
  • Support customized JSON parsing
  • The supported types are: int double String datetime dynamic var, and List of the above types
  • Two (and more)-dimensional array is not supported

Usage

  • Settings/Preferences > Plugins > Marketplace > Search for "FlutterJsonBeanFactory" > Install Plugin
  • Restart your Develop tools
  • Modify in the YAML file of the Flutter project

before:

environment:
  sdk: ">=2.12.0 <3.0.0"

after modification:

environment:
  sdk: ">=2.15.0 <3.0.0"
  • Press shortcut key alt + j for mac , right click on package -> New->Dart bean clas file from JSON And Then you will know how to use
  • If you change the fields in the class, just press the shortcut alt + j to regenerate the tojson and fromjson methods. The generated method regenerates all helper classes and JsonConvert classes (the same as the shortcut alt + j) each time an entity file is created in the generated/json directory.
  • If you need generic conversions in your network requests, use the JsonConvert.fromJsonAsT method directly.
  • If no helper files are generated, you can delete the .idea directory and restart your idea
  • You can customize the JSON parsing scheme
import 'generated/json/base/json_convert_content.dart';

class MyJsonConvert extends JsonConvert {
  T? asT<T extends Object?>(dynamic value) {
    try {
      String type = T.toString();
      if (type == "DateTime") {
        return DateFormat("dd.MM.yyyy").parse(value) as T;
      }else{
        return super.asT<T>(value);
      }
    } catch (e, stackTrace) {
      print('asT<$T> $e $stackTrace');
      return null;
    }
  }
}

Future<void> main() async {
  jsonConvert = MyJsonConvert();
  runApp(Text("OK"));
}

Find me useful ? ❤️

  • Support me by clicking the button on the upper right of this page. ✌️
  • Spread to others to let more people have a better develope expierience ❤️

Thanks to JetBrains for allocating free open-source licenses for IDEs such as IntelliJ IDEA.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap