├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── example
├── .gitignore
├── .metadata
├── README.md
├── android
│ ├── .gitignore
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── example
│ │ │ │ └── MainActivity.java
│ │ │ └── res
│ │ │ ├── drawable
│ │ │ └── launch_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ └── values
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ └── settings.gradle
├── ios
│ ├── .gitignore
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ └── Release.xcconfig
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── Runner
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ ├── Icon-App-20x20@1x.png
│ │ │ ├── Icon-App-20x20@2x.png
│ │ │ ├── Icon-App-20x20@3x.png
│ │ │ ├── Icon-App-29x29@1x.png
│ │ │ ├── Icon-App-29x29@2x.png
│ │ │ ├── Icon-App-29x29@3x.png
│ │ │ ├── Icon-App-40x40@1x.png
│ │ │ ├── Icon-App-40x40@2x.png
│ │ │ ├── Icon-App-40x40@3x.png
│ │ │ ├── Icon-App-60x60@2x.png
│ │ │ ├── Icon-App-60x60@3x.png
│ │ │ ├── Icon-App-76x76@1x.png
│ │ │ ├── Icon-App-76x76@2x.png
│ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ └── LaunchImage.imageset
│ │ │ ├── Contents.json
│ │ │ ├── LaunchImage.png
│ │ │ ├── LaunchImage@2x.png
│ │ │ ├── LaunchImage@3x.png
│ │ │ └── README.md
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── main.m
├── lib
│ ├── main.dart
│ ├── models.dart
│ └── repo.dart
└── pubspec.yaml
├── sealed_class
├── LICENSE
├── README.md
├── lib
│ ├── sealed_class.dart
│ └── src
│ │ └── sealed.dart
├── pubspec.yaml
└── test
│ └── sealed_class_test.dart
└── sealed_class_generator
├── LICENSE
├── README.md
├── build.yaml
├── lib
├── sealed_class_generator.dart
└── src
│ ├── checker.dart
│ ├── common.dart
│ ├── gen.dart
│ ├── printer.dart
│ ├── transformer.dart
│ └── visitor.dart
├── pubspec.yaml
└── test
├── printer_test.dart
└── transformer_test.dart
/.gitignore:
--------------------------------------------------------------------------------
1 | # Dart Lib specific
2 | pubspec.lock
3 |
4 | # Miscellaneous
5 | *.class
6 | *.log
7 | *.pyc
8 | *.swp
9 | .DS_Store
10 | .atom/
11 | .buildlog/
12 | .history
13 | .svn/
14 |
15 | # IntelliJ related
16 | *.iml
17 | *.ipr
18 | *.iws
19 | .idea/*
20 | !.idea/codeStyles/
21 | !.idea/runConfigurations/
22 | !.idea/live_templates.jar
23 |
24 | # Visual Studio Code related
25 | .vscode/
26 |
27 | # Flutter/Dart/Pub related
28 | **/doc/api/
29 | .dart_tool/
30 | .flutter-plugins
31 | .packages
32 | .pub-cache/
33 | .pub/
34 | /build/
35 |
36 | # Android related
37 | **/android/**/gradle-wrapper.jar
38 | **/android/.gradle
39 | **/android/captures/
40 | **/android/gradlew
41 | **/android/gradlew.bat
42 | **/android/local.properties
43 | **/android/**/GeneratedPluginRegistrant.java
44 |
45 | # iOS/XCode related
46 | **/ios/**/*.mode1v3
47 | **/ios/**/*.mode2v3
48 | **/ios/**/*.moved-aside
49 | **/ios/**/*.pbxuser
50 | **/ios/**/*.perspectivev3
51 | **/ios/**/*sync/
52 | **/ios/**/.sconsign.dblite
53 | **/ios/**/.tags*
54 | **/ios/**/.vagrant/
55 | **/ios/**/DerivedData/
56 | **/ios/**/Icon?
57 | **/ios/**/Pods/
58 | **/ios/**/.symlinks/
59 | **/ios/**/profile
60 | **/ios/**/xcuserdata
61 | **/ios/.generated/
62 | **/ios/Flutter/App.framework
63 | **/ios/Flutter/Flutter.framework
64 | **/ios/Flutter/Generated.xcconfig
65 | **/ios/Flutter/app.flx
66 | **/ios/Flutter/app.zip
67 | **/ios/Flutter/flutter_assets/
68 | **/ios/ServiceDefinitions.json
69 | **/ios/Runner/GeneratedPluginRegistrant.*
70 |
71 | # Exceptions to above rules.
72 | !**/ios/**/default.mode1v3
73 | !**/ios/**/default.mode2v3
74 | !**/ios/**/default.pbxuser
75 | !**/ios/**/default.perspectivev3
76 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
77 |
78 | # Test files
79 | test/tempfiles
80 | /example/build/
81 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # 3.0.0
2 | * Use if checks so it works for subclasses too
3 |
4 | # 2.0.0
5 | * Add dependency on Dart 2.6
6 |
7 | # 1.0.0
8 | * Initial release
9 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Tim Rijckaert
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Sealed Class Generator
2 |
3 | sealed_class: [](https://pub.dartlang.org/packages/sealed_class)
4 | sealed_class_generator: [](https://pub.dartlang.org/packages/sealed_class_generator)
5 |
6 | Fix Dart's lack of a sealed class.
7 | Inspired by [Kotlin's implementation](https://kotlinlang.org/docs/reference/sealed-classes.html) and by [Sealed Unions](https://pub.dev/packages/sealed_unions).
8 | With this lib you can generate an unlimited amount of sealed subclasses.
9 |
10 | ## Installation
11 |
12 | ```yaml
13 | dependencies:
14 | sealed_class: 2.0.0
15 |
16 | dev_dependencies:
17 | sealed_class_generator: 2.0.0
18 | build_runner: X.X.X
19 | ```
20 |
21 | ## How to use:
22 |
23 | A complete example is found in the [example](https://github.com/timrijckaert/sealed_class_generator/tree/master/example).
24 |
25 | Define your `Sealed` class by annotating it with `@Sealed()`
26 |
27 | ```dart
28 | part 'yourfilename.g.dart';
29 |
30 | @Sealed()
31 | abstract class Result{}
32 | ```
33 |
34 | Add the subclasses to the annotation.
35 |
36 | ```dart
37 | part 'yourfilename.g.dart';
38 |
39 | @Sealed([Failure, Success])
40 | abstract class Result{}
41 | ```
42 |
43 | Your subclasses should implement your sealed class.
44 |
45 | ```dart
46 | @Sealed([Failure, Success])
47 | abstract class Result {}
48 |
49 | class Failure implements Result {
50 | final String errorMessage;
51 |
52 | Failure(this.errorMessage);
53 | }
54 |
55 | class Success implements Result {
56 | final String data;
57 |
58 | Success(this.data);
59 | }
60 | ```
61 |
62 | The complete file should now look like this:
63 |
64 | ````dart
65 | import 'package:sealed_class/sealed_class.dart';
66 |
67 | part 'yourfilename.g.dart';
68 |
69 | @Sealed([Failure, Success])
70 | abstract class Result {}
71 |
72 | class Failure implements Result {
73 | final String errorMessage;
74 |
75 | Failure(this.errorMessage);
76 | }
77 |
78 | class Success implements Result {
79 | final String data;
80 |
81 | Success(this.data);
82 | }
83 | ````
84 |
85 | To make it compile run the following command in the terminal:
86 |
87 | ```shell script
88 | flutter packages pub run build_runner build --delete-conflicting-outputs
89 | ```
90 |
91 | You can do:
92 |
93 | ```dart
94 | void main() {
95 | final someResult = Success("Woohoo Sealed classes in Dart");
96 | someResult.continued(
97 | (failure) {
98 | print("Oh no it failed with errorMessage: ${failure.errorMessage}");
99 | },
100 | (success) {
101 | print(success.data);
102 | },
103 | );
104 |
105 | //Or if you want to reduce it to another value use `join`
106 | final someOtherResult = Failure("Some Error Message");
107 | final mapResult = someOtherResult.join(
108 | (failure) => failure.errorMessage,
109 | (success) => success.data,
110 | );
111 | print(mapResult);
112 | }
113 | ```
114 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | models.g.dart
--------------------------------------------------------------------------------
/example/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 5ab9e70727d858def3a586db7fb98ee580352957
8 | channel: beta
9 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | To run the sample you'll need to run the following generation script:
2 |
3 | ```bash
4 | flutter packages pub run build_runner build --delete-conflicting-outputs
5 | ```
6 |
7 | This sample shows a more practical use case for sealed classes.
8 |
9 | Imagine having a `List` of different data types, all of these items need their own specific UI.
10 | We have 4 different data types:
11 | - `ContainerData`
12 | - `TextData`
13 | - `BoringData`
14 | - `FlutterLogoData`
15 |
16 | Inside the `build` method of the Widget that contains the `List` we could type check each one of them:
17 |
18 | ```dart
19 | class MyHomePage extends StatelessWidget {
20 | MyHomePage({Key key}) : super(key: key);
21 |
22 | @override
23 | Widget build(BuildContext context) {
24 | final repository = Repo();
25 | final rawData = repository.generateRandomData();
26 |
27 | final widgets = rawData.map((data) {
28 | Widget widget;
29 | if (data is ContainerData) {
30 | widget = MyContainer(data);
31 | } else if (data is TextData) {
32 | widget = MyText(data);
33 | } else if (data is BoringData) {
34 | widget = MyBoringWidget(data);
35 | } else if (data is FlutterLogoData) {
36 | widget = MyFlutterLogo(data);
37 | }
38 | return widget;
39 | }).toList(growable: false);
40 |
41 | return Scaffold(
42 | appBar: AppBar(title: Text("Sealed Class Examples")),
43 | body: ListView(children: widgets),
44 | );
45 | }
46 | }
47 | ```
48 |
49 | But what happens if we forget a case?
50 | Dart will happily compile, but it will crash at run time, because you forgot to add a case.
51 |
52 | What if we could catch this error at compilation time?
53 | That's where this library comes in.
54 | You tell Dart all the possible cases and it won't let you forget a case.
55 |
56 | The above code become.
57 |
58 | ```dart
59 | class MyHomePage extends StatelessWidget {
60 | MyHomePage({Key key}) : super(key: key);
61 |
62 | @override
63 | Widget build(BuildContext context) {
64 | final repository = Repo();
65 | final rawData = repository.generateRandomData();
66 | final widgets = rawData
67 | .map(
68 | (data) => data.fold(
69 | mapToContainerDataWidget,
70 | mapToTextDataWidget,
71 | mapToBoringDataWidget,
72 | mapToFlutterLogoWidget,
73 | ),
74 | )
75 | .toList(growable: false);
76 |
77 | return Scaffold(
78 | appBar: AppBar(title: Text("Sealed Class Examples")),
79 | body: ListView(children: widgets),
80 | );
81 | }
82 |
83 | Widget mapToContainerDataWidget(ContainerData data) => MyContainer(data);
84 |
85 | Widget mapToTextDataWidget(TextData data) => MyText(data);
86 |
87 | Widget mapToBoringDataWidget(BoringData data) => MyBoringWidget(data);
88 |
89 | Widget mapToFlutterLogoWidget(FlutterLogoData data) => MyFlutterLogo(data);
90 | }
91 | ```
92 |
--------------------------------------------------------------------------------
/example/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | *.class
3 | .gradle
4 | /local.properties
5 | /.idea/workspace.xml
6 | /.idea/libraries
7 | .DS_Store
8 | /build
9 | /captures
10 | GeneratedPluginRegistrant.java
11 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
26 |
27 | android {
28 | compileSdkVersion 29
29 |
30 | lintOptions {
31 | disable 'InvalidPackage'
32 | }
33 |
34 | defaultConfig {
35 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
36 | applicationId "com.example.example"
37 | minSdkVersion 16
38 | targetSdkVersion 29
39 | versionCode flutterVersionCode.toInteger()
40 | versionName flutterVersionName
41 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
42 | }
43 |
44 | buildTypes {
45 | release {
46 | // TODO: Add your own signing config for the release build.
47 | // Signing with the debug keys for now, so `flutter run --release` works.
48 | signingConfig signingConfigs.debug
49 | }
50 | }
51 | }
52 |
53 | flutter {
54 | source '../..'
55 | }
56 |
57 | dependencies {
58 | testImplementation 'junit:junit:4.12'
59 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
60 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
61 | }
62 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
15 |
19 |
26 |
30 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/example/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.example;
2 |
3 | import android.os.Bundle;
4 | import io.flutter.app.FlutterActivity;
5 | import io.flutter.plugins.GeneratedPluginRegistrant;
6 |
7 | public class MainActivity extends FlutterActivity {
8 | @Override
9 | protected void onCreate(Bundle savedInstanceState) {
10 | super.onCreate(savedInstanceState);
11 | GeneratedPluginRegistrant.registerWith(this);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | google()
4 | jcenter()
5 | }
6 |
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:3.5.1'
9 | }
10 | }
11 |
12 | allprojects {
13 | repositories {
14 | google()
15 | jcenter()
16 | }
17 | }
18 |
19 | rootProject.buildDir = '../build'
20 | subprojects {
21 | project.buildDir = "${rootProject.buildDir}/${project.name}"
22 | }
23 | subprojects {
24 | project.evaluationDependsOn(':app')
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.enableR8=true
3 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
4 |
5 | def plugins = new Properties()
6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7 | if (pluginsFile.exists()) {
8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9 | }
10 |
11 | plugins.each { name, path ->
12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13 | include ":$name"
14 | project(":$name").projectDir = pluginDirectory
15 | }
16 |
--------------------------------------------------------------------------------
/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vagrant/
3 | .sconsign.dblite
4 | .svn/
5 |
6 | .DS_Store
7 | *.swp
8 | profile
9 |
10 | DerivedData/
11 | build/
12 | GeneratedPluginRegistrant.h
13 | GeneratedPluginRegistrant.m
14 |
15 | .generated/
16 |
17 | *.pbxuser
18 | *.mode1v3
19 | *.mode2v3
20 | *.perspectivev3
21 |
22 | !default.pbxuser
23 | !default.mode1v3
24 | !default.mode2v3
25 | !default.perspectivev3
26 |
27 | xcuserdata
28 |
29 | *.moved-aside
30 |
31 | *.pyc
32 | *sync/
33 | Icon?
34 | .tags*
35 |
36 | /Flutter/app.flx
37 | /Flutter/app.zip
38 | /Flutter/flutter_assets/
39 | /Flutter/App.framework
40 | /Flutter/Flutter.framework
41 | /Flutter/Generated.xcconfig
42 | /ServiceDefinitions.json
43 |
44 | Pods/
45 | .symlinks/
46 |
47 | flutter_export_environment.sh
48 |
--------------------------------------------------------------------------------
/example/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 8.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
12 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
13 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
14 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
15 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
16 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
17 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
18 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
19 | 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
20 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
21 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
22 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
23 | /* End PBXBuildFile section */
24 |
25 | /* Begin PBXCopyFilesBuildPhase section */
26 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = {
27 | isa = PBXCopyFilesBuildPhase;
28 | buildActionMask = 2147483647;
29 | dstPath = "";
30 | dstSubfolderSpec = 10;
31 | files = (
32 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
33 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
34 | );
35 | name = "Embed Frameworks";
36 | runOnlyForDeploymentPostprocessing = 0;
37 | };
38 | /* End PBXCopyFilesBuildPhase section */
39 |
40 | /* Begin PBXFileReference section */
41 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
42 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
43 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
44 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
45 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; };
46 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
47 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
48 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
49 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
50 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
51 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; };
52 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
53 | 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
54 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
55 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
56 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
57 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
58 | /* End PBXFileReference section */
59 |
60 | /* Begin PBXFrameworksBuildPhase section */
61 | 97C146EB1CF9000F007C117D /* Frameworks */ = {
62 | isa = PBXFrameworksBuildPhase;
63 | buildActionMask = 2147483647;
64 | files = (
65 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
66 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
67 | );
68 | runOnlyForDeploymentPostprocessing = 0;
69 | };
70 | /* End PBXFrameworksBuildPhase section */
71 |
72 | /* Begin PBXGroup section */
73 | 9740EEB11CF90186004384FC /* Flutter */ = {
74 | isa = PBXGroup;
75 | children = (
76 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
77 | 3B80C3931E831B6300D905FE /* App.framework */,
78 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
79 | 9740EEBA1CF902C7004384FC /* Flutter.framework */,
80 | 9740EEB21CF90195004384FC /* Debug.xcconfig */,
81 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
82 | 9740EEB31CF90195004384FC /* Generated.xcconfig */,
83 | );
84 | name = Flutter;
85 | sourceTree = "";
86 | };
87 | 97C146E51CF9000F007C117D = {
88 | isa = PBXGroup;
89 | children = (
90 | 9740EEB11CF90186004384FC /* Flutter */,
91 | 97C146F01CF9000F007C117D /* Runner */,
92 | 97C146EF1CF9000F007C117D /* Products */,
93 | CF3B75C9A7D2FA2A4C99F110 /* Frameworks */,
94 | );
95 | sourceTree = "";
96 | };
97 | 97C146EF1CF9000F007C117D /* Products */ = {
98 | isa = PBXGroup;
99 | children = (
100 | 97C146EE1CF9000F007C117D /* Runner.app */,
101 | );
102 | name = Products;
103 | sourceTree = "";
104 | };
105 | 97C146F01CF9000F007C117D /* Runner */ = {
106 | isa = PBXGroup;
107 | children = (
108 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
109 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
110 | 97C146FA1CF9000F007C117D /* Main.storyboard */,
111 | 97C146FD1CF9000F007C117D /* Assets.xcassets */,
112 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
113 | 97C147021CF9000F007C117D /* Info.plist */,
114 | 97C146F11CF9000F007C117D /* Supporting Files */,
115 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
116 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
117 | );
118 | path = Runner;
119 | sourceTree = "";
120 | };
121 | 97C146F11CF9000F007C117D /* Supporting Files */ = {
122 | isa = PBXGroup;
123 | children = (
124 | 97C146F21CF9000F007C117D /* main.m */,
125 | );
126 | name = "Supporting Files";
127 | sourceTree = "";
128 | };
129 | /* End PBXGroup section */
130 |
131 | /* Begin PBXNativeTarget section */
132 | 97C146ED1CF9000F007C117D /* Runner */ = {
133 | isa = PBXNativeTarget;
134 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
135 | buildPhases = (
136 | 9740EEB61CF901F6004384FC /* Run Script */,
137 | 97C146EA1CF9000F007C117D /* Sources */,
138 | 97C146EB1CF9000F007C117D /* Frameworks */,
139 | 97C146EC1CF9000F007C117D /* Resources */,
140 | 9705A1C41CF9048500538489 /* Embed Frameworks */,
141 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
142 | );
143 | buildRules = (
144 | );
145 | dependencies = (
146 | );
147 | name = Runner;
148 | productName = Runner;
149 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
150 | productType = "com.apple.product-type.application";
151 | };
152 | /* End PBXNativeTarget section */
153 |
154 | /* Begin PBXProject section */
155 | 97C146E61CF9000F007C117D /* Project object */ = {
156 | isa = PBXProject;
157 | attributes = {
158 | LastUpgradeCheck = 0910;
159 | ORGANIZATIONNAME = "The Chromium Authors";
160 | TargetAttributes = {
161 | 97C146ED1CF9000F007C117D = {
162 | CreatedOnToolsVersion = 7.3.1;
163 | };
164 | };
165 | };
166 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
167 | compatibilityVersion = "Xcode 3.2";
168 | developmentRegion = English;
169 | hasScannedForEncodings = 0;
170 | knownRegions = (
171 | en,
172 | Base,
173 | );
174 | mainGroup = 97C146E51CF9000F007C117D;
175 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
176 | projectDirPath = "";
177 | projectRoot = "";
178 | targets = (
179 | 97C146ED1CF9000F007C117D /* Runner */,
180 | );
181 | };
182 | /* End PBXProject section */
183 |
184 | /* Begin PBXResourcesBuildPhase section */
185 | 97C146EC1CF9000F007C117D /* Resources */ = {
186 | isa = PBXResourcesBuildPhase;
187 | buildActionMask = 2147483647;
188 | files = (
189 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
190 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
191 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
192 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
193 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
194 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
195 | );
196 | runOnlyForDeploymentPostprocessing = 0;
197 | };
198 | /* End PBXResourcesBuildPhase section */
199 |
200 | /* Begin PBXShellScriptBuildPhase section */
201 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
202 | isa = PBXShellScriptBuildPhase;
203 | buildActionMask = 2147483647;
204 | files = (
205 | );
206 | inputPaths = (
207 | );
208 | name = "Thin Binary";
209 | outputPaths = (
210 | );
211 | runOnlyForDeploymentPostprocessing = 0;
212 | shellPath = /bin/sh;
213 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
214 | };
215 | 9740EEB61CF901F6004384FC /* Run Script */ = {
216 | isa = PBXShellScriptBuildPhase;
217 | buildActionMask = 2147483647;
218 | files = (
219 | );
220 | inputPaths = (
221 | );
222 | name = "Run Script";
223 | outputPaths = (
224 | );
225 | runOnlyForDeploymentPostprocessing = 0;
226 | shellPath = /bin/sh;
227 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
228 | };
229 | /* End PBXShellScriptBuildPhase section */
230 |
231 | /* Begin PBXSourcesBuildPhase section */
232 | 97C146EA1CF9000F007C117D /* Sources */ = {
233 | isa = PBXSourcesBuildPhase;
234 | buildActionMask = 2147483647;
235 | files = (
236 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */,
237 | 97C146F31CF9000F007C117D /* main.m in Sources */,
238 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
239 | );
240 | runOnlyForDeploymentPostprocessing = 0;
241 | };
242 | /* End PBXSourcesBuildPhase section */
243 |
244 | /* Begin PBXVariantGroup section */
245 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = {
246 | isa = PBXVariantGroup;
247 | children = (
248 | 97C146FB1CF9000F007C117D /* Base */,
249 | );
250 | name = Main.storyboard;
251 | sourceTree = "";
252 | };
253 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
254 | isa = PBXVariantGroup;
255 | children = (
256 | 97C147001CF9000F007C117D /* Base */,
257 | );
258 | name = LaunchScreen.storyboard;
259 | sourceTree = "";
260 | };
261 | /* End PBXVariantGroup section */
262 |
263 | /* Begin XCBuildConfiguration section */
264 | 97C147031CF9000F007C117D /* Debug */ = {
265 | isa = XCBuildConfiguration;
266 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
267 | buildSettings = {
268 | ALWAYS_SEARCH_USER_PATHS = NO;
269 | CLANG_ANALYZER_NONNULL = YES;
270 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
271 | CLANG_CXX_LIBRARY = "libc++";
272 | CLANG_ENABLE_MODULES = YES;
273 | CLANG_ENABLE_OBJC_ARC = YES;
274 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
275 | CLANG_WARN_BOOL_CONVERSION = YES;
276 | CLANG_WARN_COMMA = YES;
277 | CLANG_WARN_CONSTANT_CONVERSION = YES;
278 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
279 | CLANG_WARN_EMPTY_BODY = YES;
280 | CLANG_WARN_ENUM_CONVERSION = YES;
281 | CLANG_WARN_INFINITE_RECURSION = YES;
282 | CLANG_WARN_INT_CONVERSION = YES;
283 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
284 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
285 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
286 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
287 | CLANG_WARN_STRICT_PROTOTYPES = YES;
288 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
289 | CLANG_WARN_UNREACHABLE_CODE = YES;
290 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
291 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
292 | COPY_PHASE_STRIP = NO;
293 | DEBUG_INFORMATION_FORMAT = dwarf;
294 | ENABLE_STRICT_OBJC_MSGSEND = YES;
295 | ENABLE_TESTABILITY = YES;
296 | GCC_C_LANGUAGE_STANDARD = gnu99;
297 | GCC_DYNAMIC_NO_PIC = NO;
298 | GCC_NO_COMMON_BLOCKS = YES;
299 | GCC_OPTIMIZATION_LEVEL = 0;
300 | GCC_PREPROCESSOR_DEFINITIONS = (
301 | "DEBUG=1",
302 | "$(inherited)",
303 | );
304 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
305 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
306 | GCC_WARN_UNDECLARED_SELECTOR = YES;
307 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
308 | GCC_WARN_UNUSED_FUNCTION = YES;
309 | GCC_WARN_UNUSED_VARIABLE = YES;
310 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
311 | MTL_ENABLE_DEBUG_INFO = YES;
312 | ONLY_ACTIVE_ARCH = YES;
313 | SDKROOT = iphoneos;
314 | TARGETED_DEVICE_FAMILY = "1,2";
315 | };
316 | name = Debug;
317 | };
318 | 97C147041CF9000F007C117D /* Release */ = {
319 | isa = XCBuildConfiguration;
320 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
321 | buildSettings = {
322 | ALWAYS_SEARCH_USER_PATHS = NO;
323 | CLANG_ANALYZER_NONNULL = YES;
324 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
325 | CLANG_CXX_LIBRARY = "libc++";
326 | CLANG_ENABLE_MODULES = YES;
327 | CLANG_ENABLE_OBJC_ARC = YES;
328 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
329 | CLANG_WARN_BOOL_CONVERSION = YES;
330 | CLANG_WARN_COMMA = YES;
331 | CLANG_WARN_CONSTANT_CONVERSION = YES;
332 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
333 | CLANG_WARN_EMPTY_BODY = YES;
334 | CLANG_WARN_ENUM_CONVERSION = YES;
335 | CLANG_WARN_INFINITE_RECURSION = YES;
336 | CLANG_WARN_INT_CONVERSION = YES;
337 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
338 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
339 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
340 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
341 | CLANG_WARN_STRICT_PROTOTYPES = YES;
342 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
343 | CLANG_WARN_UNREACHABLE_CODE = YES;
344 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
345 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
346 | COPY_PHASE_STRIP = NO;
347 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
348 | ENABLE_NS_ASSERTIONS = NO;
349 | ENABLE_STRICT_OBJC_MSGSEND = YES;
350 | GCC_C_LANGUAGE_STANDARD = gnu99;
351 | GCC_NO_COMMON_BLOCKS = YES;
352 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
353 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
354 | GCC_WARN_UNDECLARED_SELECTOR = YES;
355 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
356 | GCC_WARN_UNUSED_FUNCTION = YES;
357 | GCC_WARN_UNUSED_VARIABLE = YES;
358 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
359 | MTL_ENABLE_DEBUG_INFO = NO;
360 | SDKROOT = iphoneos;
361 | TARGETED_DEVICE_FAMILY = "1,2";
362 | VALIDATE_PRODUCT = YES;
363 | };
364 | name = Release;
365 | };
366 | 97C147061CF9000F007C117D /* Debug */ = {
367 | isa = XCBuildConfiguration;
368 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
369 | buildSettings = {
370 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
371 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
372 | ENABLE_BITCODE = NO;
373 | FRAMEWORK_SEARCH_PATHS = (
374 | "$(inherited)",
375 | "$(PROJECT_DIR)/Flutter",
376 | );
377 | INFOPLIST_FILE = Runner/Info.plist;
378 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
379 | LIBRARY_SEARCH_PATHS = (
380 | "$(inherited)",
381 | "$(PROJECT_DIR)/Flutter",
382 | );
383 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example;
384 | PRODUCT_NAME = "$(TARGET_NAME)";
385 | VERSIONING_SYSTEM = "apple-generic";
386 | };
387 | name = Debug;
388 | };
389 | 97C147071CF9000F007C117D /* Release */ = {
390 | isa = XCBuildConfiguration;
391 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
392 | buildSettings = {
393 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
394 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
395 | ENABLE_BITCODE = NO;
396 | FRAMEWORK_SEARCH_PATHS = (
397 | "$(inherited)",
398 | "$(PROJECT_DIR)/Flutter",
399 | );
400 | INFOPLIST_FILE = Runner/Info.plist;
401 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
402 | LIBRARY_SEARCH_PATHS = (
403 | "$(inherited)",
404 | "$(PROJECT_DIR)/Flutter",
405 | );
406 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example;
407 | PRODUCT_NAME = "$(TARGET_NAME)";
408 | VERSIONING_SYSTEM = "apple-generic";
409 | };
410 | name = Release;
411 | };
412 | /* End XCBuildConfiguration section */
413 |
414 | /* Begin XCConfigurationList section */
415 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
416 | isa = XCConfigurationList;
417 | buildConfigurations = (
418 | 97C147031CF9000F007C117D /* Debug */,
419 | 97C147041CF9000F007C117D /* Release */,
420 | );
421 | defaultConfigurationIsVisible = 0;
422 | defaultConfigurationName = Release;
423 | };
424 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
425 | isa = XCConfigurationList;
426 | buildConfigurations = (
427 | 97C147061CF9000F007C117D /* Debug */,
428 | 97C147071CF9000F007C117D /* Release */,
429 | );
430 | defaultConfigurationIsVisible = 0;
431 | defaultConfigurationName = Release;
432 | };
433 | /* End XCConfigurationList section */
434 | };
435 | rootObject = 97C146E61CF9000F007C117D /* Project object */;
436 | }
437 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
40 |
41 |
42 |
43 |
44 |
45 |
56 |
58 |
64 |
65 |
66 |
67 |
68 |
69 |
75 |
77 |
83 |
84 |
85 |
86 |
88 |
89 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : FlutterAppDelegate
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.m:
--------------------------------------------------------------------------------
1 | #include "AppDelegate.h"
2 | #include "GeneratedPluginRegistrant.h"
3 |
4 | @implementation AppDelegate
5 |
6 | - (BOOL)application:(UIApplication *)application
7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
8 | [GeneratedPluginRegistrant registerWithRegistry:self];
9 | // Override point for customization after application launch.
10 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
11 | }
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vrtdev/sealed_class_generator/f2f1c96792802f8d588d70c2b2a8c03db5f8634d/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | 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.
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | example
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(FLUTTER_BUILD_NAME)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/example/ios/Runner/main.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char* argv[]) {
6 | @autoreleasepool {
7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:example/repo.dart';
2 | import 'package:flutter/material.dart';
3 |
4 | import 'models.dart';
5 |
6 | void main() => runApp(MyApp());
7 |
8 | class MyApp extends StatelessWidget {
9 | @override
10 | Widget build(BuildContext context) {
11 | return MaterialApp(
12 | title: 'A practical use case of sealed classes',
13 | theme: ThemeData.dark(),
14 | home: MyHomePage(),
15 | );
16 | }
17 | }
18 |
19 | class MyHomePage extends StatelessWidget {
20 | MyHomePage({Key key}) : super(key: key);
21 |
22 | @override
23 | Widget build(BuildContext context) {
24 | final repository = Repo();
25 | final rawData = repository.generateRandomData();
26 | final widgets = rawData
27 | .map(
28 | (data) => data.join(
29 | mapToContainerDataWidget,
30 | mapToTextDataWidget,
31 | mapToBoringDataWidget,
32 | mapToFlutterLogoWidget,
33 | ),
34 | )
35 | .toList(growable: false);
36 |
37 | return Scaffold(
38 | appBar: AppBar(title: Text("Sealed Class Examples")),
39 | body: ListView(children: widgets),
40 | );
41 | }
42 |
43 | Widget mapToContainerDataWidget(ContainerData data) => MyContainer(data);
44 |
45 | Widget mapToTextDataWidget(TextData data) => MyText(data);
46 |
47 | Widget mapToBoringDataWidget(BoringData data) => MyBoringWidget(data);
48 |
49 | Widget mapToFlutterLogoWidget(FlutterLogoData data) => MyFlutterLogo(data);
50 | }
51 |
52 | //
53 | class MyContainer extends StatelessWidget {
54 | final ContainerData data;
55 |
56 | MyContainer(this.data, {Key key}) : super(key: key);
57 |
58 | @override
59 | Widget build(BuildContext context) =>
60 | Container(height: 50, color: data.color);
61 | }
62 |
63 | class MyText extends StatelessWidget {
64 | final TextData data;
65 |
66 | const MyText(this.data, {Key key}) : super(key: key);
67 |
68 | @override
69 | Widget build(BuildContext context) => Text(data.text);
70 | }
71 |
72 | class MyBoringWidget extends StatelessWidget {
73 | final BoringData data;
74 |
75 | const MyBoringWidget(this.data, {Key key}) : super(key: key);
76 |
77 | @override
78 | Widget build(BuildContext context) =>
79 | SizedBox(child: Placeholder(), height: 50);
80 | }
81 |
82 | class MyFlutterLogo extends StatelessWidget {
83 | final FlutterLogoData data;
84 |
85 | const MyFlutterLogo(this.data, {Key key}) : super(key: key);
86 |
87 | @override
88 | Widget build(BuildContext context) => FlutterLogo(duration: data.duration);
89 | }
90 | //
91 |
--------------------------------------------------------------------------------
/example/lib/models.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ui';
2 |
3 | import 'package:flutter/cupertino.dart';
4 | import 'package:sealed_class/sealed_class.dart';
5 |
6 | part 'models.g.dart';
7 |
8 | @Sealed([
9 | ContainerData,
10 | TextData,
11 | BoringData,
12 | FlutterLogoData,
13 | ])
14 | abstract class Data {}
15 |
16 | class ContainerData implements Data {
17 | final Color color;
18 |
19 | ContainerData(this.color);
20 | }
21 |
22 | class TextData implements Data {
23 | final String text;
24 |
25 | TextData(this.text);
26 | }
27 |
28 | class BoringData implements Data {}
29 |
30 | class FlutterLogoData implements Data {
31 | final Duration duration;
32 |
33 | FlutterLogoData(this.duration);
34 | }
35 |
--------------------------------------------------------------------------------
/example/lib/repo.dart:
--------------------------------------------------------------------------------
1 | import 'dart:math';
2 | import 'dart:ui';
3 |
4 | import 'models.dart';
5 |
6 | class Repo {
7 | static Random _random = Random();
8 | static const _chars = "abcdefghijklmnopqrstuvwxyz";
9 |
10 | List generateRandomData({final int amountOfData = 100}) =>
11 | List.generate(amountOfData, (_) => _random.nextInt(4)).map((it) {
12 | Data d;
13 | switch (it) {
14 | case 0:
15 | d = ContainerData(_randomColor());
16 | break;
17 | case 1:
18 | d = TextData(_randomString());
19 | break;
20 | case 2:
21 | d = BoringData();
22 | break;
23 | case 3:
24 | d = FlutterLogoData(Duration(seconds: 3));
25 | break;
26 | }
27 | return d;
28 | }).toList(growable: false);
29 |
30 | Color _randomColor() =>
31 | Color((_random.nextDouble() * 0xFFFFFF).toInt() << 0).withOpacity(1.0);
32 |
33 | String _randomString({final int strLength = 100}) {
34 | String result = "";
35 | for (var i = 0; i < strLength; i++) {
36 | result += _chars[_random.nextInt(_chars.length)];
37 | }
38 | return result;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: example
2 | description: A project used to demo the sealed class generator
3 | version: 1.0.0+1
4 |
5 | environment:
6 | sdk: ">=2.6.0 <3.0.0"
7 |
8 | dependencies:
9 | flutter:
10 | sdk: flutter
11 | sealed_class:
12 | path: ../sealed_class/
13 |
14 | dev_dependencies:
15 | build_runner: ^1.7.1
16 | flutter_test:
17 | sdk: flutter
18 | sealed_class_generator:
19 | path: ../sealed_class_generator/
20 |
21 | flutter:
22 | uses-material-design: true
--------------------------------------------------------------------------------
/sealed_class/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Tim Rijckaert
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/sealed_class/README.md:
--------------------------------------------------------------------------------
1 | # Sealed Class Generator
2 |
3 | sealed_class: [](https://pub.dartlang.org/packages/sealed_class)
4 | sealed_class_generator: [](https://pub.dartlang.org/packages/sealed_class_generator)
5 |
6 | Fix Dart's lack of a sealed class.
7 | Inspired by [Kotlin's implementation](https://kotlinlang.org/docs/reference/sealed-classes.html) and by [Sealed Unions](https://pub.dev/packages/sealed_unions).
8 | With this lib you can generate an unlimited amount of sealed subclasses.
9 |
10 | ## Installation
11 |
12 | ```yaml
13 | dependencies:
14 | sealed_class: 3.0.0
15 |
16 | dev_dependencies:
17 | sealed_class_generator: 3.0.0
18 | build_runner: X.X.X
19 | ```
20 |
21 | ## How to use:
22 |
23 | A complete example is found in the [example](https://github.com/timrijckaert/sealed_class_generator/tree/master/example).
24 |
25 | Define your `Sealed` class by annotating it with `@Sealed()`
26 |
27 | ```dart
28 | part 'yourfilename.g.dart';
29 |
30 | @Sealed()
31 | abstract class Result{}
32 | ```
33 |
34 | Add the subclasses to the annotation.
35 |
36 | ```dart
37 | part 'yourfilename.g.dart';
38 |
39 | @Sealed([Failure, Success])
40 | abstract class Result{}
41 | ```
42 |
43 | Your subclasses should implement your sealed class.
44 |
45 | ```dart
46 | @Sealed([Failure, Success])
47 | abstract class Result {}
48 |
49 | class Failure implements Result {
50 | final String errorMessage;
51 |
52 | Failure(this.errorMessage);
53 | }
54 |
55 | class Success implements Result {
56 | final String data;
57 |
58 | Success(this.data);
59 | }
60 | ```
61 |
62 | The complete file should now look like this:
63 |
64 | ````dart
65 | import 'package:sealed_class/sealed_class.dart';
66 |
67 | part 'yourfilename.g.dart';
68 |
69 | @Sealed([Failure, Success])
70 | abstract class Result {}
71 |
72 | class Failure implements Result {
73 | final String errorMessage;
74 |
75 | Failure(this.errorMessage);
76 | }
77 |
78 | class Success implements Result {
79 | final String data;
80 |
81 | Success(this.data);
82 | }
83 | ````
84 |
85 | To make it compile run the following command in the terminal:
86 |
87 | ```shell script
88 | flutter packages pub run build_runner build --delete-conflicting-outputs
89 | ```
90 |
91 | You can do:
92 |
93 | ```dart
94 | void main() {
95 | final someResult = Success("Woohoo Sealed classes in Dart");
96 | someResult.continued(
97 | (failure) {
98 | print("Oh no it failed with errorMessage: ${failure.errorMessage}");
99 | },
100 | (success) {
101 | print(success.data);
102 | },
103 | );
104 |
105 | //Or if you want to reduce it to another value use `join`
106 | final someOtherResult = Failure("Some Error Message");
107 | final mapResult = someOtherResult.join(
108 | (failure) => failure.errorMessage,
109 | (success) => success.data,
110 | );
111 | print(mapResult);
112 | }
113 | ```
114 |
--------------------------------------------------------------------------------
/sealed_class/lib/sealed_class.dart:
--------------------------------------------------------------------------------
1 | library sealed_class;
2 |
3 | export 'src/sealed.dart';
4 |
--------------------------------------------------------------------------------
/sealed_class/lib/src/sealed.dart:
--------------------------------------------------------------------------------
1 | class Sealed {
2 | final List types;
3 |
4 | const Sealed(this.types);
5 | }
6 |
--------------------------------------------------------------------------------
/sealed_class/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: sealed_class
2 | description: Make a sealed class hierarchy
3 | version: 3.0.0
4 | homepage: https://github.com/vrtdev/sealed_class_generator
5 | repository: https://github.com/vrtdev/sealed_class_generator
6 | issue_tracker: https://github.com/vrtdev/sealed_class_generator/issues
7 |
8 | environment:
9 | sdk: ">=2.6.0 <3.0.0"
10 |
11 | dev_dependencies:
12 | test: ^1.9.3
--------------------------------------------------------------------------------
/sealed_class/test/sealed_class_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:test/test.dart';
2 |
3 | import 'package:sealed_class/sealed_class.dart';
4 |
5 | void main() {
6 | }
7 |
--------------------------------------------------------------------------------
/sealed_class_generator/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Tim Rijckaert
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/sealed_class_generator/README.md:
--------------------------------------------------------------------------------
1 | # Sealed Class Generator
2 |
3 | sealed_class: [](https://pub.dartlang.org/packages/sealed_class)
4 | sealed_class_generator: [](https://pub.dartlang.org/packages/sealed_class_generator)
5 |
6 | Fix Dart's lack of a sealed class.
7 | Inspired by [Kotlin's implementation](https://kotlinlang.org/docs/reference/sealed-classes.html) and by [Sealed Unions](https://pub.dev/packages/sealed_unions).
8 | With this lib you can generate an unlimited amount of sealed subclasses.
9 |
10 | ## Installation
11 |
12 | ```yaml
13 | dependencies:
14 | sealed_class: 3.0.0
15 |
16 | dev_dependencies:
17 | sealed_class_generator: 3.0.0
18 | build_runner: X.X.X
19 | ```
20 |
21 | ## How to use:
22 |
23 | A complete example is found in the [example](https://github.com/timrijckaert/sealed_class_generator/tree/master/example).
24 |
25 | Define your `Sealed` class by annotating it with `@Sealed()`
26 |
27 | ```dart
28 | part 'yourfilename.g.dart';
29 |
30 | @Sealed()
31 | abstract class Result{}
32 | ```
33 |
34 | Add the subclasses to the annotation.
35 |
36 | ```dart
37 | part 'yourfilename.g.dart';
38 |
39 | @Sealed([Failure, Success])
40 | abstract class Result{}
41 | ```
42 |
43 | Your subclasses should implement your sealed class.
44 |
45 | ```dart
46 | @Sealed([Failure, Success])
47 | abstract class Result {}
48 |
49 | class Failure implements Result {
50 | final String errorMessage;
51 |
52 | Failure(this.errorMessage);
53 | }
54 |
55 | class Success implements Result {
56 | final String data;
57 |
58 | Success(this.data);
59 | }
60 | ```
61 |
62 | The complete file should now look like this:
63 |
64 | ````dart
65 | import 'package:sealed_class/sealed_class.dart';
66 |
67 | part 'yourfilename.g.dart';
68 |
69 | @Sealed([Failure, Success])
70 | abstract class Result {}
71 |
72 | class Failure implements Result {
73 | final String errorMessage;
74 |
75 | Failure(this.errorMessage);
76 | }
77 |
78 | class Success implements Result {
79 | final String data;
80 |
81 | Success(this.data);
82 | }
83 | ````
84 |
85 | To make it compile run the following command in the terminal:
86 |
87 | ```shell script
88 | flutter packages pub run build_runner build --delete-conflicting-outputs
89 | ```
90 |
91 | You can do:
92 |
93 | ```dart
94 | void main() {
95 | final someResult = Success("Woohoo Sealed classes in Dart");
96 | someResult.continued(
97 | (failure) {
98 | print("Oh no it failed with errorMessage: ${failure.errorMessage}");
99 | },
100 | (success) {
101 | print(success.data);
102 | },
103 | );
104 |
105 | //Or if you want to reduce it to another value use `join`
106 | final someOtherResult = Failure("Some Error Message");
107 | final mapResult = someOtherResult.join(
108 | (failure) => failure.errorMessage,
109 | (success) => success.data,
110 | );
111 | print(mapResult);
112 | }
113 | ```
114 |
--------------------------------------------------------------------------------
/sealed_class_generator/build.yaml:
--------------------------------------------------------------------------------
1 | targets:
2 | $default:
3 | builders:
4 | sealed_class_generator|sealed_class:
5 | enabled: true
6 |
7 | builders:
8 | sealed_class:
9 | target: ":sealed_class_generator"
10 | import: "package:sealed_class_generator/sealed_class_generator.dart"
11 | builder_factories: ["sealedClassBuilder"]
12 | build_extensions: {".dart": [".sealed_class.g.part"]}
13 | auto_apply: dependents
14 | build_to: cache
15 | applies_builders: ["source_gen|combining_builder"]
--------------------------------------------------------------------------------
/sealed_class_generator/lib/sealed_class_generator.dart:
--------------------------------------------------------------------------------
1 | import 'package:build/build.dart';
2 | import 'package:sealed_class_generator/src/gen.dart';
3 | import 'package:source_gen/source_gen.dart';
4 |
5 | Builder sealedClassBuilder(BuilderOptions options) =>
6 | SharedPartBuilder([SealedGenerator()], 'sealed_gen');
7 |
--------------------------------------------------------------------------------
/sealed_class_generator/lib/src/checker.dart:
--------------------------------------------------------------------------------
1 | class Checker {
2 | static void checkInputValidity(
3 | String className,
4 | List typeParams,
5 | ) {
6 | if ((className?.isEmpty ?? true) == true) {
7 | throw "Could not determine the `className.`";
8 | }
9 |
10 | if (typeParams.isEmpty || typeParams.length <= 1) {
11 | throw "You should have more than one type parameter.";
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/sealed_class_generator/lib/src/common.dart:
--------------------------------------------------------------------------------
1 | const typeParam = "R";
2 |
--------------------------------------------------------------------------------
/sealed_class_generator/lib/src/gen.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 |
3 | import 'package:analyzer/dart/element/element.dart';
4 | import 'package:build/build.dart';
5 | import 'package:sealed_class/sealed_class.dart';
6 | import 'package:source_gen/source_gen.dart';
7 |
8 | import 'checker.dart';
9 | import 'printer.dart';
10 | import 'transformer.dart';
11 | import 'visitor.dart';
12 |
13 | class SealedGenerator extends GeneratorForAnnotation {
14 | @override
15 | FutureOr generateForAnnotatedElement(
16 | Element element,
17 | ConstantReader annotation,
18 | BuildStep buildStep,
19 | ) {
20 | final typeParams = annotation.objectValue
21 | .getField("types")
22 | .toListValue()
23 | .map((dartObj) => dartObj.toTypeValue())
24 | .map((type) => type.name)
25 | .toList();
26 |
27 | final visitor = SealedClassVisitor();
28 | element.visitChildren(visitor);
29 |
30 | Checker.checkInputValidity(visitor.className, typeParams);
31 |
32 | final typeParameterData =
33 | TypeParameterTransformer.toGeneratedCodeData(typeParams);
34 | final printerOutput =
35 | Printer.constructOutput(visitor.className, typeParameterData);
36 |
37 | return printerOutput.toString();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/sealed_class_generator/lib/src/printer.dart:
--------------------------------------------------------------------------------
1 | import 'common.dart';
2 | import 'transformer.dart';
3 |
4 | class PrinterOutput {
5 | final String _sealedClassName;
6 | final String _continuedStatement;
7 | final String _joinStatement;
8 |
9 | PrinterOutput(
10 | this._sealedClassName,
11 | this._continuedStatement,
12 | this._joinStatement,
13 | );
14 |
15 | @override
16 | String toString() => (StringBuffer()
17 | ..writeln("extension ${_sealedClassName}Ext on $_sealedClassName {")
18 | ..writeln(_continuedStatement)
19 | ..writeln(_joinStatement)
20 | ..writeln("}"))
21 | .toString();
22 | }
23 |
24 | class Printer {
25 | static const _continuedMethodName = "continued";
26 | static const _joinMethodName = "join";
27 |
28 | Printer._();
29 |
30 | static PrinterOutput constructOutput(
31 | final String className,
32 | final Iterable typeParamData,
33 | ) {
34 | String continuedStatement(final Iterable typeParamData) {
35 | String continuedTypeCheckStatement(
36 | final Iterable typeParamData) {
37 | final caseBuffer = StringBuffer();
38 | typeParamData.forEach((it) {
39 | caseBuffer
40 | ..writeln("if (this is ${it.type}) {")
41 | ..writeln(it.continuedFunction)
42 | ..writeln("}");
43 | });
44 | return caseBuffer.toString();
45 | }
46 |
47 | return (StringBuffer()
48 | ..write("void $_continuedMethodName(")
49 | ..writeln()
50 | ..writeln(typeParamData
51 | .map((it) => it.continuedFunctionDeclaration)
52 | .join(",\n"))
53 | ..writeln(",) {")
54 | ..writeln(continuedTypeCheckStatement(typeParamData))
55 | ..writeln("}"))
56 | .toString();
57 | }
58 |
59 | String joinStatement(final Iterable typeParamData) {
60 | String joinTypeCheckStatement(
61 | final Iterable typeParamData) {
62 | final caseBuffer = StringBuffer();
63 | typeParamData.forEach((it) {
64 | caseBuffer
65 | ..writeln("if (this is ${it.type}) {")
66 | ..writeln("r = ${it.joinFunction}")
67 | ..writeln("}");
68 | });
69 | return caseBuffer.toString();
70 | }
71 |
72 | return (StringBuffer()
73 | ..write("$typeParam $_joinMethodName<$typeParam>(")
74 | ..writeln()
75 | ..writeln(typeParamData
76 | .map((it) => it.joinFunctionDeclaration)
77 | .join(",\n"))
78 | ..writeln(",) {")
79 | ..writeln("$typeParam ${typeParam.toLowerCase()};")
80 | ..writeln(joinTypeCheckStatement(typeParamData))
81 | ..writeln("return ${typeParam.toLowerCase()};")
82 | ..writeln("}"))
83 | .toString();
84 | }
85 |
86 | return PrinterOutput(
87 | className,
88 | continuedStatement(typeParamData),
89 | joinStatement(typeParamData),
90 | );
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/sealed_class_generator/lib/src/transformer.dart:
--------------------------------------------------------------------------------
1 | import 'common.dart';
2 |
3 | class GeneratedCodeData {
4 | static const continuedMethodName = "continuation";
5 | static const joinMethodName = "join";
6 |
7 | final String type;
8 |
9 | final String continuedFunction;
10 | final String continuedFunctionDeclaration;
11 |
12 | final String joinFunction;
13 | final String joinFunctionDeclaration;
14 |
15 | GeneratedCodeData(this.type)
16 | : continuedFunction = "$continuedMethodName$type(this);",
17 | continuedFunctionDeclaration =
18 | "Function($type) $continuedMethodName$type",
19 | joinFunction = "$joinMethodName$type(this);",
20 | joinFunctionDeclaration =
21 | "$typeParam Function($type) $joinMethodName$type";
22 | }
23 |
24 | class TypeParameterTransformer {
25 | TypeParameterTransformer._();
26 |
27 | static List toGeneratedCodeData(final List typeParameters) =>
28 | typeParameters.map((it) => GeneratedCodeData(it)).toList(growable: false);
29 | }
30 |
--------------------------------------------------------------------------------
/sealed_class_generator/lib/src/visitor.dart:
--------------------------------------------------------------------------------
1 | import 'package:analyzer/dart/element/element.dart';
2 | import 'package:analyzer/dart/element/visitor.dart';
3 |
4 | class SealedClassVisitor extends SimpleElementVisitor {
5 | String className = null;
6 |
7 | @override
8 | visitConstructorElement(ConstructorElement element) =>
9 | className = element.type.returnType.name;
10 | }
11 |
--------------------------------------------------------------------------------
/sealed_class_generator/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: sealed_class_generator
2 | description: Sealed Class generator parses and generates your sealed classes.
3 | version: 3.0.0
4 | homepage: https://github.com/vrtdev/sealed_class_generator
5 | repository: https://github.com/vrtdev/sealed_class_generator
6 | issue_tracker: https://github.com/vrtdev/sealed_class_generator/issues
7 |
8 | environment:
9 | sdk: ">=2.6.0 <3.0.0"
10 |
11 | dependencies:
12 | analyzer: ^0.39.1
13 | build: ^1.2.1
14 | source_gen: ^0.9.4+6
15 | sealed_class:
16 | path: ../sealed_class
17 |
18 | dev_dependencies:
19 | build_test: ^0.10.9+1
20 | build_runner: ^1.7.1
21 | test: ^1.9.3
22 |
23 | dependency_overrides:
24 | sealed_class:
25 | path: ../sealed_class/
26 |
--------------------------------------------------------------------------------
/sealed_class_generator/test/printer_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:sealed_class_generator/src/printer.dart';
2 | import 'package:sealed_class_generator/src/transformer.dart';
3 | import 'package:test/test.dart';
4 |
5 | void main() {
6 | group("Printer", () {
7 | final printerOutput = Printer.constructOutput(
8 | "MySealedClass",
9 | [
10 | GeneratedCodeData("A"),
11 | GeneratedCodeData("B"),
12 | ],
13 | );
14 |
15 | group("complete output", () {
16 | test("should match", () {
17 | expect(
18 | printerOutput.toString(),
19 | """
20 | extension MySealedClassExt on MySealedClass {
21 | void continued(
22 | Function(A) continuationA,
23 | Function(B) continuationB
24 | ,) {
25 | if (this is A) {
26 | continuationA(this);
27 | }
28 | if (this is B) {
29 | continuationB(this);
30 | }
31 |
32 | }
33 |
34 | R join(
35 | R Function(A) joinA,
36 | R Function(B) joinB
37 | ,) {
38 | R r;
39 | if (this is A) {
40 | r = joinA(this);
41 | }
42 | if (this is B) {
43 | r = joinB(this);
44 | }
45 |
46 | return r;
47 | }
48 |
49 | }
50 | """,
51 | );
52 | });
53 | });
54 | });
55 | }
56 |
--------------------------------------------------------------------------------
/sealed_class_generator/test/transformer_test.dart:
--------------------------------------------------------------------------------
1 | import 'package:sealed_class_generator/src/transformer.dart';
2 | import 'package:test/test.dart';
3 |
4 | void main() {
5 | group("Type Parameter Transformer", () {
6 | group("to generated code data", () {
7 | final generatedCodeData =
8 | TypeParameterTransformer.toGeneratedCodeData(["A"]).first;
9 |
10 | group("continued function", () {
11 | test("should have the correct continued function", () {
12 | expect(generatedCodeData.continuedFunction, "continuationA(this);");
13 | });
14 |
15 | test("should have the correct continued function declaration", () {
16 | expect(generatedCodeData.continuedFunctionDeclaration,
17 | "Function(A) continuationA");
18 | });
19 | });
20 |
21 | group("folding function", () {
22 | test("should have the correct fold function", () {
23 | expect(generatedCodeData.joinFunction, "mapA(this);");
24 | });
25 |
26 | test("should have the correct fold function declaration", () {
27 | expect(
28 | generatedCodeData.joinFunctionDeclaration, "R Function(A) mapA");
29 | });
30 | });
31 | });
32 | });
33 | }
34 |
--------------------------------------------------------------------------------