diff --git a/jsonexample/.gitignore b/jsonexample/.gitignore new file mode 100644 index 000000000..0fe1a7c4e --- /dev/null +++ b/jsonexample/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +.dart_tool/ +.packages +.pub/ +.idea +.atom +.flutter-plugins +build/ +*.iml diff --git a/jsonexample/.metadata b/jsonexample/.metadata new file mode 100644 index 000000000..8cab361b1 --- /dev/null +++ b/jsonexample/.metadata @@ -0,0 +1,8 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 44b7e7d3f42f050a79712daab253af06e9daf530 + channel: beta diff --git a/jsonexample/README.md b/jsonexample/README.md new file mode 100644 index 000000000..98bddae37 --- /dev/null +++ b/jsonexample/README.md @@ -0,0 +1,44 @@ +# jsonexample + +A Flutter sample app that deserializes a set of JSON strings using three +different libraries: `dart:convert`, `json_serializable`, and +`built_value`. + +## Goals for this sample + +* Help you decide which of the three most common libraries for + deserializing JSON is right for your project. +* Provide you with example code for deserializing: + * Simple and nested objects + * Lists of primitive values + * Maps containing primitive values + +## The important bits + +### `json_strings.dart` + +The actual JSON to be deserialized. + +### `dart_convert`/`json_serializable`/`dart_convert` + +These folders contain code used to deserialize the simple and complex +object models using one of the three libraries. They do the work of +instantiating models and populating their fields. + +### `tab_pages.dart` + +Each tab page in the app deserializes one type of data with one library. +These Widgets show what app code using the above libraries might look like. + +## Questions/issues + +If you have a general question about JSON serialization in Flutter, the +best places to go are: + +* [The FlutterDev Google Group](https://groups.google.com/forum/#!forum/flutter-dev) +* [The Flutter Gitter channel](https://gitter.im/flutter/flutter) +* [StackOverflow](https://stackoverflow.com/questions/tagged/flutter) + +If you run into an issue with the sample itself, please file an issue +in the [main Flutter repo](https://github.com/flutter/flutter/issues). + diff --git a/jsonexample/android/.gitignore b/jsonexample/android/.gitignore new file mode 100644 index 000000000..65b7315af --- /dev/null +++ b/jsonexample/android/.gitignore @@ -0,0 +1,10 @@ +*.iml +*.class +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +GeneratedPluginRegistrant.java diff --git a/jsonexample/android/app/build.gradle b/jsonexample/android/app/build.gradle new file mode 100644 index 000000000..f056606a4 --- /dev/null +++ b/jsonexample/android/app/build.gradle @@ -0,0 +1,51 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +apply plugin: 'com.android.application' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion 27 + + lintOptions { + disable 'InvalidPackage' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.google.example.jsonexample" + minSdkVersion 16 + targetSdkVersion 27 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.1' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' +} diff --git a/jsonexample/android/app/src/main/AndroidManifest.xml b/jsonexample/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..bb93d4c66 --- /dev/null +++ b/jsonexample/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + diff --git a/jsonexample/android/app/src/main/java/com/google/example/jsonexample/MainActivity.java b/jsonexample/android/app/src/main/java/com/google/example/jsonexample/MainActivity.java new file mode 100644 index 000000000..7eb034fdc --- /dev/null +++ b/jsonexample/android/app/src/main/java/com/google/example/jsonexample/MainActivity.java @@ -0,0 +1,14 @@ +package com.google.example.jsonexample; + +import android.os.Bundle; + +import io.flutter.app.FlutterActivity; +import io.flutter.plugins.GeneratedPluginRegistrant; + +public class MainActivity extends FlutterActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + GeneratedPluginRegistrant.registerWith(this); + } +} diff --git a/jsonexample/android/app/src/main/res/drawable/launch_background.xml b/jsonexample/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 000000000..304732f88 --- /dev/null +++ b/jsonexample/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/jsonexample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/jsonexample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..db77bb4b7 Binary files /dev/null and b/jsonexample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/jsonexample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/jsonexample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..17987b79b Binary files /dev/null and b/jsonexample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/jsonexample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/jsonexample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..09d439148 Binary files /dev/null and b/jsonexample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/jsonexample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/jsonexample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..d5f1c8d34 Binary files /dev/null and b/jsonexample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/jsonexample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/jsonexample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..4d6372eeb Binary files /dev/null and b/jsonexample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/jsonexample/android/app/src/main/res/values/styles.xml b/jsonexample/android/app/src/main/res/values/styles.xml new file mode 100644 index 000000000..00fa4417c --- /dev/null +++ b/jsonexample/android/app/src/main/res/values/styles.xml @@ -0,0 +1,8 @@ + + + + diff --git a/jsonexample/android/build.gradle b/jsonexample/android/build.gradle new file mode 100644 index 000000000..447688755 --- /dev/null +++ b/jsonexample/android/build.gradle @@ -0,0 +1,29 @@ +buildscript { + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:3.0.1' + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/jsonexample/android/gradle.properties b/jsonexample/android/gradle.properties new file mode 100644 index 000000000..8bd86f680 --- /dev/null +++ b/jsonexample/android/gradle.properties @@ -0,0 +1 @@ +org.gradle.jvmargs=-Xmx1536M diff --git a/jsonexample/android/gradle/wrapper/gradle-wrapper.jar b/jsonexample/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..13372aef5 Binary files /dev/null and b/jsonexample/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/jsonexample/android/gradle/wrapper/gradle-wrapper.properties b/jsonexample/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..aa901e1e0 --- /dev/null +++ b/jsonexample/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/jsonexample/android/gradlew b/jsonexample/android/gradlew new file mode 100755 index 000000000..9d82f7891 --- /dev/null +++ b/jsonexample/android/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/jsonexample/android/gradlew.bat b/jsonexample/android/gradlew.bat new file mode 100644 index 000000000..aec99730b --- /dev/null +++ b/jsonexample/android/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/jsonexample/android/settings.gradle b/jsonexample/android/settings.gradle new file mode 100644 index 000000000..5a2f14fb1 --- /dev/null +++ b/jsonexample/android/settings.gradle @@ -0,0 +1,15 @@ +include ':app' + +def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + +def plugins = new Properties() +def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') +if (pluginsFile.exists()) { + pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } +} + +plugins.each { name, path -> + def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() + include ":$name" + project(":$name").projectDir = pluginDirectory +} diff --git a/jsonexample/build.yaml b/jsonexample/build.yaml new file mode 100644 index 000000000..86bade68a --- /dev/null +++ b/jsonexample/build.yaml @@ -0,0 +1,26 @@ +targets: + $default: + builders: + built_value_generator|built_value: + generate_for: + - lib/built_value/*.dart + options: + header: | + // Copyright 2018 The Chromium Authors. All rights reserved. + // Use of this source code is governed by a BSD-style license that can be + // found in the LICENSE file. + + // GENERATED CODE - DO NOT MODIFY BY HAND + json_serializable|json_serializable: + generate_for: + - lib/json_serializable/*.dart + options: + header: | + // Copyright 2018 The Chromium Authors. All rights reserved. + // Use of this source code is governed by a BSD-style license that can be + // found in the LICENSE file. + + // GENERATED CODE - DO NOT MODIFY BY HAND + + + diff --git a/jsonexample/ios/.gitignore b/jsonexample/ios/.gitignore new file mode 100644 index 000000000..2a8c8b606 --- /dev/null +++ b/jsonexample/ios/.gitignore @@ -0,0 +1,44 @@ +.idea/ +.vagrant/ +.sconsign.dblite +.svn/ + +.DS_Store +*.swp +profile + +DerivedData/ +build/ +GeneratedPluginRegistrant.h +GeneratedPluginRegistrant.m + +.generated/ + +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspectivev3 + +!default.pbxuser +!default.mode1v3 +!default.mode2v3 +!default.perspectivev3 + +xcuserdata + +*.moved-aside + +*.pyc +*sync/ +Icon? +.tags* + +/Flutter/app.flx +/Flutter/app.zip +/Flutter/flutter_assets/ +/Flutter/App.framework +/Flutter/Flutter.framework +/Flutter/Generated.xcconfig +/ServiceDefinitions.json + +Pods/ diff --git a/jsonexample/ios/Flutter/AppFrameworkInfo.plist b/jsonexample/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 000000000..6c2de8086 --- /dev/null +++ b/jsonexample/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + UIRequiredDeviceCapabilities + + arm64 + + MinimumOSVersion + 8.0 + + diff --git a/jsonexample/ios/Flutter/Debug.xcconfig b/jsonexample/ios/Flutter/Debug.xcconfig new file mode 100644 index 000000000..592ceee85 --- /dev/null +++ b/jsonexample/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/jsonexample/ios/Flutter/Release.xcconfig b/jsonexample/ios/Flutter/Release.xcconfig new file mode 100644 index 000000000..592ceee85 --- /dev/null +++ b/jsonexample/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/jsonexample/ios/Runner.xcodeproj/project.pbxproj b/jsonexample/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 000000000..fc2248546 --- /dev/null +++ b/jsonexample/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,440 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; + 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; + 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB31CF90195004384FC /* Generated.xcconfig */; }; + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; + 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, + 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 2D5378251FAA1A9400D5DBA9 /* flutter_assets */, + 3B80C3931E831B6300D905FE /* App.framework */, + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEBA1CF902C7004384FC /* Flutter.framework */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + CF3B75C9A7D2FA2A4C99F110 /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 97C146F11CF9000F007C117D /* Supporting Files */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + ); + path = Runner; + sourceTree = ""; + }; + 97C146F11CF9000F007C117D /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 97C146F21CF9000F007C117D /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0910; + ORGANIZATIONNAME = "The Chromium Authors"; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, + 97C146F31CF9000F007C117D /* main.m in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ARCHS = arm64; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CURRENT_PROJECT_VERSION = 1; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.google.example.jsonexample; + PRODUCT_NAME = "$(TARGET_NAME)"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ARCHS = arm64; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CURRENT_PROJECT_VERSION = 1; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.google.example.jsonexample; + PRODUCT_NAME = "$(TARGET_NAME)"; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/jsonexample/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/jsonexample/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..1d526a16e --- /dev/null +++ b/jsonexample/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/jsonexample/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/jsonexample/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 000000000..1263ac84b --- /dev/null +++ b/jsonexample/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jsonexample/ios/Runner.xcworkspace/contents.xcworkspacedata b/jsonexample/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..1d526a16e --- /dev/null +++ b/jsonexample/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/jsonexample/ios/Runner/AppDelegate.h b/jsonexample/ios/Runner/AppDelegate.h new file mode 100644 index 000000000..cf210d213 --- /dev/null +++ b/jsonexample/ios/Runner/AppDelegate.h @@ -0,0 +1,6 @@ +#import +#import + +@interface AppDelegate : FlutterAppDelegate + +@end diff --git a/jsonexample/ios/Runner/AppDelegate.m b/jsonexample/ios/Runner/AppDelegate.m new file mode 100644 index 000000000..112becd13 --- /dev/null +++ b/jsonexample/ios/Runner/AppDelegate.m @@ -0,0 +1,12 @@ +#include "AppDelegate.h" +#include "GeneratedPluginRegistrant.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [GeneratedPluginRegistrant registerWithRegistry:self]; + // Override point for customization after application launch. + return [super application:application didFinishLaunchingWithOptions:launchOptions]; +} + +@end diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..d36b1fab2 --- /dev/null +++ b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 000000000..3d43d11e6 Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 000000000..28c6bf030 Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 000000000..2ccbfd967 Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 000000000..f091b6b0b Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 000000000..4cde12118 Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 000000000..d0ef06e7e Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 000000000..dcdc2306c Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 000000000..2ccbfd967 Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 000000000..c8f9ed8f5 Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 000000000..a6d6b8609 Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 000000000..a6d6b8609 Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 000000000..75b2d164a Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 000000000..c4df70d39 Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 000000000..6a84f41e1 Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 000000000..d0e1f5853 Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 000000000..0bedcf2fd --- /dev/null +++ b/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 000000000..89c2725b7 --- /dev/null +++ b/jsonexample/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/jsonexample/ios/Runner/Base.lproj/LaunchScreen.storyboard b/jsonexample/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000..f2e259c7c --- /dev/null +++ b/jsonexample/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jsonexample/ios/Runner/Base.lproj/Main.storyboard b/jsonexample/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 000000000..f3c28516f --- /dev/null +++ b/jsonexample/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jsonexample/ios/Runner/Info.plist b/jsonexample/ios/Runner/Info.plist new file mode 100644 index 000000000..093aae07a --- /dev/null +++ b/jsonexample/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + jsonexample + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/jsonexample/ios/Runner/main.m b/jsonexample/ios/Runner/main.m new file mode 100644 index 000000000..0ccc45001 --- /dev/null +++ b/jsonexample/ios/Runner/main.m @@ -0,0 +1,9 @@ +#import +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/jsonexample/lib/built_value/built_complex_object.dart b/jsonexample/lib/built_value/built_complex_object.dart new file mode 100644 index 000000000..baeaf8158 --- /dev/null +++ b/jsonexample/lib/built_value/built_complex_object.dart @@ -0,0 +1,40 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:jsonexample/built_value/built_simple_object.dart'; + +part 'built_complex_object.g.dart'; + +abstract class BuiltComplexObject + implements Built { + static Serializer get serializer => + _$builtComplexObjectSerializer; + + @nullable + String get aString; + + @nullable + int get anInt; + + @nullable + double get aDouble; + + BuiltSimpleObject get anObject; + + BuiltList get aListOfStrings; + + BuiltList get aListOfInts; + + BuiltList get aListOfDoubles; + + BuiltList get aListOfObjects; + + BuiltComplexObject._(); + + factory BuiltComplexObject([updates(BuiltComplexObjectBuilder b)]) = + _$BuiltComplexObject; +} diff --git a/jsonexample/lib/built_value/built_complex_object.g.dart b/jsonexample/lib/built_value/built_complex_object.g.dart new file mode 100644 index 000000000..e3dc66815 --- /dev/null +++ b/jsonexample/lib/built_value/built_complex_object.g.dart @@ -0,0 +1,345 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'built_complex_object.dart'; + +// ************************************************************************** +// Generator: BuiltValueGenerator +// ************************************************************************** + +// ignore_for_file: always_put_control_body_on_new_line +// ignore_for_file: annotate_overrides +// ignore_for_file: avoid_annotating_with_dynamic +// ignore_for_file: avoid_returning_this +// ignore_for_file: omit_local_variable_types +// ignore_for_file: prefer_expression_function_bodies +// ignore_for_file: sort_constructors_first + +Serializer _$builtComplexObjectSerializer = + new _$BuiltComplexObjectSerializer(); + +class _$BuiltComplexObjectSerializer + implements StructuredSerializer { + @override + final Iterable types = const [BuiltComplexObject, _$BuiltComplexObject]; + @override + final String wireName = 'BuiltComplexObject'; + + @override + Iterable serialize(Serializers serializers, BuiltComplexObject object, + {FullType specifiedType: FullType.unspecified}) { + final result = [ + 'anObject', + serializers.serialize(object.anObject, + specifiedType: const FullType(BuiltSimpleObject)), + 'aListOfStrings', + serializers.serialize(object.aListOfStrings, + specifiedType: + const FullType(BuiltList, const [const FullType(String)])), + 'aListOfInts', + serializers.serialize(object.aListOfInts, + specifiedType: + const FullType(BuiltList, const [const FullType(int)])), + 'aListOfDoubles', + serializers.serialize(object.aListOfDoubles, + specifiedType: + const FullType(BuiltList, const [const FullType(double)])), + 'aListOfObjects', + serializers.serialize(object.aListOfObjects, + specifiedType: const FullType( + BuiltList, const [const FullType(BuiltSimpleObject)])), + ]; + if (object.aString != null) { + result + ..add('aString') + ..add(serializers.serialize(object.aString, + specifiedType: const FullType(String))); + } + if (object.anInt != null) { + result + ..add('anInt') + ..add(serializers.serialize(object.anInt, + specifiedType: const FullType(int))); + } + if (object.aDouble != null) { + result + ..add('aDouble') + ..add(serializers.serialize(object.aDouble, + specifiedType: const FullType(double))); + } + + return result; + } + + @override + BuiltComplexObject deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType: FullType.unspecified}) { + final result = new BuiltComplexObjectBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final dynamic value = iterator.current; + switch (key) { + case 'aString': + result.aString = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case 'anInt': + result.anInt = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case 'aDouble': + result.aDouble = serializers.deserialize(value, + specifiedType: const FullType(double)) as double; + break; + case 'anObject': + result.anObject.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltSimpleObject)) + as BuiltSimpleObject); + break; + case 'aListOfStrings': + result.aListOfStrings.replace(serializers.deserialize(value, + specifiedType: + const FullType(BuiltList, const [const FullType(String)])) + as BuiltList); + break; + case 'aListOfInts': + result.aListOfInts.replace(serializers.deserialize(value, + specifiedType: + const FullType(BuiltList, const [const FullType(int)])) + as BuiltList); + break; + case 'aListOfDoubles': + result.aListOfDoubles.replace(serializers.deserialize(value, + specifiedType: + const FullType(BuiltList, const [const FullType(double)])) + as BuiltList); + break; + case 'aListOfObjects': + result.aListOfObjects.replace(serializers.deserialize(value, + specifiedType: const FullType( + BuiltList, const [const FullType(BuiltSimpleObject)])) + as BuiltList); + break; + } + } + + return result.build(); + } +} + +class _$BuiltComplexObject extends BuiltComplexObject { + @override + final String aString; + @override + final int anInt; + @override + final double aDouble; + @override + final BuiltSimpleObject anObject; + @override + final BuiltList aListOfStrings; + @override + final BuiltList aListOfInts; + @override + final BuiltList aListOfDoubles; + @override + final BuiltList aListOfObjects; + + factory _$BuiltComplexObject([void updates(BuiltComplexObjectBuilder b)]) => + (new BuiltComplexObjectBuilder()..update(updates)).build(); + + _$BuiltComplexObject._( + {this.aString, + this.anInt, + this.aDouble, + this.anObject, + this.aListOfStrings, + this.aListOfInts, + this.aListOfDoubles, + this.aListOfObjects}) + : super._() { + if (anObject == null) + throw new BuiltValueNullFieldError('BuiltComplexObject', 'anObject'); + if (aListOfStrings == null) + throw new BuiltValueNullFieldError( + 'BuiltComplexObject', 'aListOfStrings'); + if (aListOfInts == null) + throw new BuiltValueNullFieldError('BuiltComplexObject', 'aListOfInts'); + if (aListOfDoubles == null) + throw new BuiltValueNullFieldError( + 'BuiltComplexObject', 'aListOfDoubles'); + if (aListOfObjects == null) + throw new BuiltValueNullFieldError( + 'BuiltComplexObject', 'aListOfObjects'); + } + + @override + BuiltComplexObject rebuild(void updates(BuiltComplexObjectBuilder b)) => + (toBuilder()..update(updates)).build(); + + @override + BuiltComplexObjectBuilder toBuilder() => + new BuiltComplexObjectBuilder()..replace(this); + + @override + bool operator ==(dynamic other) { + if (identical(other, this)) return true; + if (other is! BuiltComplexObject) return false; + return aString == other.aString && + anInt == other.anInt && + aDouble == other.aDouble && + anObject == other.anObject && + aListOfStrings == other.aListOfStrings && + aListOfInts == other.aListOfInts && + aListOfDoubles == other.aListOfDoubles && + aListOfObjects == other.aListOfObjects; + } + + @override + int get hashCode { + return $jf($jc( + $jc( + $jc( + $jc( + $jc( + $jc($jc($jc(0, aString.hashCode), anInt.hashCode), + aDouble.hashCode), + anObject.hashCode), + aListOfStrings.hashCode), + aListOfInts.hashCode), + aListOfDoubles.hashCode), + aListOfObjects.hashCode)); + } + + @override + String toString() { + return (newBuiltValueToStringHelper('BuiltComplexObject') + ..add('aString', aString) + ..add('anInt', anInt) + ..add('aDouble', aDouble) + ..add('anObject', anObject) + ..add('aListOfStrings', aListOfStrings) + ..add('aListOfInts', aListOfInts) + ..add('aListOfDoubles', aListOfDoubles) + ..add('aListOfObjects', aListOfObjects)) + .toString(); + } +} + +class BuiltComplexObjectBuilder + implements Builder { + _$BuiltComplexObject _$v; + + String _aString; + String get aString => _$this._aString; + set aString(String aString) => _$this._aString = aString; + + int _anInt; + int get anInt => _$this._anInt; + set anInt(int anInt) => _$this._anInt = anInt; + + double _aDouble; + double get aDouble => _$this._aDouble; + set aDouble(double aDouble) => _$this._aDouble = aDouble; + + BuiltSimpleObjectBuilder _anObject; + BuiltSimpleObjectBuilder get anObject => + _$this._anObject ??= new BuiltSimpleObjectBuilder(); + set anObject(BuiltSimpleObjectBuilder anObject) => + _$this._anObject = anObject; + + ListBuilder _aListOfStrings; + ListBuilder get aListOfStrings => + _$this._aListOfStrings ??= new ListBuilder(); + set aListOfStrings(ListBuilder aListOfStrings) => + _$this._aListOfStrings = aListOfStrings; + + ListBuilder _aListOfInts; + ListBuilder get aListOfInts => + _$this._aListOfInts ??= new ListBuilder(); + set aListOfInts(ListBuilder aListOfInts) => + _$this._aListOfInts = aListOfInts; + + ListBuilder _aListOfDoubles; + ListBuilder get aListOfDoubles => + _$this._aListOfDoubles ??= new ListBuilder(); + set aListOfDoubles(ListBuilder aListOfDoubles) => + _$this._aListOfDoubles = aListOfDoubles; + + ListBuilder _aListOfObjects; + ListBuilder get aListOfObjects => + _$this._aListOfObjects ??= new ListBuilder(); + set aListOfObjects(ListBuilder aListOfObjects) => + _$this._aListOfObjects = aListOfObjects; + + BuiltComplexObjectBuilder(); + + BuiltComplexObjectBuilder get _$this { + if (_$v != null) { + _aString = _$v.aString; + _anInt = _$v.anInt; + _aDouble = _$v.aDouble; + _anObject = _$v.anObject?.toBuilder(); + _aListOfStrings = _$v.aListOfStrings?.toBuilder(); + _aListOfInts = _$v.aListOfInts?.toBuilder(); + _aListOfDoubles = _$v.aListOfDoubles?.toBuilder(); + _aListOfObjects = _$v.aListOfObjects?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(BuiltComplexObject other) { + if (other == null) throw new ArgumentError.notNull('other'); + _$v = other as _$BuiltComplexObject; + } + + @override + void update(void updates(BuiltComplexObjectBuilder b)) { + if (updates != null) updates(this); + } + + @override + _$BuiltComplexObject build() { + _$BuiltComplexObject _$result; + try { + _$result = _$v ?? + new _$BuiltComplexObject._( + aString: aString, + anInt: anInt, + aDouble: aDouble, + anObject: anObject.build(), + aListOfStrings: aListOfStrings.build(), + aListOfInts: aListOfInts.build(), + aListOfDoubles: aListOfDoubles.build(), + aListOfObjects: aListOfObjects.build()); + } catch (_) { + String _$failedField; + try { + _$failedField = 'anObject'; + anObject.build(); + _$failedField = 'aListOfStrings'; + aListOfStrings.build(); + _$failedField = 'aListOfInts'; + aListOfInts.build(); + _$failedField = 'aListOfDoubles'; + aListOfDoubles.build(); + _$failedField = 'aListOfObjects'; + aListOfObjects.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + 'BuiltComplexObject', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} diff --git a/jsonexample/lib/built_value/built_simple_object.dart b/jsonexample/lib/built_value/built_simple_object.dart new file mode 100644 index 000000000..297c5fb65 --- /dev/null +++ b/jsonexample/lib/built_value/built_simple_object.dart @@ -0,0 +1,35 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; + +part 'built_simple_object.g.dart'; + +abstract class BuiltSimpleObject + implements Built { + static Serializer get serializer => + _$builtSimpleObjectSerializer; + + @nullable + String get aString; + + @nullable + int get anInt; + + @nullable + double get aDouble; + + BuiltList get aListOfStrings; + + BuiltList get aListOfInts; + + BuiltList get aListOfDoubles; + + BuiltSimpleObject._(); + + factory BuiltSimpleObject([updates(BuiltSimpleObjectBuilder b)]) = + _$BuiltSimpleObject; +} diff --git a/jsonexample/lib/built_value/built_simple_object.g.dart b/jsonexample/lib/built_value/built_simple_object.g.dart new file mode 100644 index 000000000..9c91fbe7f --- /dev/null +++ b/jsonexample/lib/built_value/built_simple_object.g.dart @@ -0,0 +1,286 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'built_simple_object.dart'; + +// ************************************************************************** +// Generator: BuiltValueGenerator +// ************************************************************************** + +// ignore_for_file: always_put_control_body_on_new_line +// ignore_for_file: annotate_overrides +// ignore_for_file: avoid_annotating_with_dynamic +// ignore_for_file: avoid_returning_this +// ignore_for_file: omit_local_variable_types +// ignore_for_file: prefer_expression_function_bodies +// ignore_for_file: sort_constructors_first + +Serializer _$builtSimpleObjectSerializer = + new _$BuiltSimpleObjectSerializer(); + +class _$BuiltSimpleObjectSerializer + implements StructuredSerializer { + @override + final Iterable types = const [BuiltSimpleObject, _$BuiltSimpleObject]; + @override + final String wireName = 'BuiltSimpleObject'; + + @override + Iterable serialize(Serializers serializers, BuiltSimpleObject object, + {FullType specifiedType: FullType.unspecified}) { + final result = [ + 'aListOfStrings', + serializers.serialize(object.aListOfStrings, + specifiedType: + const FullType(BuiltList, const [const FullType(String)])), + 'aListOfInts', + serializers.serialize(object.aListOfInts, + specifiedType: + const FullType(BuiltList, const [const FullType(int)])), + 'aListOfDoubles', + serializers.serialize(object.aListOfDoubles, + specifiedType: + const FullType(BuiltList, const [const FullType(double)])), + ]; + if (object.aString != null) { + result + ..add('aString') + ..add(serializers.serialize(object.aString, + specifiedType: const FullType(String))); + } + if (object.anInt != null) { + result + ..add('anInt') + ..add(serializers.serialize(object.anInt, + specifiedType: const FullType(int))); + } + if (object.aDouble != null) { + result + ..add('aDouble') + ..add(serializers.serialize(object.aDouble, + specifiedType: const FullType(double))); + } + + return result; + } + + @override + BuiltSimpleObject deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType: FullType.unspecified}) { + final result = new BuiltSimpleObjectBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final dynamic value = iterator.current; + switch (key) { + case 'aString': + result.aString = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case 'anInt': + result.anInt = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case 'aDouble': + result.aDouble = serializers.deserialize(value, + specifiedType: const FullType(double)) as double; + break; + case 'aListOfStrings': + result.aListOfStrings.replace(serializers.deserialize(value, + specifiedType: + const FullType(BuiltList, const [const FullType(String)])) + as BuiltList); + break; + case 'aListOfInts': + result.aListOfInts.replace(serializers.deserialize(value, + specifiedType: + const FullType(BuiltList, const [const FullType(int)])) + as BuiltList); + break; + case 'aListOfDoubles': + result.aListOfDoubles.replace(serializers.deserialize(value, + specifiedType: + const FullType(BuiltList, const [const FullType(double)])) + as BuiltList); + break; + } + } + + return result.build(); + } +} + +class _$BuiltSimpleObject extends BuiltSimpleObject { + @override + final String aString; + @override + final int anInt; + @override + final double aDouble; + @override + final BuiltList aListOfStrings; + @override + final BuiltList aListOfInts; + @override + final BuiltList aListOfDoubles; + + factory _$BuiltSimpleObject([void updates(BuiltSimpleObjectBuilder b)]) => + (new BuiltSimpleObjectBuilder()..update(updates)).build(); + + _$BuiltSimpleObject._( + {this.aString, + this.anInt, + this.aDouble, + this.aListOfStrings, + this.aListOfInts, + this.aListOfDoubles}) + : super._() { + if (aListOfStrings == null) + throw new BuiltValueNullFieldError('BuiltSimpleObject', 'aListOfStrings'); + if (aListOfInts == null) + throw new BuiltValueNullFieldError('BuiltSimpleObject', 'aListOfInts'); + if (aListOfDoubles == null) + throw new BuiltValueNullFieldError('BuiltSimpleObject', 'aListOfDoubles'); + } + + @override + BuiltSimpleObject rebuild(void updates(BuiltSimpleObjectBuilder b)) => + (toBuilder()..update(updates)).build(); + + @override + BuiltSimpleObjectBuilder toBuilder() => + new BuiltSimpleObjectBuilder()..replace(this); + + @override + bool operator ==(dynamic other) { + if (identical(other, this)) return true; + if (other is! BuiltSimpleObject) return false; + return aString == other.aString && + anInt == other.anInt && + aDouble == other.aDouble && + aListOfStrings == other.aListOfStrings && + aListOfInts == other.aListOfInts && + aListOfDoubles == other.aListOfDoubles; + } + + @override + int get hashCode { + return $jf($jc( + $jc( + $jc( + $jc($jc($jc(0, aString.hashCode), anInt.hashCode), + aDouble.hashCode), + aListOfStrings.hashCode), + aListOfInts.hashCode), + aListOfDoubles.hashCode)); + } + + @override + String toString() { + return (newBuiltValueToStringHelper('BuiltSimpleObject') + ..add('aString', aString) + ..add('anInt', anInt) + ..add('aDouble', aDouble) + ..add('aListOfStrings', aListOfStrings) + ..add('aListOfInts', aListOfInts) + ..add('aListOfDoubles', aListOfDoubles)) + .toString(); + } +} + +class BuiltSimpleObjectBuilder + implements Builder { + _$BuiltSimpleObject _$v; + + String _aString; + String get aString => _$this._aString; + set aString(String aString) => _$this._aString = aString; + + int _anInt; + int get anInt => _$this._anInt; + set anInt(int anInt) => _$this._anInt = anInt; + + double _aDouble; + double get aDouble => _$this._aDouble; + set aDouble(double aDouble) => _$this._aDouble = aDouble; + + ListBuilder _aListOfStrings; + ListBuilder get aListOfStrings => + _$this._aListOfStrings ??= new ListBuilder(); + set aListOfStrings(ListBuilder aListOfStrings) => + _$this._aListOfStrings = aListOfStrings; + + ListBuilder _aListOfInts; + ListBuilder get aListOfInts => + _$this._aListOfInts ??= new ListBuilder(); + set aListOfInts(ListBuilder aListOfInts) => + _$this._aListOfInts = aListOfInts; + + ListBuilder _aListOfDoubles; + ListBuilder get aListOfDoubles => + _$this._aListOfDoubles ??= new ListBuilder(); + set aListOfDoubles(ListBuilder aListOfDoubles) => + _$this._aListOfDoubles = aListOfDoubles; + + BuiltSimpleObjectBuilder(); + + BuiltSimpleObjectBuilder get _$this { + if (_$v != null) { + _aString = _$v.aString; + _anInt = _$v.anInt; + _aDouble = _$v.aDouble; + _aListOfStrings = _$v.aListOfStrings?.toBuilder(); + _aListOfInts = _$v.aListOfInts?.toBuilder(); + _aListOfDoubles = _$v.aListOfDoubles?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(BuiltSimpleObject other) { + if (other == null) throw new ArgumentError.notNull('other'); + _$v = other as _$BuiltSimpleObject; + } + + @override + void update(void updates(BuiltSimpleObjectBuilder b)) { + if (updates != null) updates(this); + } + + @override + _$BuiltSimpleObject build() { + _$BuiltSimpleObject _$result; + try { + _$result = _$v ?? + new _$BuiltSimpleObject._( + aString: aString, + anInt: anInt, + aDouble: aDouble, + aListOfStrings: aListOfStrings.build(), + aListOfInts: aListOfInts.build(), + aListOfDoubles: aListOfDoubles.build()); + } catch (_) { + String _$failedField; + try { + _$failedField = 'aListOfStrings'; + aListOfStrings.build(); + _$failedField = 'aListOfInts'; + aListOfInts.build(); + _$failedField = 'aListOfDoubles'; + aListOfDoubles.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + 'BuiltSimpleObject', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} diff --git a/jsonexample/lib/built_value/built_value_serializers.dart b/jsonexample/lib/built_value/built_value_serializers.dart new file mode 100644 index 000000000..a3be0239e --- /dev/null +++ b/jsonexample/lib/built_value/built_value_serializers.dart @@ -0,0 +1,25 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +library serializers; + +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/serializer.dart'; +import 'package:built_value/standard_json_plugin.dart'; +import 'package:jsonexample/built_value/built_complex_object.dart'; +import 'package:jsonexample/built_value/built_simple_object.dart'; + +part 'built_value_serializers.g.dart'; + +@SerializersFor(const [ + BuiltSimpleObject, + BuiltComplexObject, +]) + +// By default, `built_value` serialization uses lists and is not compatible +// with other JSON formats. If you'd like to serialize data using a map-based +// JSON approach (which is what you'll find in the json_strings.dart file in +// this project), you can add the StandardJsonPlugin as you see here. +final Serializers serializers = + (_$serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build(); diff --git a/jsonexample/lib/built_value/built_value_serializers.g.dart b/jsonexample/lib/built_value/built_value_serializers.g.dart new file mode 100644 index 000000000..5fa2ddb28 --- /dev/null +++ b/jsonexample/lib/built_value/built_value_serializers.g.dart @@ -0,0 +1,45 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of serializers; + +// ************************************************************************** +// Generator: BuiltValueGenerator +// ************************************************************************** + +// ignore_for_file: always_put_control_body_on_new_line +// ignore_for_file: annotate_overrides +// ignore_for_file: avoid_annotating_with_dynamic +// ignore_for_file: avoid_returning_this +// ignore_for_file: omit_local_variable_types +// ignore_for_file: prefer_expression_function_bodies +// ignore_for_file: sort_constructors_first + +Serializers _$serializers = (new Serializers().toBuilder() + ..add(BuiltComplexObject.serializer) + ..add(BuiltSimpleObject.serializer) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(String)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(int)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(double)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(String)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(int)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(double)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(BuiltSimpleObject)]), + () => new ListBuilder())) + .build(); diff --git a/jsonexample/lib/dart_convert/converted_complex_object.dart b/jsonexample/lib/dart_convert/converted_complex_object.dart new file mode 100644 index 000000000..526ebc17f --- /dev/null +++ b/jsonexample/lib/dart_convert/converted_complex_object.dart @@ -0,0 +1,52 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:jsonexample/dart_convert/converted_simple_object.dart'; + +class ConvertedComplexObject { + const ConvertedComplexObject({ + this.aString, + this.anInt, + this.aDouble, + this.anObject, + this.aListOfStrings, + this.aListOfInts, + this.aListOfDoubles, + this.aListOfObjects, + }); + + final String aString; + final int anInt; + final double aDouble; + final ConvertedSimpleObject anObject; + final List aListOfStrings; + final List aListOfInts; + final List aListOfDoubles; + final List aListOfObjects; + + factory ConvertedComplexObject.fromJson(Map json) { + if (json == null) return null; + + return ConvertedComplexObject( + aString: json['aString'], + anInt: json['anInt'], + aDouble: json['aDouble'], + anObject: json['anObject'] != null + ? ConvertedSimpleObject.fromJson(json['anObject']) + : null, + aListOfStrings: json['aListOfStrings'] != null + ? List.from(json['aListOfStrings']) + : null, + aListOfInts: json['aListOfInts'] != null + ? List.from(json['aListOfInts']) + : null, + aListOfDoubles: json['aListOfDoubles'] != null + ? List.from(json['aListOfDoubles']) + : null, + aListOfObjects: json['aListOfObjects'] != null + ? List.from(json['aListOfObjects'] + .map((o) => ConvertedSimpleObject.fromJson(o))) + : null); + } +} diff --git a/jsonexample/lib/dart_convert/converted_simple_object.dart b/jsonexample/lib/dart_convert/converted_simple_object.dart new file mode 100644 index 000000000..6f8b1771f --- /dev/null +++ b/jsonexample/lib/dart_convert/converted_simple_object.dart @@ -0,0 +1,40 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +class ConvertedSimpleObject { + const ConvertedSimpleObject({ + this.aString, + this.anInt, + this.aDouble, + this.aListOfStrings, + this.aListOfInts, + this.aListOfDoubles, + }); + + final String aString; + final int anInt; + final double aDouble; + final List aListOfStrings; + final List aListOfInts; + final List aListOfDoubles; + + factory ConvertedSimpleObject.fromJson(Map json) { + if (json == null) return null; + + return ConvertedSimpleObject( + aString: json['aString'], + anInt: json['anInt'], + aDouble: json['aDouble'], + aListOfStrings: json['aListOfStrings'] != null + ? List.from(json['aListOfStrings']) + : null, + aListOfInts: json['aListOfInts'] != null + ? List.from(json['aListOfInts']) + : null, + aListOfDoubles: json['aListOfDoubles'] != null + ? List.from(json['aListOfDoubles']) + : null, + ); + } +} diff --git a/jsonexample/lib/json_serializable/serializable_complex_object.dart b/jsonexample/lib/json_serializable/serializable_complex_object.dart new file mode 100644 index 000000000..0183c8fb8 --- /dev/null +++ b/jsonexample/lib/json_serializable/serializable_complex_object.dart @@ -0,0 +1,35 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:json_annotation/json_annotation.dart'; +import 'package:jsonexample/json_serializable/serializable_simple_object.dart'; + +part 'serializable_complex_object.g.dart'; + +@JsonSerializable() +class SerializableComplexObject extends Object + with _$SerializableComplexObjectSerializerMixin { + SerializableComplexObject({ + this.aString, + this.anInt, + this.aDouble, + this.anObject, + this.aListOfStrings, + this.aListOfInts, + this.aListOfDoubles, + this.aListOfObjects, + }); + + final String aString; + final int anInt; + final double aDouble; + final SerializableSimpleObject anObject; + final List aListOfStrings; + final List aListOfInts; + final List aListOfDoubles; + final List aListOfObjects; + + factory SerializableComplexObject.fromJson(Map json) => + _$SerializableComplexObjectFromJson(json); +} diff --git a/jsonexample/lib/json_serializable/serializable_complex_object.g.dart b/jsonexample/lib/json_serializable/serializable_complex_object.g.dart new file mode 100644 index 000000000..21bce9abf --- /dev/null +++ b/jsonexample/lib/json_serializable/serializable_complex_object.g.dart @@ -0,0 +1,56 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'serializable_complex_object.dart'; + +// ************************************************************************** +// Generator: JsonSerializableGenerator +// ************************************************************************** + +SerializableComplexObject _$SerializableComplexObjectFromJson( + Map json) => + new SerializableComplexObject( + aString: json['aString'] as String, + anInt: json['anInt'] as int, + aDouble: (json['aDouble'] as num)?.toDouble(), + anObject: json['anObject'] == null + ? null + : new SerializableSimpleObject.fromJson( + json['anObject'] as Map), + aListOfStrings: + (json['aListOfStrings'] as List)?.map((e) => e as String)?.toList(), + aListOfInts: + (json['aListOfInts'] as List)?.map((e) => e as int)?.toList(), + aListOfDoubles: (json['aListOfDoubles'] as List) + ?.map((e) => (e as num)?.toDouble()) + ?.toList(), + aListOfObjects: (json['aListOfObjects'] as List) + ?.map((e) => e == null + ? null + : new SerializableSimpleObject.fromJson( + e as Map)) + ?.toList()); + +abstract class _$SerializableComplexObjectSerializerMixin { + String get aString; + int get anInt; + double get aDouble; + SerializableSimpleObject get anObject; + List get aListOfStrings; + List get aListOfInts; + List get aListOfDoubles; + List get aListOfObjects; + Map toJson() => { + 'aString': aString, + 'anInt': anInt, + 'aDouble': aDouble, + 'anObject': anObject, + 'aListOfStrings': aListOfStrings, + 'aListOfInts': aListOfInts, + 'aListOfDoubles': aListOfDoubles, + 'aListOfObjects': aListOfObjects + }; +} diff --git a/jsonexample/lib/json_serializable/serializable_simple_object.dart b/jsonexample/lib/json_serializable/serializable_simple_object.dart new file mode 100644 index 000000000..8c5b434a9 --- /dev/null +++ b/jsonexample/lib/json_serializable/serializable_simple_object.dart @@ -0,0 +1,32 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:json_annotation/json_annotation.dart'; + +part 'serializable_simple_object.g.dart'; + +/// An annotation for the code generator to know that this class needs the +/// JSON serialization logic to be generated. +@JsonSerializable() +class SerializableSimpleObject extends Object + with _$SerializableSimpleObjectSerializerMixin { + SerializableSimpleObject({ + this.aString, + this.anInt, + this.aDouble, + this.aListOfStrings, + this.aListOfInts, + this.aListOfDoubles, + }); + + final String aString; + final int anInt; + final double aDouble; + final List aListOfStrings; + final List aListOfInts; + final List aListOfDoubles; + + factory SerializableSimpleObject.fromJson(Map json) => + _$SerializableSimpleObjectFromJson(json); +} diff --git a/jsonexample/lib/json_serializable/serializable_simple_object.g.dart b/jsonexample/lib/json_serializable/serializable_simple_object.g.dart new file mode 100644 index 000000000..d4a2c1887 --- /dev/null +++ b/jsonexample/lib/json_serializable/serializable_simple_object.g.dart @@ -0,0 +1,42 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'serializable_simple_object.dart'; + +// ************************************************************************** +// Generator: JsonSerializableGenerator +// ************************************************************************** + +SerializableSimpleObject _$SerializableSimpleObjectFromJson( + Map json) => + new SerializableSimpleObject( + aString: json['aString'] as String, + anInt: json['anInt'] as int, + aDouble: (json['aDouble'] as num)?.toDouble(), + aListOfStrings: + (json['aListOfStrings'] as List)?.map((e) => e as String)?.toList(), + aListOfInts: + (json['aListOfInts'] as List)?.map((e) => e as int)?.toList(), + aListOfDoubles: (json['aListOfDoubles'] as List) + ?.map((e) => (e as num)?.toDouble()) + ?.toList()); + +abstract class _$SerializableSimpleObjectSerializerMixin { + String get aString; + int get anInt; + double get aDouble; + List get aListOfStrings; + List get aListOfInts; + List get aListOfDoubles; + Map toJson() => { + 'aString': aString, + 'anInt': anInt, + 'aDouble': aDouble, + 'aListOfStrings': aListOfStrings, + 'aListOfInts': aListOfInts, + 'aListOfDoubles': aListOfDoubles + }; +} diff --git a/jsonexample/lib/json_strings.dart b/jsonexample/lib/json_strings.dart new file mode 100644 index 000000000..0f4ba171b --- /dev/null +++ b/jsonexample/lib/json_strings.dart @@ -0,0 +1,267 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +abstract class JsonStrings { + static final String listOfInts = '[1, 2, 3]'; + + static final String listOfDoubles = '[1.0, 2.0, 3.0]'; + + static final String listOfStrings = '["one", "two", "three"]'; + + static final String listOfDynamics = '[1, "two", 3.0]'; + + static final String mapOfDynamics = ''' + { + "anInt": 1, + "aString": "Blah, blah, blah.", + "aDouble": 1.0 + }'''; + + static final String listOfSimpleObjects = ''' + [ + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }, + { + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }, + { + "aString": "Blah, blah, blah.", + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }, + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }, + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }, + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfDoubles": [1.0, 2.0, 3.0] + }, + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3] + }, + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": [], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }, + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [], + "aListOfDoubles": [1.0, 2.0, 3.0] + }, + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [] + } + ] + '''; + + static final List simpleObjects = [ + ''' + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }''', + ''' + { + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }''', + ''' + { + "aString": "Blah, blah, blah.", + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }''', + ''' + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }''', + ''' + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }''', + ''' + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfDoubles": [1.0, 2.0, 3.0] + }''', + ''' + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3] + }''', + ''' + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": [], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }''', + ''' + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [], + "aListOfDoubles": [1.0, 2.0, 3.0] + }''', + ''' + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [] + }''', + ]; + + static final List complexObjects = [ + ''' + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "anObject": { + "anInt": 1, + "aString": "Blah, blah, blah.", + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0], + "aListOfObjects": [ + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }, + { + "aString": "Blah, blah, blah.", + "anInt": 2, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }, + { + "aString": "Blah, blah, blah.", + "anInt": 3, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + } + ] + }''', + ''' + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "anObject": { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0], + "aListOfObjects": [] + }''', + ''' + { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "anObject": { + "aString": "Blah, blah, blah.", + "anInt": 1, + "aDouble": 1.0, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }, + "aListOfStrings": ["one", "two", "three"], + "aListOfInts": [1, 2, 3], + "aListOfDoubles": [1.0, 2.0, 3.0] + }''', + ]; +} diff --git a/jsonexample/lib/main.dart b/jsonexample/lib/main.dart new file mode 100644 index 000000000..d466290b1 --- /dev/null +++ b/jsonexample/lib/main.dart @@ -0,0 +1,69 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:jsonexample/tab_pages.dart'; + +void main() => runApp(MyApp()); + +class MyApp extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + home: MyHomePage(), + ); + } +} + +class MyHomePage extends StatelessWidget { + MyHomePage({Key key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return DefaultTabController( + length: 10, + child: Scaffold( + appBar: AppBar( + title: const Text('Let\'s parse some JSON'), + bottom: const TabBar( + isScrollable: true, + tabs: [ + Tab(text: 'Basics'), + Tab(text: 'Conv. Simple'), + Tab(text: 'Conv. Complex'), + Tab(text: 'Conv. List'), + Tab(text: 'Ser. Simple'), + Tab(text: 'Ser. Complex'), + Tab(text: 'Ser. List'), + Tab(text: 'Built Simple'), + Tab(text: 'Built Complex'), + Tab(text: 'Built List'), + ], + ), + ), + body: new SafeArea( + bottom: false, + child: TabBarView( + children: [ + BasicsPage(), + ConvertedSimplePage(), + ConvertedComplexPage(), + ConvertedListPage(), + SerializableSimplePage(), + SerializableComplexPage(), + SerializableListPage(), + BuiltSimplePage(), + BuiltComplexPage(), + BuiltListPage(), + ], + ), + ), + ), + ); + } +} diff --git a/jsonexample/lib/tab_pages.dart b/jsonexample/lib/tab_pages.dart new file mode 100644 index 000000000..ba61a8b3f --- /dev/null +++ b/jsonexample/lib/tab_pages.dart @@ -0,0 +1,334 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:jsonexample/built_value/built_complex_object.dart'; +import 'package:jsonexample/built_value/built_simple_object.dart'; +import 'package:jsonexample/built_value/built_value_serializers.dart'; +import 'package:jsonexample/dart_convert/converted_complex_object.dart'; +import 'package:jsonexample/dart_convert/converted_simple_object.dart'; +import 'package:jsonexample/json_serializable/serializable_complex_object.dart'; +import 'package:jsonexample/json_serializable/serializable_simple_object.dart'; +import 'package:jsonexample/json_strings.dart'; +import 'package:jsonexample/utils.dart'; +import 'package:jsonexample/widgets.dart'; + +class BasicsPage extends StatelessWidget { + List createMapRows( + Map values, TextStyle normalStyle, TextStyle boldStyle) { + return values.keys.map((k) { + return TableRow( + children: [ + Padding( + padding: const EdgeInsets.only(right: 8.0, bottom: 4.0), + child: Text(k, style: boldStyle), + ), + Text( + values[k] is String ? '"${values[k]}"' : '${values[k]}', + style: normalStyle, + ), + ], + ); + }).toList(); + } + + @override + Widget build(BuildContext context) { + final localTheme = Theme.of(context).textTheme; + final boldStyle = localTheme.body1.copyWith(fontWeight: FontWeight.w600); + + final dynamicListOfInts = json.decode(JsonStrings.listOfInts); + final strongListOfInts = List.from(dynamicListOfInts); + + final dynamicListOfStrings = json.decode(JsonStrings.listOfStrings); + final strongListOfStrings = List.from(dynamicListOfStrings); + + final dynamicListOfDoubles = json.decode(JsonStrings.listOfDoubles); + final strongListOfDoubles = List.from(dynamicListOfDoubles); + + final dynamicListOfDynamics = json.decode(JsonStrings.listOfDynamics); + final strongListOfDynamics = List.from(dynamicListOfDynamics); + + final dynamicMapOfDynamics = json.decode(JsonStrings.mapOfDynamics); + final strongMapOfDynamics = Map.from(dynamicMapOfDynamics); + + return ListView( + padding: const EdgeInsets.all(16.0), + children: [ + Table( + columnWidths: const { + 0: IntrinsicColumnWidth(), + 1: FlexColumnWidth(1.0), + }, + children: [ + TableRow( + children: [ + Padding( + padding: const EdgeInsets.only(right: 8.0, bottom: 4.0), + child: Text('List of ints:', style: boldStyle), + ), + Text( + prettyPrintList(strongListOfInts), + style: localTheme.body1, + ), + ], + ), + TableRow( + children: [ + Padding( + padding: const EdgeInsets.only(right: 8.0, bottom: 4.0), + child: Text('List of strings:', style: boldStyle), + ), + Text( + prettyPrintList(strongListOfStrings), + style: localTheme.body1, + ), + ], + ), + TableRow( + children: [ + Padding( + padding: const EdgeInsets.only(right: 8.0, bottom: 4.0), + child: Text('List of doubles:', style: boldStyle), + ), + Text( + prettyPrintList(strongListOfDoubles), + style: localTheme.body1, + ), + ], + ), + TableRow( + children: [ + Padding( + padding: const EdgeInsets.only(right: 8.0, bottom: 4.0), + child: Text('List of dynamic:', style: boldStyle), + ), + Text( + prettyPrintList(strongListOfDynamics), + style: localTheme.body1, + ), + ], + ), + TableRow( + children: [ + Padding( + padding: const EdgeInsets.only(right: 8.0, bottom: 8.0), + child: Text('Map of dynamics:', style: boldStyle), + ), + Container(), + ], + ), + ], + ), + Padding( + padding: const EdgeInsets.only(left: 24.0), + child: Table( + columnWidths: const { + 0: IntrinsicColumnWidth(), + 1: FlexColumnWidth(1.0), + }, + children: createMapRows( + strongMapOfDynamics, + localTheme.body1, + boldStyle, + ), + ), + ), + ], + ); + } +} + +class ConvertedSimplePage extends StatelessWidget { + @override + Widget build(BuildContext context) { + List objects = JsonStrings.simpleObjects.map( + (jsonString) { + final parsedJson = json.decode(jsonString); + return ConvertedSimpleObject.fromJson(parsedJson); + }, + ).toList(); + + return ListView( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + children: [ + const SizedBox(height: 16.0), + SimpleObjectViewList(objects), + const SizedBox(height: 16.0), + ], + ); + } +} + +class ConvertedComplexPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + List objects = JsonStrings.complexObjects.map( + (jsonString) { + final parsedJson = json.decode(jsonString); + return ConvertedComplexObject.fromJson(parsedJson); + }, + ).toList(); + + return ListView( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + children: [ + const SizedBox(height: 16.0), + ComplexObjectViewList(objects), + const SizedBox(height: 16.0), + ], + ); + } +} + +class ConvertedListPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + final parsedJson = json.decode(JsonStrings.listOfSimpleObjects); + + final deserializedObjects = + parsedJson.map((o) => ConvertedComplexObject.fromJson(o)); + + final listOfObjects = deserializedObjects.toList(); + + return ListView( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + children: [ + const SizedBox(height: 16.0), + SimpleObjectViewList(listOfObjects), + const SizedBox(height: 16.0), + ], + ); + } +} + +class SerializableSimplePage extends StatelessWidget { + @override + Widget build(BuildContext context) { + List objects = JsonStrings.simpleObjects.map( + (jsonString) { + final parsedJson = json.decode(jsonString); + return SerializableSimpleObject.fromJson(parsedJson); + }, + ).toList(); + + return ListView( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + children: [ + const SizedBox(height: 16.0), + SimpleObjectViewList(objects), + const SizedBox(height: 16.0), + ], + ); + } +} + +class SerializableComplexPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + List objects = JsonStrings.complexObjects.map( + (jsonString) { + final parsedJson = json.decode(jsonString); + return SerializableComplexObject.fromJson(parsedJson); + }, + ).toList(); + + return ListView( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + children: [ + const SizedBox(height: 16.0), + ComplexObjectViewList(objects), + const SizedBox(height: 16.0), + ], + ); + } +} + +class SerializableListPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + final parsedJson = json.decode(JsonStrings.listOfSimpleObjects); + + final deserializedObjects = + parsedJson.map((o) => SerializableSimpleObject.fromJson(o)); + + final listOfObjects = deserializedObjects.toList(); + + return ListView( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + children: [ + const SizedBox(height: 16.0), + SimpleObjectViewList(listOfObjects), + const SizedBox(height: 16.0), + ], + ); + } +} + +class BuiltSimplePage extends StatelessWidget { + @override + Widget build(BuildContext context) { + List objects = JsonStrings.simpleObjects.map( + (jsonString) { + final parsedJson = json.decode(jsonString); + return serializers.deserializeWith( + BuiltSimpleObject.serializer, parsedJson); + }, + ).toList(); + + return ListView( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + children: [ + const SizedBox(height: 16.0), + SimpleObjectViewList(objects), + const SizedBox(height: 16.0), + ], + ); + } +} + +class BuiltComplexPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + List objects = JsonStrings.complexObjects.map( + (jsonString) { + final parsedJson = json.decode(jsonString); + return serializers.deserializeWith( + BuiltComplexObject.serializer, parsedJson); + }, + ).toList(); + + return ListView( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + children: [ + const SizedBox(height: 16.0), + ComplexObjectViewList(objects), + const SizedBox(height: 16.0), + ], + ); + } +} + +class BuiltListPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + final parsedJson = json.decode(JsonStrings.listOfSimpleObjects); + + final deserializedObjects = parsedJson.map( + (o) => serializers.deserializeWith(BuiltComplexObject.serializer, o)); + + final listOfObjects = deserializedObjects.toList(); + + return ListView( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + children: [ + const SizedBox(height: 16.0), + SimpleObjectViewList(listOfObjects), + const SizedBox(height: 16.0), + ], + ); + } +} diff --git a/jsonexample/lib/utils.dart b/jsonexample/lib/utils.dart new file mode 100644 index 000000000..7ff2796df --- /dev/null +++ b/jsonexample/lib/utils.dart @@ -0,0 +1,26 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +String prettyPrintList(Iterable iter) { + if (iter == null) return 'NULL'; + + final buff = StringBuffer(); + var isFirst = true; + + buff.write('['); + + for (final val in iter) { + if (!isFirst) buff.write(', '); + isFirst = false; + if (val is String) { + buff.write('"$val"'); + } else { + buff.write(val.toString()); + } + } + + buff.write(']'); + + return buff.toString(); +} diff --git a/jsonexample/lib/widgets.dart b/jsonexample/lib/widgets.dart new file mode 100644 index 000000000..b1d819ab9 --- /dev/null +++ b/jsonexample/lib/widgets.dart @@ -0,0 +1,291 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:jsonexample/utils.dart'; + +class SimpleObjectView extends StatelessWidget { + SimpleObjectView(dynamic obj) : simpleObject = obj; + + final dynamic simpleObject; + + @override + Widget build(BuildContext context) { + final localTheme = Theme.of(context).textTheme; + final boldStyle = localTheme.body1.copyWith(fontWeight: FontWeight.w600); + + if (simpleObject == null) return Text('NULL', style: localTheme.body1); + + return Table( + columnWidths: const { + 0: IntrinsicColumnWidth(), + 1: FlexColumnWidth(1.0), + }, + children: [ + TableRow( + children: [ + Text( + 'aString:', + style: boldStyle, + ), + Text( + simpleObject.aString != null + ? '"${simpleObject.aString}"' + : 'NULL', + style: localTheme.body1, + ), + ], + ), + TableRow( + children: [ + Text('anInt:', style: boldStyle), + Text( + simpleObject.anInt?.toString() ?? 'NULL', + style: localTheme.body1, + ), + ], + ), + TableRow(children: [ + Text('aDouble:', style: boldStyle), + Text( + simpleObject.aDouble?.toString() ?? 'NULL', + style: localTheme.body1, + ), + ]), + TableRow( + children: [ + Text('aListOfStrings:', style: boldStyle), + Text( + prettyPrintList( + simpleObject.aListOfStrings, + ), + style: localTheme.body1, + ), + ], + ), + TableRow( + children: [ + Text('aListOfInts:', style: boldStyle), + Text( + prettyPrintList(simpleObject.aListOfInts), + style: localTheme.body1, + ), + ], + ), + TableRow( + children: [ + Padding( + padding: const EdgeInsets.only(right: 8.0), + child: Text('aListOfDoubles:', style: boldStyle), + ), + Text( + prettyPrintList(simpleObject.aListOfDoubles), + style: localTheme.body1, + ), + ], + ), + ], + ); + } +} + +class SimpleObjectViewList extends StatelessWidget { + SimpleObjectViewList(List objects) : simpleObjects = objects; + + final List simpleObjects; + + @override + Widget build(BuildContext context) { + final widgets = []; + + for (int i = 0; i < simpleObjects.length; i++) { + widgets.addAll([ + Text( + 'SimpleObject $i:', + style: Theme.of(context).textTheme.subhead, + ), + const SizedBox(height: 4.0), + SimpleObjectView(simpleObjects[i]), + const SizedBox(height: 24.0), + ]); + } + + widgets.removeLast(); + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: widgets, + ); + } +} + +class ComplexObjectView extends StatelessWidget { + final dynamic complexObject; + + ComplexObjectView(dynamic obj) : complexObject = obj; + + List _generateSimpleObjectWidgets(Iterable simpleObjects) { + if (simpleObjects == null) { + return [ + const Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: Text('NULL'), + ), + ]; + } + + if (simpleObjects.length == 0) { + return [ + const Padding( + padding: const EdgeInsets.symmetric(vertical: 4.0), + child: Text('[]'), + ), + ]; + } + + return simpleObjects + .expand((o) => [ + const SizedBox(height: 4.0), + SimpleObjectView(o), + const SizedBox(height: 4.0), + ]) + .toList(); + } + + @override + Widget build(BuildContext context) { + final localTheme = Theme.of(context).textTheme; + final boldStyle = localTheme.body1.copyWith(fontWeight: FontWeight.w600); + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Table( + columnWidths: const { + 0: IntrinsicColumnWidth(), + 1: FlexColumnWidth(1.0), + }, + children: [ + TableRow( + children: [ + Text('aString:', style: boldStyle), + Text( + complexObject.aString != null + ? '"${complexObject.aString}"' + : 'NULL', + style: localTheme.body1), + ], + ), + TableRow( + children: [ + Text('anInt:', style: boldStyle), + Text(complexObject.anInt?.toString() ?? 'NULL', + style: localTheme.body1), + ], + ), + TableRow( + children: [ + Text('aDouble:', style: boldStyle), + Text(complexObject.aDouble?.toString() ?? 'NULL', + style: localTheme.body1), + ], + ), + TableRow( + children: [ + Text('anObject:', style: boldStyle), + Container(), + ], + ), + ], + ), + Padding( + padding: const EdgeInsets.fromLTRB(24.0, 4.0, 0.0, 4.0), + child: SimpleObjectView(complexObject.anObject), + ), + Table( + columnWidths: const { + 0: IntrinsicColumnWidth(), + 1: FlexColumnWidth(1.0), + }, + children: [ + TableRow( + children: [ + Text('aListOfStrings:', style: boldStyle), + Text( + prettyPrintList(complexObject.aListOfStrings), + style: localTheme.body1, + ), + ], + ), + TableRow( + children: [ + Text('aListOfInts:', style: boldStyle), + Text( + prettyPrintList(complexObject.aListOfInts), + style: localTheme.body1, + ), + ], + ), + TableRow( + children: [ + Padding( + padding: const EdgeInsets.only(right: 8.0), + child: Text('aListOfDoubles:', style: boldStyle), + ), + Text( + prettyPrintList(complexObject.aListOfDoubles), + style: localTheme.body1, + ), + ], + ), + TableRow( + children: [ + Text('aListOfObjects:', style: boldStyle), + Container() + ], + ), + ], + ), + Padding( + padding: const EdgeInsets.only(left: 24.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: + _generateSimpleObjectWidgets(complexObject.aListOfObjects), + ), + ), + ], + ); + } +} + +class ComplexObjectViewList extends StatelessWidget { + ComplexObjectViewList(List objects) : complexObjects = objects; + + final List complexObjects; + + @override + Widget build(BuildContext context) { + final widgets = []; + + for (int i = 0; i < complexObjects.length; i++) { + widgets.addAll([ + Text( + 'Complex Object $i:', + style: Theme.of(context).textTheme.subhead, + ), + const SizedBox(height: 4.0), + ComplexObjectView(complexObjects[i]), + const SizedBox(height: 24.0), + ]); + } + + widgets.removeLast(); + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: widgets, + ); + } +} diff --git a/jsonexample/pubspec.yaml b/jsonexample/pubspec.yaml new file mode 100644 index 000000000..afaf7cf30 --- /dev/null +++ b/jsonexample/pubspec.yaml @@ -0,0 +1,24 @@ +name: jsonexample +description: A demonstration of JSON parsing + +dependencies: + + json_annotation: ^0.2.3 + built_collection: '>=2.0.0 <4.0.0' + built_value: ^5.5.1 + + flutter: + sdk: flutter + +dev_dependencies: + + build_runner: ^0.8.0 + json_serializable: ^0.5.0 + built_value_generator: ^5.5.0 + + flutter_test: + sdk: flutter + +flutter: + + uses-material-design: true diff --git a/jsonexample/test/widget_test.dart b/jsonexample/test/widget_test.dart new file mode 100644 index 000000000..df84151d3 --- /dev/null +++ b/jsonexample/test/widget_test.dart @@ -0,0 +1,9 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async {}); +}