JsonToDartRelated articles

  • Flutter’s most versatile JsonToDart tool (Desktop Web Sea, Land and Air support)
  • Flutter JsonToDart LEI for Mac is not really mark
  • Flutter JsonToDart tools

A C# version of JsonToDart was made earlier, supporting Windows and the Web. Many people ask why there is no Mac version. In fact, when making the C# version, we considered using Flutter to implement Flutter -desktop and Flutter -web. But given the technology I am familiar with and the fact that flutter-desktop and Flutter – Web are just guinea pigs right now, it is not a priority. After r completing the C# version, it took some time to convert to the Dart version, which opened up the way to fill holes in flutter-desktop and flutter-web.

Pit related things

  • flutter
  • flutter-desktop
  • flutter-web
  • go-flutter

In fact, recently we found that a lot of big guys have fallen into the trap, Flutter -desktop and Flutter -web. Before, we only saw what big guys said, but didn’t do it ourselves.

I am a MAC nerd and don’t know anything about configuration, so I read the Sinking Guide to The Humble Big Guy, from configuring the environment to discarding, the Flutter Desktop MAC version and the Flutter Web Review. This is a walkthrough by the Humble Big guy, just follow the steps.

pit

  • There is no packaging method for flutter-desktop, all are debug versions, so there will be yellow overflow warning (who knows how to disable this warning, please let me know, thanks)

  • The output of the Flutter -desktop MAC is unknown, maybe because I don’t know enough. Windows is EXE, Microsoft fans easy to find.

  • The Flutter -desktop does not support shortcut keys, such as Ctrl+C,Ctrl+V. Later only the Go-Flutter packaging can solve this problem. How do I pack with go-Flutter

  • The flutter-web works fine locally, the packaged release page displays incorrectly. When packing on Windows, note that webdev build is executed in CMD /PowerShell. Don’t use Git like I did and the command can’t be found

  • flutter-desktop

There is no complete life cycle for flutter-web, so THERE is no way to know when the application will be closed, so I added a save configuration button (it feels bad to save all the time, especially with the input box)

At first blush, it feels like flutter-desktop and Flutter – Web are really just guinea pigs, but the MAC version of Go-Flutter is good enough to use.

JsonToDart guide

Dart is the most comprehensive Json conversion tool available for Windows, Mac, Web, and Linux.

Related:

  • uwp
  • wpf
  • silverlight
  • flutter
  • flutter-desktop
  • flutter-web
  • go-flutter
  • go
  • hover

Flutter Candies QQ Group 181398081

  • download
  • The installation
    • UWP(Windows10)
    • WPF(Windows7/Windows8)
    • Silverlight(Web)
    • Flutter(Mac)
    • Flutter(Windows_x64)
  • use
    • formatting
    • More Settings
      • Full data type protection
      • Array omnidirectional protection
      • Number of times to traverse a number of groups
      • Attribute name
      • Attributes sorting
      • Adding a Protection Method
      • File header information
      • Property accessor type
    • Modify the JSON information
    • Generate the Dart

download

Github download speed is too slow, in order to facilitate everyone to download, specially created in Gitee download address.

UWP Microsoft Store

WPF for Windows

UWP for Windows10

Flutter for Macos

Flutter for Web

platform language describe Code/installation package address
windows C# Uwp built, running environment Windows10, x86/ X64 windows-uwp.zip
windows C# WPF build, runtime environment Windows 10 / Windows/widnows7, x86 / x64 windows-wpf.zip
windows dart Flutter construction, useThe official wayBuild, X64,debug version windows-x64-flutter.zip
windows dart Flutter construction, usego-flutterBuild, X64,debug version windows-x64-go-flutter.zip
mac dart Flutter construction, usego-flutterCompile (official, no product found) mac-go-flutter.zip
web C# silverlightBuild, requires installation of silverlight plug-in, browser restrictions The web addressandWeb page address with font file
web dart flutter-webbuild The web address
linux dart Flutter build, compiled using official method (no environment tests, pretend to work) The code address

The installation

UWP(Windows10)

Windows 10 users

Considering that app stores often have their periods, they don’t upload to the store.

Download the installation package and unzip it.

For the first installation, you need to install the certificate. Please use PowerShell to open Add-AppDevPackage.ps1 as shown below

If the tool is updated later, download the latest one and click on FluttercandiesjsonToDART_x.0.x.0_x86_x64. appXBundle to install it

