Coder Social home page Coder Social logo

flutterjsonbeanfactory's Introduction

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

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
  • 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.

flutterjsonbeanfactory's People

Contributors

kkkkkkkkkkkkkkeee avatar kvii avatar wangyng avatar zhangruiyu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.