WPF(Windows7/Windows8)

Windows 7 / Windows users

Download and unzip and click Setup.exe to install

Silverlight(Web)

There may be garbled characters in the font file. Due to the Chinese font problem, the Chinese font file is included. It will take a long time for the first time, please be patient

First you need to install Silverlight

Mac users download Mac, Windows users download Windows

Then there is the browser issue, because Silverlight is supported by a limited number of browsers, and in addition to Internet Explorer, the following versions are also supported.

Mac Safari under 12.0 can try this

Mac Firefox this version can be used

Flutter(Mac)

The product of go-flutter is a binary program, run as exec, which can be opened by double clicking, and then packaged with DMG by the big guy. Install the package. For details about how to package the Go Flutter Desktop, see the Go binary package for MAC App (DMG).

Flutter(Windows_x64)

If the official flutter product or go-flutter product is exe, click exe to start the flutter

use

On the left is the JSON input box and the resulting Dart code, and on the right is the structure of the generated JSON class

formatting

Click the format button to convert the JSON to the json class structure visualized on the right

More Settings

All Settings are automatically saved (except for the FLUTTER version, which needs to be manually saved)

Full data type protection

There must be times when you are stuck on the server side, right? Json parsing fails because the specified data type is not passed.

Turning this switch on adds a layer of protection when retrieving data, as shown below

T asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }
  if(value ! =null) {
    final String valueS = value.toString();
    if (0 is T) {
      return int.tryParse(valueS) as T;
    } else if (0.0 is T) {
      return double.tryParse(valueS) as T;
    } else if (' ' is T) {
      return valueS as T;
    } else if (false is T) {
      if (valueS == '0' || valueS == '1') {
        return (valueS == '1') as T;
      }
      return bool.fromEnvironment(value.toString()) asT; }}return null;
}
Copy the code

Array omnidirectional protection

Have you ever been in a situation where one error caused the entire parsing of json to fail while looping through an array?

Turning this switch on protects each loop parse, as shown below

void tryCatch(Function f) {
  try{ f? .call(); }catch (e, stack) {
    debugPrint("$e");
    debugPrint("$stack"); }}Copy the code

Number of times to traverse a number of groups

In the data returned by the server, sometimes not every item in the array has all the attributes,

If only the first one is checked, the attribute is lost

You can avoid losing attributes by looping multiple times

The choices are 1,20,99

99 means the loop is all checked

Attribute name

Attribute naming convention options: Leave it as is, camel name small camel, PASCAL name big camel, Hungarian name underline

Dart naming convention

Dart officially recommends hump naming for small humps

Attributes sorting

Sort attributes

Sorting options: Keep as is, sort in ascending order, sort in descending order

Adding a Protection Method

Whether to add a protection method. Data type omni-protection/Array omni-protection both generate methods when enabled. You can turn them on the first time you use them, you can pop them out, and you don’t have to include them in every file to generate Dart.

File header information

You can add copyright, improt Dart, creator information, etc., to this function. You can use [Date YYYY MM-DD] to generate the time.

For example, [Date YYYY MM-DD] will generate the time when you generated the Dart code in YYYY MM-DD format

Property accessor type

After hitting Format, a visual JSON class structure is displayed on the right, and property accessor type Settings are displayed in the right column

Options: default, Final, Get, GetSet

The top Settings are changed, and the subitems are changed. You can also set individual properties.

Modify the JSON information

After hitting Format, the right side displays a visual JSON class structure.

The first column is the corresponding key in JSON

The second column is the name of the attribute type/class. If it is a class name, it is indicated with a yellow background

The third column is the name of the attribute

If the input option is empty, a red prompt is displayed

Generate the Dart

After you’ve set it up, click the Generate Dart button, and the Dart code you want will be generated on the left, with the message “Dart generated successfully, copied to clipboard”, ready to be copied directly to your Dart file

Welcome Start, Fork, 666.

Finally put onJosn To DartPlease let me know if there is anything you don’t understand or how to improve the program. Welcome to join usFlutter CandiesTogether to make cute little Flutter candiesQQ group: 181398081

Once again, let’s invite those who are willing to contribute to the ecology of Flutter to join Flutter Candies and have fun writing bugs with Flutter Candies.

And finally, put Flutter Candies on it. It smells sweet.