├── android ├── gradle.properties ├── app │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── 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 │ │ │ │ └── drawable │ │ │ │ │ └── launch_background.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── flutter_aws_app │ │ │ │ │ └── MainActivity.kt │ │ │ └── AndroidManifest.xml │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ └── profile │ │ │ └── AndroidManifest.xml │ └── build.gradle ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── settings.gradle └── build.gradle ├── ios ├── Flutter │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── AppFrameworkInfo.plist ├── Runner │ ├── Runner-Bridging-Header.h │ ├── Assets.xcassets │ │ ├── LaunchImage.imageset │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ ├── README.md │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ ├── 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-1024x1024@1x.png │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ └── Contents.json │ ├── AppDelegate.swift │ ├── Info.plist │ └── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard ├── Runner.xcworkspace │ └── contents.xcworkspacedata └── Runner.xcodeproj │ ├── project.xcworkspace │ └── contents.xcworkspacedata │ ├── xcshareddata │ └── xcschemes │ │ └── Runner.xcscheme │ └── project.pbxproj ├── lib ├── models │ ├── models.dart │ ├── pet.dart │ ├── query.dart │ ├── serializers.dart │ ├── serializers.g.dart │ ├── pet.g.dart │ └── query.g.dart ├── packages │ ├── repository.dart │ ├── query_repository.dart │ ├── repository_provider.dart │ ├── repository_provider_tree.dart │ ├── query_provider.dart │ └── sig_v4.dart ├── home │ ├── home.dart │ ├── home_events.dart │ ├── home_states.dart │ ├── home_bloc.dart │ ├── home_events.g.dart │ ├── home_states.g.dart │ └── home_page.dart ├── identity │ ├── identity.dart │ ├── identity_signout_page.dart │ ├── identity_signin_page.dart │ └── identity_repository.dart ├── authentication │ ├── authentication.dart │ ├── authentication_events.dart │ ├── authentication_states.dart │ ├── authentication_tokens.dart │ ├── authentication_credentials.dart │ ├── authentication_bloc.dart │ ├── authentication_states.g.dart │ └── authentication_events.g.dart └── main.dart ├── .metadata ├── test └── widget_test.dart ├── README.md ├── .gitignore ├── pubspec.yaml └── pubspec.lock /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" -------------------------------------------------------------------------------- /lib/models/models.dart: -------------------------------------------------------------------------------- 1 | export 'serializers.dart'; 2 | export 'pet.dart'; 3 | export 'query.dart'; 4 | -------------------------------------------------------------------------------- /lib/packages/repository.dart: -------------------------------------------------------------------------------- 1 | export 'repository_provider.dart'; 2 | export 'repository_provider_tree.dart'; -------------------------------------------------------------------------------- /lib/home/home.dart: -------------------------------------------------------------------------------- 1 | export 'home_bloc.dart'; 2 | export 'home_events.dart'; 3 | export 'home_states.dart'; 4 | export 'home_page.dart'; -------------------------------------------------------------------------------- /lib/identity/identity.dart: -------------------------------------------------------------------------------- 1 | export 'identity_repository.dart'; 2 | export 'identity_signin_page.dart'; 3 | export 'identity_signout_page.dart'; -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BerndWessels/flutter_aws_app/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /lib/authentication/authentication.dart: -------------------------------------------------------------------------------- 1 | export 'authentication_bloc.dart'; 2 | export 'authentication_events.dart'; 3 | export 'authentication_states.dart'; 4 | export 'authentication_tokens.dart'; 5 | export 'authentication_credentials.dart'; 6 | -------------------------------------------------------------------------------- /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-4.10.2-all.zip 7 | -------------------------------------------------------------------------------- /.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: 8661d8aecd626f7f57ccbcb735553edc05a2e713 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/flutter_aws_app/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.flutter_aws_app 2 | 3 | import android.os.Bundle 4 | 5 | import io.flutter.app.FlutterActivity 6 | import io.flutter.plugins.GeneratedPluginRegistrant 7 | 8 | class MainActivity: FlutterActivity() { 9 | override fun onCreate(savedInstanceState: Bundle?) { 10 | super.onCreate(savedInstanceState) 11 | GeneratedPluginRegistrant.registerWith(this) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/models/pet.dart: -------------------------------------------------------------------------------- 1 | import 'package:built_collection/built_collection.dart'; 2 | import 'package:built_value/built_value.dart'; 3 | import 'package:built_value/serializer.dart'; 4 | 5 | part 'pet.g.dart'; 6 | 7 | abstract class Pet implements Built { 8 | static Serializer get serializer => _$petSerializer; 9 | 10 | Pet._(); 11 | 12 | factory Pet([void Function(PetBuilder) updates]) = _$Pet; 13 | 14 | String get id; 15 | 16 | String get type; 17 | 18 | double get price; 19 | } 20 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter_test/flutter_test.dart'; 9 | 10 | void main() { 11 | testWidgets('Counter increments smoke test', (WidgetTester tester) async {}); 12 | } 13 | -------------------------------------------------------------------------------- /lib/models/query.dart: -------------------------------------------------------------------------------- 1 | import 'package:built_collection/built_collection.dart'; 2 | import 'package:built_value/built_value.dart'; 3 | import 'package:built_value/serializer.dart'; 4 | 5 | import 'models.dart'; 6 | 7 | part 'query.g.dart'; 8 | 9 | abstract class Query implements Built { 10 | static Serializer get serializer => _$querySerializer; 11 | 12 | Query._(); 13 | 14 | factory Query([void Function(QueryBuilder) updates]) = _$Query; 15 | 16 | @nullable 17 | Pet get getPet; 18 | 19 | @nullable 20 | BuiltList get listPets; 21 | } 22 | -------------------------------------------------------------------------------- /lib/home/home_events.dart: -------------------------------------------------------------------------------- 1 | import 'package:built_value/built_value.dart'; 2 | 3 | part 'home_events.g.dart'; 4 | 5 | abstract class HomeEvent {} 6 | 7 | abstract class Fetch implements Built, HomeEvent { 8 | Fetch._(); 9 | 10 | factory Fetch([void Function(FetchBuilder) updates]) = _$Fetch; 11 | 12 | String get operationName; 13 | 14 | String get query; 15 | } 16 | 17 | abstract class Initialize 18 | implements Built, HomeEvent { 19 | Initialize._(); 20 | 21 | factory Initialize([void Function(InitializeBuilder) updates]) = _$Initialize; 22 | } 23 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.2.71' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.2.1' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /lib/models/serializers.dart: -------------------------------------------------------------------------------- 1 | import 'package:built_collection/built_collection.dart'; 2 | import 'package:built_value/serializer.dart'; 3 | import 'package:built_value/standard_json_plugin.dart'; 4 | import 'package:flutter_aws_app/models/models.dart'; 5 | 6 | part 'serializers.g.dart'; 7 | 8 | @SerializersFor([ 9 | Query, 10 | Pet, 11 | ]) 12 | final Serializers serializers = _$serializers; 13 | 14 | //final Serializers serializers = (_$serializers.toBuilder() 15 | // ..addBuilderFactory( 16 | // const FullType(BuiltList, const [const FullType(Pet)]), 17 | // () => new ListBuilder())) 18 | // .build(); 19 | 20 | final standardSerializers = 21 | (serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build(); 22 | -------------------------------------------------------------------------------- /lib/home/home_states.dart: -------------------------------------------------------------------------------- 1 | import 'package:built_value/built_value.dart'; 2 | 3 | part 'home_states.g.dart'; 4 | 5 | abstract class HomeState {} 6 | 7 | abstract class HomeInitial 8 | implements Built, HomeState { 9 | HomeInitial._(); 10 | 11 | factory HomeInitial([void Function(HomeInitialBuilder) updates]) = 12 | _$HomeInitial; 13 | } 14 | 15 | abstract class HomeSuccess 16 | implements Built, HomeState { 17 | HomeSuccess._(); 18 | 19 | factory HomeSuccess([void Function(HomeSuccessBuilder) updates]) = 20 | _$HomeSuccess; 21 | } 22 | 23 | abstract class HomeLoading 24 | implements Built, HomeState { 25 | HomeLoading._(); 26 | 27 | factory HomeLoading([void Function(HomeLoadingBuilder) updates]) = 28 | _$HomeLoading; 29 | } 30 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/authentication/authentication_events.dart: -------------------------------------------------------------------------------- 1 | import 'package:built_value/built_value.dart'; 2 | 3 | part 'authentication_events.g.dart'; 4 | 5 | abstract class AuthenticationEvent {} 6 | 7 | abstract class AppStarted 8 | implements Built, AuthenticationEvent { 9 | AppStarted._(); 10 | 11 | factory AppStarted([void Function(AppStartedBuilder) updates]) = _$AppStarted; 12 | } 13 | 14 | abstract class Authenticate 15 | implements Built, AuthenticationEvent { 16 | Authenticate._(); 17 | 18 | factory Authenticate([void Function(AuthenticateBuilder) updates]) = 19 | _$Authenticate; 20 | 21 | String get code; 22 | } 23 | 24 | abstract class SignOut 25 | implements Built, AuthenticationEvent { 26 | SignOut._(); 27 | 28 | factory SignOut([void Function(SignOutBuilder) updates]) = _$SignOut; 29 | } 30 | -------------------------------------------------------------------------------- /lib/models/serializers.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'serializers.dart'; 4 | 5 | // ************************************************************************** 6 | // BuiltValueGenerator 7 | // ************************************************************************** 8 | 9 | Serializers _$serializers = (new Serializers().toBuilder() 10 | ..add(Pet.serializer) 11 | ..add(Query.serializer) 12 | ..addBuilderFactory( 13 | const FullType(BuiltList, const [const FullType(Pet)]), 14 | () => new ListBuilder())) 15 | .build(); 16 | 17 | // ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new 18 | -------------------------------------------------------------------------------- /lib/authentication/authentication_states.dart: -------------------------------------------------------------------------------- 1 | import 'package:built_value/built_value.dart'; 2 | 3 | part 'authentication_states.g.dart'; 4 | 5 | abstract class AuthenticationState {} 6 | 7 | abstract class Authenticated 8 | implements Built, AuthenticationState { 9 | Authenticated._(); 10 | 11 | factory Authenticated([void Function(AuthenticatedBuilder) updates]) = 12 | _$Authenticated; 13 | } 14 | 15 | abstract class Unauthenticated 16 | implements 17 | Built, 18 | AuthenticationState { 19 | Unauthenticated._(); 20 | 21 | factory Unauthenticated([void Function(UnauthenticatedBuilder) updates]) = 22 | _$Unauthenticated; 23 | } 24 | 25 | abstract class Uninitialized 26 | implements Built, AuthenticationState { 27 | Uninitialized._(); 28 | 29 | factory Uninitialized([void Function(UninitializedBuilder) updates]) = 30 | _$Uninitialized; 31 | } 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # flutter_aws_app 2 | 3 | A simple Flutter example app showing how to use 4 | - AWS Cognito User Management 5 | - AWS AppSync GraphQL API 6 | with Flutter 7 | 8 | This Example uses the AWS Cognito hosted UI to manage all users including federated identities 9 | within the Cognito User Pool. 10 | 11 | It is still using a Cognito Identity Pool to get IAM access credentials. 12 | 13 | To get a better understanding checkout the following links. 14 | 15 | ## More Details 16 | 17 | - [BFF Back-End for Front-End Architecture](https://medium.com/@wesselsbernd/bff-back-end-for-front-end-architecture-as-of-may-2019-5d09b913a8ed) 18 | - [Some AWS Cognito & AppSync Details](https://medium.com/@wesselsbernd/some-aws-cognito-appsync-details-as-of-may-2019-247c8531f600) 19 | - [Flutter and AWS](https://medium.com/@wesselsbernd/flutter-and-aws-as-of-march-2019-1ad7f40fa9e4) 20 | 21 | ## Changelog 22 | 23 | ### 2019 / 05 / 31 24 | - Cleanup 25 | - Better organized into blocs, repositories and providers 26 | - Now using BuiltValue and BuiltCollection 27 | -------------------------------------------------------------------------------- /lib/authentication/authentication_tokens.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | class AuthenticationTokens { 4 | final String accessToken; 5 | final String refreshToken; 6 | final String idToken; 7 | final DateTime expiryDateTime; 8 | 9 | AuthenticationTokens({ 10 | this.accessToken, 11 | this.expiryDateTime, 12 | this.idToken, 13 | this.refreshToken, 14 | }); 15 | 16 | factory AuthenticationTokens.fromJson(String json) { 17 | Map data = jsonDecode(json, reviver: (key, value) { 18 | return key == "expiryDateTime" ? DateTime.parse(value) : value; 19 | }); 20 | return AuthenticationTokens( 21 | accessToken: data["accessToken"], 22 | refreshToken: data["refreshToken"], 23 | idToken: data["idToken"], 24 | expiryDateTime: data["expiryDateTime"], 25 | ); 26 | } 27 | 28 | String toJson() { 29 | return jsonEncode({ 30 | "accessToken": accessToken, 31 | "refreshToken": refreshToken, 32 | "idToken": idToken, 33 | "expiryDateTime": expiryDateTime.toIso8601String() 34 | }); 35 | } 36 | 37 | bool get hasExpired => DateTime.now().isAfter(expiryDateTime); 38 | } 39 | -------------------------------------------------------------------------------- /lib/home/home_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:flutter_aws_app/home/home.dart'; 3 | import 'package:flutter_aws_app/packages/query_repository.dart'; 4 | import 'package:meta/meta.dart'; 5 | 6 | class HomeBloc extends Bloc { 7 | final QueryRepository queryRepository; 8 | 9 | HomeBloc({@required this.queryRepository}) : assert(queryRepository != null); 10 | 11 | @override 12 | HomeState get initialState => HomeInitial(); 13 | 14 | @override 15 | Stream mapEventToState( 16 | HomeEvent event, 17 | ) async* { 18 | if (event is Initialize) { 19 | yield HomeLoading(); 20 | var response = await queryRepository.query( 21 | """ 22 | listPets { 23 | id 24 | price 25 | type 26 | } 27 | """, 28 | retryCount: 2, 29 | ); // , cache , retry , pollingInterval 30 | var response2 = response.rebuild((b) => b..listPets[0] = b.listPets[0].rebuild((b) => b..price += 10)); 31 | print(response); 32 | print(response2); // now this should be the new value in the cache ?!?!?!?! 33 | yield HomeSuccess(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/authentication/authentication_credentials.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | class AuthenticationCredentials { 4 | final String accessKeyId; 5 | final String secretKey; 6 | final String sessionToken; 7 | final DateTime expiryDateTime; 8 | 9 | AuthenticationCredentials({ 10 | this.accessKeyId, 11 | this.expiryDateTime, 12 | this.secretKey, 13 | this.sessionToken, 14 | }); 15 | 16 | factory AuthenticationCredentials.fromJson(String json) { 17 | Map data = jsonDecode(json, reviver: (key, value) { 18 | return key == "expiryDateTime" ? DateTime.parse(value) : value; 19 | }); 20 | return AuthenticationCredentials( 21 | accessKeyId: data["accessKeyId"], 22 | secretKey: data["secretKey"], 23 | sessionToken: data["sessionToken"], 24 | expiryDateTime: data["expiryDateTime"], 25 | ); 26 | } 27 | 28 | String toJson() { 29 | return jsonEncode({ 30 | "accessKeyId": accessKeyId, 31 | "secretKey": secretKey, 32 | "sessionToken": sessionToken, 33 | "expiryDateTime": expiryDateTime.toIso8601String() 34 | }); 35 | } 36 | 37 | bool get hasExpired => DateTime.now().isAfter(expiryDateTime); 38 | } 39 | -------------------------------------------------------------------------------- /lib/packages/query_repository.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_aws_app/identity/identity.dart'; 2 | import 'package:flutter_aws_app/models/models.dart'; 3 | import 'package:flutter_aws_app/packages/query_provider.dart'; 4 | import 'package:flutter_aws_app/packages/repository.dart'; 5 | import 'package:meta/meta.dart'; 6 | 7 | class QueryRepository extends Repository { 8 | final IdentityRepository identityRepository; 9 | final String endpoint; 10 | final String region; 11 | final QueryProvider _queryProvider; 12 | 13 | QueryRepository({ 14 | @required this.endpoint, 15 | @required this.region, 16 | @required this.identityRepository, 17 | }) : _queryProvider = QueryProvider(endpoint, region); 18 | 19 | Future query(String fragment, {int retryCount = -1}) async { 20 | Query response; 21 | int retry = 0; 22 | do { 23 | print("try #$retry"); 24 | response = await _query(fragment); 25 | } while (response == null && retry++ < retryCount); 26 | return response; 27 | } 28 | 29 | Future _query(String fragment) async { 30 | var credentials = await identityRepository.credentials; 31 | if (credentials == null) { 32 | return null; 33 | } 34 | var response = await _queryProvider.query( 35 | credentials.accessKeyId, 36 | credentials.secretKey, 37 | credentials.sessionToken, 38 | fragment, 39 | ); 40 | return response; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/authentication/authentication_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:flutter_aws_app/authentication/authentication.dart'; 3 | import 'package:flutter_aws_app/identity/identity.dart'; 4 | import 'package:meta/meta.dart'; 5 | 6 | class AuthenticationBloc 7 | extends Bloc { 8 | final IdentityRepository identityRepository; 9 | 10 | AuthenticationBloc({@required this.identityRepository}) 11 | : assert(identityRepository != null); 12 | 13 | @override 14 | AuthenticationState get initialState => Uninitialized(); 15 | 16 | @override 17 | Stream mapEventToState( 18 | AuthenticationEvent event, 19 | ) async* { 20 | if (event is AppStarted) { 21 | bool isAuthenticated = await identityRepository.isAuthenticated(); 22 | if (isAuthenticated) { 23 | yield Authenticated(); 24 | } else { 25 | yield Unauthenticated(); 26 | } 27 | } 28 | if (event is Authenticate) { 29 | // If this fails (e.g. being offline) the code will be unusable anyways. 30 | // So no need to retry, but rather having to sign in again. 31 | bool isAuthenticated = await identityRepository.authenticate(event.code); 32 | if (isAuthenticated) { 33 | yield Authenticated(); 34 | } else { 35 | yield Unauthenticated(); 36 | } 37 | } 38 | if (event is SignOut) { 39 | bool isSignedOut = await identityRepository.signOut(); 40 | if (isSignedOut) { 41 | yield Unauthenticated(); 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # Visual Studio Code related 19 | .vscode/ 20 | 21 | # Flutter/Dart/Pub related 22 | **/doc/api/ 23 | .dart_tool/ 24 | .flutter-plugins 25 | .packages 26 | .pub-cache/ 27 | .pub/ 28 | /build/ 29 | 30 | # Android related 31 | **/android/**/gradle-wrapper.jar 32 | **/android/.gradle 33 | **/android/captures/ 34 | **/android/gradlew 35 | **/android/gradlew.bat 36 | **/android/local.properties 37 | **/android/**/GeneratedPluginRegistrant.java 38 | 39 | # iOS/XCode related 40 | **/ios/**/*.mode1v3 41 | **/ios/**/*.mode2v3 42 | **/ios/**/*.moved-aside 43 | **/ios/**/*.pbxuser 44 | **/ios/**/*.perspectivev3 45 | **/ios/**/*sync/ 46 | **/ios/**/.sconsign.dblite 47 | **/ios/**/.tags* 48 | **/ios/**/.vagrant/ 49 | **/ios/**/DerivedData/ 50 | **/ios/**/Icon? 51 | **/ios/**/Pods/ 52 | **/ios/**/.symlinks/ 53 | **/ios/**/profile 54 | **/ios/**/xcuserdata 55 | **/ios/.generated/ 56 | **/ios/Flutter/App.framework 57 | **/ios/Flutter/Flutter.framework 58 | **/ios/Flutter/Generated.xcconfig 59 | **/ios/Flutter/app.flx 60 | **/ios/Flutter/app.zip 61 | **/ios/Flutter/flutter_assets/ 62 | **/ios/ServiceDefinitions.json 63 | **/ios/Runner/GeneratedPluginRegistrant.* 64 | 65 | # Exceptions to above rules. 66 | !**/ios/**/default.mode1v3 67 | !**/ios/**/default.mode2v3 68 | !**/ios/**/default.pbxuser 69 | !**/ios/**/default.perspectivev3 70 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 71 | -------------------------------------------------------------------------------- /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 | flutter_aws_app 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 28 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.example.flutter_aws_app" 42 | minSdkVersion 18 43 | targetSdkVersion 28 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 47 | } 48 | 49 | buildTypes { 50 | release { 51 | // TODO: Add your own signing config for the release build. 52 | // Signing with the debug keys for now, so `flutter run --release` works. 53 | signingConfig signingConfigs.debug 54 | } 55 | } 56 | } 57 | 58 | flutter { 59 | source '../..' 60 | } 61 | 62 | dependencies { 63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 64 | testImplementation 'junit:junit:4.12' 65 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 66 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 67 | } 68 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 15 | 22 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/packages/repository_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | abstract class Repository {} 4 | 5 | /// A Flutter widget which provides a repository to its children via `RepositoryProvider.of(context)`. 6 | /// It is used as a DI widget so that a single instance of a repository can be provided 7 | /// to multiple widgets within a subtree. 8 | class RepositoryProvider extends InheritedWidget { 9 | /// The [Repository] which is to be made available throughout the subtree 10 | final T repository; 11 | 12 | /// The [Widget] and its descendants which will have access to the [Repository]. 13 | final Widget child; 14 | 15 | RepositoryProvider({ 16 | Key key, 17 | @required this.repository, 18 | this.child, 19 | }) : assert(repository != null), 20 | super(key: key); 21 | 22 | /// Method that allows widgets to access the repository as long as their `BuildContext` 23 | /// contains a `RepositoryProvider` instance. 24 | static T of(BuildContext context) { 25 | final type = _typeOf>(); 26 | final RepositoryProvider provider = context 27 | .ancestorInheritedElementForWidgetOfExactType(type) 28 | ?.widget as RepositoryProvider; 29 | 30 | if (provider == null) { 31 | throw FlutterError( 32 | """ 33 | RepositoryProvider.of() called with a context that does not contain a Repository of type $T. 34 | No ancestor could be found starting from the context that was passed to RepositoryProvider.of<$T>(). 35 | This can happen if the context you use comes from a widget above the RepositoryProvider. 36 | This can also happen if you used RepositoryProviderTree and didn\'t explicity provide 37 | the RepositoryProvider types: RepositoryProvider(repository: $T()) instead of RepositoryProvider<$T>(repository: $T()). 38 | The context used was: $context 39 | """, 40 | ); 41 | } 42 | return provider?.repository; 43 | } 44 | 45 | /// Clone the current [RepositoryProvider] with a new child [Widget]. 46 | /// All other values, including [Key] and [Repository] are preserved. 47 | RepositoryProvider copyWith(Widget child) { 48 | return RepositoryProvider( 49 | key: key, 50 | repository: repository, 51 | child: child, 52 | ); 53 | } 54 | 55 | /// Necessary to obtain generic [Type] 56 | /// https://github.com/dart-lang/sdk/issues/11923 57 | static Type _typeOf() => T; 58 | 59 | @override 60 | bool updateShouldNotify(RepositoryProvider oldWidget) => false; 61 | } 62 | -------------------------------------------------------------------------------- /lib/packages/repository_provider_tree.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/widgets.dart'; 2 | import 'package:flutter_aws_app/packages/repository.dart'; 3 | 4 | /// A Flutter [Widget] that merges multiple [RepositoryProvider] widgets into one widget tree. 5 | /// 6 | /// [RepositoryProviderTree] improves the readability and eliminates the need 7 | /// to nest multiple [RepositoryProviders]. 8 | /// 9 | /// By using [RepositoryProviderTree] we can go from: 10 | /// 11 | /// ```dart 12 | /// RepositoryProvider( 13 | /// repository: RepositoryA(), 14 | /// child: RepositoryProvider( 15 | /// repository: RepositoryB(), 16 | /// child: RepositoryProvider( 17 | /// value: RepositoryC(), 18 | /// child: ChildA(), 19 | /// ) 20 | /// ) 21 | /// ) 22 | /// ``` 23 | /// 24 | /// to: 25 | /// 26 | /// ```dart 27 | /// RepositoryProviderTree( 28 | /// repositoryProviders: [ 29 | /// RepositoryProvider(repository: RepositoryA()), 30 | /// RepositoryProvider(repository: RepositoryB()), 31 | /// RepositoryProvider(repository: RepositoryC()), 32 | /// ], 33 | /// child: ChildA(), 34 | /// ) 35 | /// ``` 36 | /// 37 | /// [RepositoryProviderTree] converts the [RepositoryProvider] list 38 | /// into a tree of nested [RepositoryProvider] widgets. 39 | /// As a result, the only advantage of using [RepositoryProviderTree] is improved 40 | /// readability due to the reduction in nesting and boilerplate. 41 | class RepositoryProviderTree extends StatelessWidget { 42 | /// The [RepositoryProvider] list which is converted into a tree of [RepositoryProvider] widgets. 43 | /// The tree of [RepositoryProvider] widgets is created in order meaning the first [RepositoryProvider] 44 | /// will be the top-most [RepositoryProvider] and the last [RepositoryProvider] will be a direct ancestor 45 | /// of the `child` [Widget]. 46 | final List repositoryProviders; 47 | 48 | /// The [Widget] and its descendants which will have access to every [Repository] provided by `repositoryProviders`. 49 | /// This [Widget] will be a direct descendent of the last [RepositoryProvider] in `repositoryProviders`. 50 | final Widget child; 51 | 52 | RepositoryProviderTree({ 53 | Key key, 54 | @required this.repositoryProviders, 55 | @required this.child, 56 | }) : assert(repositoryProviders != null), 57 | assert(child != null), 58 | super(key: key); 59 | 60 | @override 61 | Widget build(BuildContext context) { 62 | Widget tree = child; 63 | for (final repositoryProvider in repositoryProviders.reversed) { 64 | tree = repositoryProvider.copyWith(tree); 65 | } 66 | return tree; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /lib/identity/identity_signout_page.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_aws_app/authentication/authentication.dart'; 5 | import 'package:flutter_aws_app/identity/identity.dart'; 6 | import 'package:flutter_aws_app/packages/repository.dart'; 7 | import 'package:flutter_bloc/flutter_bloc.dart'; 8 | import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; 9 | 10 | // The application's login page. 11 | class IdentitySignOutPage extends StatefulWidget { 12 | @override 13 | _IdentitySignOutPageState createState() => new _IdentitySignOutPageState(); 14 | } 15 | 16 | // The application's login page state. 17 | class _IdentitySignOutPageState extends State { 18 | // Identity access. 19 | IdentityRepository _identityRepository; 20 | 21 | // Authentication Bloc. 22 | AuthenticationBloc _authenticationBloc; 23 | 24 | // Webview to present the sign in/up web page. 25 | final flutterWebviewPlugin = new FlutterWebviewPlugin(); 26 | 27 | // Webview subscriptions. 28 | StreamSubscription _onDestroy; 29 | StreamSubscription _onUrlChanged; 30 | StreamSubscription _onStateChanged; 31 | 32 | String token; 33 | 34 | @override 35 | void dispose() { 36 | // Every listener should be canceled, the same should be done with this stream. 37 | _onDestroy.cancel(); 38 | _onUrlChanged.cancel(); 39 | _onStateChanged.cancel(); 40 | flutterWebviewPlugin.dispose(); 41 | super.dispose(); 42 | } 43 | 44 | @override 45 | void initState() { 46 | super.initState(); 47 | 48 | _identityRepository = RepositoryProvider.of(context); 49 | _authenticationBloc = BlocProvider.of(context); 50 | 51 | // Close, just to be sure. 52 | flutterWebviewPlugin.close(); 53 | 54 | // Add a listener to on destroy WebView, so you can make came actions. 55 | _onDestroy = flutterWebviewPlugin.onDestroy.listen((_) { 56 | print("destroy"); 57 | }); 58 | 59 | // Add a listener to on state changed. 60 | _onStateChanged = 61 | flutterWebviewPlugin.onStateChanged.listen((WebViewStateChanged state) { 62 | print("onStateChanged: ${state.type} ${state.url}"); 63 | }); 64 | 65 | // Add a listener to on url changed. 66 | _onUrlChanged = flutterWebviewPlugin.onUrlChanged.listen((String url) { 67 | if (url 68 | .startsWith(_identityRepository.cognitoUserPoolLogoutRedirectUrl)) { 69 | _authenticationBloc.dispatch(SignOut()); 70 | Navigator.pop(context); 71 | } 72 | }); 73 | } 74 | 75 | @override 76 | Widget build(BuildContext context) { 77 | String logoutUrl = _identityRepository.cognitoUserPoolLogoutUrl; 78 | return new WebviewScaffold( 79 | url: logoutUrl, 80 | hidden: true, 81 | appBar: new AppBar( 82 | title: new Text("Sign Out"), 83 | ), 84 | userAgent: 85 | // TODO change based on platform. 86 | "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1", 87 | ); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/identity/identity_signin_page.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_aws_app/authentication/authentication.dart'; 5 | import 'package:flutter_aws_app/identity/identity.dart'; 6 | import 'package:flutter_aws_app/packages/repository.dart'; 7 | import 'package:flutter_bloc/flutter_bloc.dart'; 8 | import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; 9 | 10 | // The application's login page. 11 | class IdentitySignInPage extends StatefulWidget { 12 | @override 13 | _IdentitySignInPageState createState() => new _IdentitySignInPageState(); 14 | } 15 | 16 | // The application's login page state. 17 | class _IdentitySignInPageState extends State { 18 | // Identity access. 19 | IdentityRepository _identityRepository; 20 | 21 | // Authentication Bloc. 22 | AuthenticationBloc _authenticationBloc; 23 | 24 | // Webview to present the sign in/up web page. 25 | final flutterWebviewPlugin = new FlutterWebviewPlugin(); 26 | 27 | // Webview subscriptions. 28 | StreamSubscription _onDestroy; 29 | StreamSubscription _onUrlChanged; 30 | StreamSubscription _onStateChanged; 31 | 32 | String token; 33 | 34 | @override 35 | void dispose() { 36 | // Every listener should be canceled, the same should be done with this stream. 37 | _onDestroy.cancel(); 38 | _onUrlChanged.cancel(); 39 | _onStateChanged.cancel(); 40 | flutterWebviewPlugin.dispose(); 41 | super.dispose(); 42 | } 43 | 44 | @override 45 | void initState() { 46 | super.initState(); 47 | 48 | _identityRepository = RepositoryProvider.of(context); 49 | _authenticationBloc = BlocProvider.of(context); 50 | 51 | // Close, just to be sure. 52 | flutterWebviewPlugin.close(); 53 | 54 | // Add a listener to on destroy WebView, so you can make came actions. 55 | _onDestroy = flutterWebviewPlugin.onDestroy.listen((_) { 56 | print("destroy"); 57 | }); 58 | 59 | // Add a listener to on state changed. 60 | _onStateChanged = 61 | flutterWebviewPlugin.onStateChanged.listen((WebViewStateChanged state) { 62 | print("onStateChanged: ${state.type} ${state.url}"); 63 | }); 64 | 65 | // Add a listener to on url changed. 66 | _onUrlChanged = flutterWebviewPlugin.onUrlChanged.listen((String url) { 67 | if (mounted) { 68 | setState(() { 69 | print("URL changed: $url"); 70 | if (url.startsWith( 71 | _identityRepository.cognitoUserPoolLoginRedirectUrl)) { 72 | RegExp regExp = new RegExp("code=(.*)"); 73 | token = regExp.firstMatch(url)?.group(1); 74 | print("token $token - $url"); 75 | _authenticationBloc.dispatch(Authenticate((b) => b..code = token)); 76 | Navigator.pop(context); 77 | } 78 | }); 79 | } 80 | }); 81 | } 82 | 83 | @override 84 | Widget build(BuildContext context) { 85 | String loginUrl = _identityRepository.cognitoUserPoolLoginUrl; 86 | return new WebviewScaffold( 87 | url: loginUrl, 88 | hidden: true, 89 | appBar: new AppBar( 90 | title: new Text("Sign In"), 91 | ), 92 | userAgent: 93 | // TODO change based on platform. 94 | "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1", 95 | ); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/packages/query_provider.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter_aws_app/models/models.dart'; 4 | import 'package:flutter_aws_app/packages/sig_v4.dart'; 5 | import 'package:http/http.dart' as http; 6 | 7 | class QueryProvider { 8 | final String endpoint; 9 | final String region; 10 | 11 | QueryProvider(this.endpoint, this.region); 12 | 13 | Future post( 14 | String accessKey, 15 | String secretKey, 16 | String sessionToken, 17 | String operationName, 18 | String query, 19 | ) async { 20 | final sigV4Client = new AwsSigV4Client( 21 | accessKey, 22 | secretKey, 23 | endpoint, 24 | serviceName: 'appsync', 25 | sessionToken: sessionToken, 26 | region: region, 27 | ); 28 | 29 | final sigV4Request = new SigV4Request( 30 | sigV4Client, 31 | method: "POST", 32 | path: "/graphql", 33 | headers: new Map.from({ 34 | "Content-Type": "application/graphql; charset=utf-8", 35 | }), 36 | body: new Map.from({ 37 | "operationName": operationName, 38 | "query": query, 39 | }), 40 | ); 41 | 42 | http.Response response; 43 | try { 44 | response = await http.post( 45 | sigV4Request.url, 46 | headers: sigV4Request.headers, 47 | body: sigV4Request.body, 48 | ); 49 | } catch (e) { 50 | print(e); 51 | return null; 52 | } 53 | var data; 54 | try { 55 | data = json.decode(response.body); 56 | } catch (e) { 57 | print(e); 58 | return null; 59 | } 60 | if (response.statusCode < 200 || response.statusCode > 299) { 61 | String errorType = "UnknownError"; 62 | for (String header in response.headers.keys) { 63 | if (header.toLowerCase() == "x-amzn-errortype") { 64 | errorType = response.headers[header].split(':')[0]; 65 | break; 66 | } 67 | } 68 | if (data == null) { 69 | print("$errorType, statusCode: ${response.statusCode}"); 70 | } 71 | return null; 72 | } 73 | // TODO errors are per field, so is this to restrictive? 74 | if (data["errors"] != null) { 75 | print(data["errors"]); 76 | return null; 77 | } 78 | return data; 79 | } 80 | 81 | Future query( 82 | String accessKey, 83 | String secretKey, 84 | String sessionToken, 85 | String fragment, 86 | ) async { 87 | var data = await post( 88 | accessKey, 89 | secretKey, 90 | sessionToken, 91 | "operation", 92 | "query operation { $fragment }", 93 | ); 94 | Query query; 95 | try { 96 | query = data == null 97 | ? null 98 | : standardSerializers.deserializeWith(Query.serializer, data["data"]); 99 | } catch (e) { 100 | print(e); 101 | return null; 102 | } 103 | return query; 104 | } 105 | } 106 | 107 | //var x = standardSerializers.deserializeWith(PetList.serializer, data["data"]); 108 | //final specifiedType = FullType(BuiltList, const [const FullType(Pet)]); 109 | //var x = standardSerializers.deserialize(data["data"]["listPets"], specifiedType: specifiedType); 110 | 111 | //var timeout = { 112 | // "data": {"listPets": null}, 113 | // "errors": [ 114 | // { 115 | // "path": ["listPets"], 116 | // "data": null, 117 | // "errorType": "ExecutionTimeout", 118 | // "errorInfo": null, 119 | // "locations": [ 120 | // {"line": 2, "column": 9, "sourceName": null} 121 | // ], 122 | // "message": "Execution timed out." 123 | // } 124 | // ] 125 | //}; 126 | 127 | // {"data":{"listPets":null},"errors":[{"path":["listPets"],"data":null,"errorType":"ExecutionTimeout","errorInfo":null,"locations":[{"line":2,"column":9,"sourceName":null}],"message":"Execution timed out."}]} 128 | 129 | // {"data":{"listPets":[{"id":"e26b33ed-c2b4-45e0-a344-aa8775a57861","price":11.0,"type":"fish"}]}} 130 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_aws_app 2 | description: A new Flutter application. 3 | 4 | # The following defines the version and build number for your application. 5 | # A version number is three numbers separated by dots, like 1.2.43 6 | # followed by an optional build number separated by a +. 7 | # Both the version and the builder number may be overridden in flutter 8 | # build by specifying --build-name and --build-number, respectively. 9 | # In Android, build-name is used as versionName while build-number used as versionCode. 10 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 11 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 12 | # Read more about iOS versioning at 13 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 14 | version: 1.0.0+1 15 | 16 | environment: 17 | sdk: ">=2.1.0 <3.0.0" 18 | 19 | dependencies: 20 | flutter: 21 | sdk: flutter 22 | 23 | # The following adds the Cupertino Icons font to your application. 24 | # Use with the CupertinoIcons class for iOS style icons. 25 | cupertino_icons: ^0.1.2 26 | 27 | # The following adds the bloc pattern to your application. 28 | # All details can be found here https://felangel.github.io/bloc/ 29 | bloc: ^0.13.0 30 | flutter_bloc: ^0.13.0 31 | 32 | # The following adds a Webview tho your application. 33 | # It is used to sign in/up users to Cognito User Pools using the Hosted Web UI. 34 | # This should become obsolete once proper Cognito support arrives for flutter. 35 | flutter_webview_plugin: ^0.3.4 36 | 37 | # The following adds Deep Linking to your application. 38 | uni_links: ^0.2.0 39 | 40 | # The following adds HTTP REST API access capabilities to your application. 41 | http: any 42 | 43 | # Cryptography for SigV4 signing. 44 | crypto: any 45 | 46 | # The following adds secure key storage to your application. 47 | flutter_secure_storage: ^3.2.1+1 48 | 49 | # The following adds a heads up display component to your application. 50 | modal_progress_hud: ^0.1.3 51 | 52 | # The following adds immutable value builders to your application. 53 | built_value: ^6.5.0 54 | built_collection: ^4.2.2 55 | 56 | dev_dependencies: 57 | # The following adds immutable value builders to your application. 58 | # Run 'flutter packages pub run build_runner build' to build. 59 | build_runner: 60 | built_value_generator: ^6.5.0 61 | 62 | # The following is testing related. 63 | flutter_test: 64 | sdk: flutter 65 | 66 | 67 | # For information on the generic Dart part of this file, see the 68 | # following page: https://www.dartlang.org/tools/pub/pubspec 69 | 70 | # The following section is specific to Flutter. 71 | flutter: 72 | 73 | # The following line ensures that the Material Icons font is 74 | # included with your application, so that you can use the icons in 75 | # the material Icons class. 76 | uses-material-design: true 77 | 78 | # To add assets to your application, add an assets section, like this: 79 | # assets: 80 | # - images/a_dot_burr.jpeg 81 | # - images/a_dot_ham.jpeg 82 | 83 | # An image asset can refer to one or more resolution-specific "variants", see 84 | # https://flutter.io/assets-and-images/#resolution-aware. 85 | 86 | # For details regarding adding assets from package dependencies, see 87 | # https://flutter.io/assets-and-images/#from-packages 88 | 89 | # To add custom fonts to your application, add a fonts section here, 90 | # in this "flutter" section. Each entry in this list should have a 91 | # "family" key with the font family name, and a "fonts" key with a 92 | # list giving the asset and other descriptors for the font. For 93 | # example: 94 | # fonts: 95 | # - family: Schyler 96 | # fonts: 97 | # - asset: fonts/Schyler-Regular.ttf 98 | # - asset: fonts/Schyler-Italic.ttf 99 | # style: italic 100 | # - family: Trajan Pro 101 | # fonts: 102 | # - asset: fonts/TrajanPro.ttf 103 | # - asset: fonts/TrajanPro_Bold.ttf 104 | # weight: 700 105 | # 106 | # For details regarding fonts from package dependencies, 107 | # see https://flutter.io/custom-fonts/#from-packages 108 | -------------------------------------------------------------------------------- /lib/home/home_events.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'home_events.dart'; 4 | 5 | // ************************************************************************** 6 | // BuiltValueGenerator 7 | // ************************************************************************** 8 | 9 | class _$Fetch extends Fetch { 10 | @override 11 | final String operationName; 12 | @override 13 | final String query; 14 | 15 | factory _$Fetch([void Function(FetchBuilder) updates]) => 16 | (new FetchBuilder()..update(updates)).build(); 17 | 18 | _$Fetch._({this.operationName, this.query}) : super._() { 19 | if (operationName == null) { 20 | throw new BuiltValueNullFieldError('Fetch', 'operationName'); 21 | } 22 | if (query == null) { 23 | throw new BuiltValueNullFieldError('Fetch', 'query'); 24 | } 25 | } 26 | 27 | @override 28 | Fetch rebuild(void Function(FetchBuilder) updates) => 29 | (toBuilder()..update(updates)).build(); 30 | 31 | @override 32 | FetchBuilder toBuilder() => new FetchBuilder()..replace(this); 33 | 34 | @override 35 | bool operator ==(Object other) { 36 | if (identical(other, this)) return true; 37 | return other is Fetch && 38 | operationName == other.operationName && 39 | query == other.query; 40 | } 41 | 42 | @override 43 | int get hashCode { 44 | return $jf($jc($jc(0, operationName.hashCode), query.hashCode)); 45 | } 46 | 47 | @override 48 | String toString() { 49 | return (newBuiltValueToStringHelper('Fetch') 50 | ..add('operationName', operationName) 51 | ..add('query', query)) 52 | .toString(); 53 | } 54 | } 55 | 56 | class FetchBuilder implements Builder { 57 | _$Fetch _$v; 58 | 59 | String _operationName; 60 | String get operationName => _$this._operationName; 61 | set operationName(String operationName) => 62 | _$this._operationName = operationName; 63 | 64 | String _query; 65 | String get query => _$this._query; 66 | set query(String query) => _$this._query = query; 67 | 68 | FetchBuilder(); 69 | 70 | FetchBuilder get _$this { 71 | if (_$v != null) { 72 | _operationName = _$v.operationName; 73 | _query = _$v.query; 74 | _$v = null; 75 | } 76 | return this; 77 | } 78 | 79 | @override 80 | void replace(Fetch other) { 81 | if (other == null) { 82 | throw new ArgumentError.notNull('other'); 83 | } 84 | _$v = other as _$Fetch; 85 | } 86 | 87 | @override 88 | void update(void Function(FetchBuilder) updates) { 89 | if (updates != null) updates(this); 90 | } 91 | 92 | @override 93 | _$Fetch build() { 94 | final _$result = 95 | _$v ?? new _$Fetch._(operationName: operationName, query: query); 96 | replace(_$result); 97 | return _$result; 98 | } 99 | } 100 | 101 | class _$Initialize extends Initialize { 102 | factory _$Initialize([void Function(InitializeBuilder) updates]) => 103 | (new InitializeBuilder()..update(updates)).build(); 104 | 105 | _$Initialize._() : super._(); 106 | 107 | @override 108 | Initialize rebuild(void Function(InitializeBuilder) updates) => 109 | (toBuilder()..update(updates)).build(); 110 | 111 | @override 112 | InitializeBuilder toBuilder() => new InitializeBuilder()..replace(this); 113 | 114 | @override 115 | bool operator ==(Object other) { 116 | if (identical(other, this)) return true; 117 | return other is Initialize; 118 | } 119 | 120 | @override 121 | int get hashCode { 122 | return 33416838; 123 | } 124 | 125 | @override 126 | String toString() { 127 | return newBuiltValueToStringHelper('Initialize').toString(); 128 | } 129 | } 130 | 131 | class InitializeBuilder implements Builder { 132 | _$Initialize _$v; 133 | 134 | InitializeBuilder(); 135 | 136 | @override 137 | void replace(Initialize other) { 138 | if (other == null) { 139 | throw new ArgumentError.notNull('other'); 140 | } 141 | _$v = other as _$Initialize; 142 | } 143 | 144 | @override 145 | void update(void Function(InitializeBuilder) updates) { 146 | if (updates != null) updates(this); 147 | } 148 | 149 | @override 150 | _$Initialize build() { 151 | final _$result = _$v ?? new _$Initialize._(); 152 | replace(_$result); 153 | return _$result; 154 | } 155 | } 156 | 157 | // ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new 158 | -------------------------------------------------------------------------------- /lib/models/pet.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'pet.dart'; 4 | 5 | // ************************************************************************** 6 | // BuiltValueGenerator 7 | // ************************************************************************** 8 | 9 | Serializer _$petSerializer = new _$PetSerializer(); 10 | 11 | class _$PetSerializer implements StructuredSerializer { 12 | @override 13 | final Iterable types = const [Pet, _$Pet]; 14 | @override 15 | final String wireName = 'Pet'; 16 | 17 | @override 18 | Iterable serialize(Serializers serializers, Pet object, 19 | {FullType specifiedType = FullType.unspecified}) { 20 | final result = [ 21 | 'id', 22 | serializers.serialize(object.id, specifiedType: const FullType(String)), 23 | 'type', 24 | serializers.serialize(object.type, specifiedType: const FullType(String)), 25 | 'price', 26 | serializers.serialize(object.price, 27 | specifiedType: const FullType(double)), 28 | ]; 29 | 30 | return result; 31 | } 32 | 33 | @override 34 | Pet deserialize(Serializers serializers, Iterable serialized, 35 | {FullType specifiedType = FullType.unspecified}) { 36 | final result = new PetBuilder(); 37 | 38 | final iterator = serialized.iterator; 39 | while (iterator.moveNext()) { 40 | final key = iterator.current as String; 41 | iterator.moveNext(); 42 | final dynamic value = iterator.current; 43 | switch (key) { 44 | case 'id': 45 | result.id = serializers.deserialize(value, 46 | specifiedType: const FullType(String)) as String; 47 | break; 48 | case 'type': 49 | result.type = serializers.deserialize(value, 50 | specifiedType: const FullType(String)) as String; 51 | break; 52 | case 'price': 53 | result.price = serializers.deserialize(value, 54 | specifiedType: const FullType(double)) as double; 55 | break; 56 | } 57 | } 58 | 59 | return result.build(); 60 | } 61 | } 62 | 63 | class _$Pet extends Pet { 64 | @override 65 | final String id; 66 | @override 67 | final String type; 68 | @override 69 | final double price; 70 | 71 | factory _$Pet([void Function(PetBuilder) updates]) => 72 | (new PetBuilder()..update(updates)).build(); 73 | 74 | _$Pet._({this.id, this.type, this.price}) : super._() { 75 | if (id == null) { 76 | throw new BuiltValueNullFieldError('Pet', 'id'); 77 | } 78 | if (type == null) { 79 | throw new BuiltValueNullFieldError('Pet', 'type'); 80 | } 81 | if (price == null) { 82 | throw new BuiltValueNullFieldError('Pet', 'price'); 83 | } 84 | } 85 | 86 | @override 87 | Pet rebuild(void Function(PetBuilder) updates) => 88 | (toBuilder()..update(updates)).build(); 89 | 90 | @override 91 | PetBuilder toBuilder() => new PetBuilder()..replace(this); 92 | 93 | @override 94 | bool operator ==(Object other) { 95 | if (identical(other, this)) return true; 96 | return other is Pet && 97 | id == other.id && 98 | type == other.type && 99 | price == other.price; 100 | } 101 | 102 | @override 103 | int get hashCode { 104 | return $jf($jc($jc($jc(0, id.hashCode), type.hashCode), price.hashCode)); 105 | } 106 | 107 | @override 108 | String toString() { 109 | return (newBuiltValueToStringHelper('Pet') 110 | ..add('id', id) 111 | ..add('type', type) 112 | ..add('price', price)) 113 | .toString(); 114 | } 115 | } 116 | 117 | class PetBuilder implements Builder { 118 | _$Pet _$v; 119 | 120 | String _id; 121 | String get id => _$this._id; 122 | set id(String id) => _$this._id = id; 123 | 124 | String _type; 125 | String get type => _$this._type; 126 | set type(String type) => _$this._type = type; 127 | 128 | double _price; 129 | double get price => _$this._price; 130 | set price(double price) => _$this._price = price; 131 | 132 | PetBuilder(); 133 | 134 | PetBuilder get _$this { 135 | if (_$v != null) { 136 | _id = _$v.id; 137 | _type = _$v.type; 138 | _price = _$v.price; 139 | _$v = null; 140 | } 141 | return this; 142 | } 143 | 144 | @override 145 | void replace(Pet other) { 146 | if (other == null) { 147 | throw new ArgumentError.notNull('other'); 148 | } 149 | _$v = other as _$Pet; 150 | } 151 | 152 | @override 153 | void update(void Function(PetBuilder) updates) { 154 | if (updates != null) updates(this); 155 | } 156 | 157 | @override 158 | _$Pet build() { 159 | final _$result = _$v ?? new _$Pet._(id: id, type: type, price: price); 160 | replace(_$result); 161 | return _$result; 162 | } 163 | } 164 | 165 | // ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new 166 | -------------------------------------------------------------------------------- /lib/home/home_states.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'home_states.dart'; 4 | 5 | // ************************************************************************** 6 | // BuiltValueGenerator 7 | // ************************************************************************** 8 | 9 | class _$HomeInitial extends HomeInitial { 10 | factory _$HomeInitial([void Function(HomeInitialBuilder) updates]) => 11 | (new HomeInitialBuilder()..update(updates)).build(); 12 | 13 | _$HomeInitial._() : super._(); 14 | 15 | @override 16 | HomeInitial rebuild(void Function(HomeInitialBuilder) updates) => 17 | (toBuilder()..update(updates)).build(); 18 | 19 | @override 20 | HomeInitialBuilder toBuilder() => new HomeInitialBuilder()..replace(this); 21 | 22 | @override 23 | bool operator ==(Object other) { 24 | if (identical(other, this)) return true; 25 | return other is HomeInitial; 26 | } 27 | 28 | @override 29 | int get hashCode { 30 | return 329584587; 31 | } 32 | 33 | @override 34 | String toString() { 35 | return newBuiltValueToStringHelper('HomeInitial').toString(); 36 | } 37 | } 38 | 39 | class HomeInitialBuilder implements Builder { 40 | _$HomeInitial _$v; 41 | 42 | HomeInitialBuilder(); 43 | 44 | @override 45 | void replace(HomeInitial other) { 46 | if (other == null) { 47 | throw new ArgumentError.notNull('other'); 48 | } 49 | _$v = other as _$HomeInitial; 50 | } 51 | 52 | @override 53 | void update(void Function(HomeInitialBuilder) updates) { 54 | if (updates != null) updates(this); 55 | } 56 | 57 | @override 58 | _$HomeInitial build() { 59 | final _$result = _$v ?? new _$HomeInitial._(); 60 | replace(_$result); 61 | return _$result; 62 | } 63 | } 64 | 65 | class _$HomeSuccess extends HomeSuccess { 66 | factory _$HomeSuccess([void Function(HomeSuccessBuilder) updates]) => 67 | (new HomeSuccessBuilder()..update(updates)).build(); 68 | 69 | _$HomeSuccess._() : super._(); 70 | 71 | @override 72 | HomeSuccess rebuild(void Function(HomeSuccessBuilder) updates) => 73 | (toBuilder()..update(updates)).build(); 74 | 75 | @override 76 | HomeSuccessBuilder toBuilder() => new HomeSuccessBuilder()..replace(this); 77 | 78 | @override 79 | bool operator ==(Object other) { 80 | if (identical(other, this)) return true; 81 | return other is HomeSuccess; 82 | } 83 | 84 | @override 85 | int get hashCode { 86 | return 970183756; 87 | } 88 | 89 | @override 90 | String toString() { 91 | return newBuiltValueToStringHelper('HomeSuccess').toString(); 92 | } 93 | } 94 | 95 | class HomeSuccessBuilder implements Builder { 96 | _$HomeSuccess _$v; 97 | 98 | HomeSuccessBuilder(); 99 | 100 | @override 101 | void replace(HomeSuccess other) { 102 | if (other == null) { 103 | throw new ArgumentError.notNull('other'); 104 | } 105 | _$v = other as _$HomeSuccess; 106 | } 107 | 108 | @override 109 | void update(void Function(HomeSuccessBuilder) updates) { 110 | if (updates != null) updates(this); 111 | } 112 | 113 | @override 114 | _$HomeSuccess build() { 115 | final _$result = _$v ?? new _$HomeSuccess._(); 116 | replace(_$result); 117 | return _$result; 118 | } 119 | } 120 | 121 | class _$HomeLoading extends HomeLoading { 122 | factory _$HomeLoading([void Function(HomeLoadingBuilder) updates]) => 123 | (new HomeLoadingBuilder()..update(updates)).build(); 124 | 125 | _$HomeLoading._() : super._(); 126 | 127 | @override 128 | HomeLoading rebuild(void Function(HomeLoadingBuilder) updates) => 129 | (toBuilder()..update(updates)).build(); 130 | 131 | @override 132 | HomeLoadingBuilder toBuilder() => new HomeLoadingBuilder()..replace(this); 133 | 134 | @override 135 | bool operator ==(Object other) { 136 | if (identical(other, this)) return true; 137 | return other is HomeLoading; 138 | } 139 | 140 | @override 141 | int get hashCode { 142 | return 666759997; 143 | } 144 | 145 | @override 146 | String toString() { 147 | return newBuiltValueToStringHelper('HomeLoading').toString(); 148 | } 149 | } 150 | 151 | class HomeLoadingBuilder implements Builder { 152 | _$HomeLoading _$v; 153 | 154 | HomeLoadingBuilder(); 155 | 156 | @override 157 | void replace(HomeLoading other) { 158 | if (other == null) { 159 | throw new ArgumentError.notNull('other'); 160 | } 161 | _$v = other as _$HomeLoading; 162 | } 163 | 164 | @override 165 | void update(void Function(HomeLoadingBuilder) updates) { 166 | if (updates != null) updates(this); 167 | } 168 | 169 | @override 170 | _$HomeLoading build() { 171 | final _$result = _$v ?? new _$HomeLoading._(); 172 | replace(_$result); 173 | return _$result; 174 | } 175 | } 176 | 177 | // ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new 178 | -------------------------------------------------------------------------------- /lib/models/query.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'query.dart'; 4 | 5 | // ************************************************************************** 6 | // BuiltValueGenerator 7 | // ************************************************************************** 8 | 9 | Serializer _$querySerializer = new _$QuerySerializer(); 10 | 11 | class _$QuerySerializer implements StructuredSerializer { 12 | @override 13 | final Iterable types = const [Query, _$Query]; 14 | @override 15 | final String wireName = 'Query'; 16 | 17 | @override 18 | Iterable serialize(Serializers serializers, Query object, 19 | {FullType specifiedType = FullType.unspecified}) { 20 | final result = []; 21 | if (object.getPet != null) { 22 | result 23 | ..add('getPet') 24 | ..add(serializers.serialize(object.getPet, 25 | specifiedType: const FullType(Pet))); 26 | } 27 | if (object.listPets != null) { 28 | result 29 | ..add('listPets') 30 | ..add(serializers.serialize(object.listPets, 31 | specifiedType: 32 | const FullType(BuiltList, const [const FullType(Pet)]))); 33 | } 34 | 35 | return result; 36 | } 37 | 38 | @override 39 | Query deserialize(Serializers serializers, Iterable serialized, 40 | {FullType specifiedType = FullType.unspecified}) { 41 | final result = new QueryBuilder(); 42 | 43 | final iterator = serialized.iterator; 44 | while (iterator.moveNext()) { 45 | final key = iterator.current as String; 46 | iterator.moveNext(); 47 | final dynamic value = iterator.current; 48 | switch (key) { 49 | case 'getPet': 50 | result.getPet.replace(serializers.deserialize(value, 51 | specifiedType: const FullType(Pet)) as Pet); 52 | break; 53 | case 'listPets': 54 | result.listPets.replace(serializers.deserialize(value, 55 | specifiedType: 56 | const FullType(BuiltList, const [const FullType(Pet)])) 57 | as BuiltList); 58 | break; 59 | } 60 | } 61 | 62 | return result.build(); 63 | } 64 | } 65 | 66 | class _$Query extends Query { 67 | @override 68 | final Pet getPet; 69 | @override 70 | final BuiltList listPets; 71 | 72 | factory _$Query([void Function(QueryBuilder) updates]) => 73 | (new QueryBuilder()..update(updates)).build(); 74 | 75 | _$Query._({this.getPet, this.listPets}) : super._(); 76 | 77 | @override 78 | Query rebuild(void Function(QueryBuilder) updates) => 79 | (toBuilder()..update(updates)).build(); 80 | 81 | @override 82 | QueryBuilder toBuilder() => new QueryBuilder()..replace(this); 83 | 84 | @override 85 | bool operator ==(Object other) { 86 | if (identical(other, this)) return true; 87 | return other is Query && 88 | getPet == other.getPet && 89 | listPets == other.listPets; 90 | } 91 | 92 | @override 93 | int get hashCode { 94 | return $jf($jc($jc(0, getPet.hashCode), listPets.hashCode)); 95 | } 96 | 97 | @override 98 | String toString() { 99 | return (newBuiltValueToStringHelper('Query') 100 | ..add('getPet', getPet) 101 | ..add('listPets', listPets)) 102 | .toString(); 103 | } 104 | } 105 | 106 | class QueryBuilder implements Builder { 107 | _$Query _$v; 108 | 109 | PetBuilder _getPet; 110 | PetBuilder get getPet => _$this._getPet ??= new PetBuilder(); 111 | set getPet(PetBuilder getPet) => _$this._getPet = getPet; 112 | 113 | ListBuilder _listPets; 114 | ListBuilder get listPets => _$this._listPets ??= new ListBuilder(); 115 | set listPets(ListBuilder listPets) => _$this._listPets = listPets; 116 | 117 | QueryBuilder(); 118 | 119 | QueryBuilder get _$this { 120 | if (_$v != null) { 121 | _getPet = _$v.getPet?.toBuilder(); 122 | _listPets = _$v.listPets?.toBuilder(); 123 | _$v = null; 124 | } 125 | return this; 126 | } 127 | 128 | @override 129 | void replace(Query other) { 130 | if (other == null) { 131 | throw new ArgumentError.notNull('other'); 132 | } 133 | _$v = other as _$Query; 134 | } 135 | 136 | @override 137 | void update(void Function(QueryBuilder) updates) { 138 | if (updates != null) updates(this); 139 | } 140 | 141 | @override 142 | _$Query build() { 143 | _$Query _$result; 144 | try { 145 | _$result = _$v ?? 146 | new _$Query._(getPet: _getPet?.build(), listPets: _listPets?.build()); 147 | } catch (_) { 148 | String _$failedField; 149 | try { 150 | _$failedField = 'getPet'; 151 | _getPet?.build(); 152 | _$failedField = 'listPets'; 153 | _listPets?.build(); 154 | } catch (e) { 155 | throw new BuiltValueNestedFieldError( 156 | 'Query', _$failedField, e.toString()); 157 | } 158 | rethrow; 159 | } 160 | replace(_$result); 161 | return _$result; 162 | } 163 | } 164 | 165 | // ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new 166 | -------------------------------------------------------------------------------- /lib/authentication/authentication_states.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'authentication_states.dart'; 4 | 5 | // ************************************************************************** 6 | // BuiltValueGenerator 7 | // ************************************************************************** 8 | 9 | class _$Authenticated extends Authenticated { 10 | factory _$Authenticated([void Function(AuthenticatedBuilder) updates]) => 11 | (new AuthenticatedBuilder()..update(updates)).build(); 12 | 13 | _$Authenticated._() : super._(); 14 | 15 | @override 16 | Authenticated rebuild(void Function(AuthenticatedBuilder) updates) => 17 | (toBuilder()..update(updates)).build(); 18 | 19 | @override 20 | AuthenticatedBuilder toBuilder() => new AuthenticatedBuilder()..replace(this); 21 | 22 | @override 23 | bool operator ==(Object other) { 24 | if (identical(other, this)) return true; 25 | return other is Authenticated; 26 | } 27 | 28 | @override 29 | int get hashCode { 30 | return 960353163; 31 | } 32 | 33 | @override 34 | String toString() { 35 | return newBuiltValueToStringHelper('Authenticated').toString(); 36 | } 37 | } 38 | 39 | class AuthenticatedBuilder 40 | implements Builder { 41 | _$Authenticated _$v; 42 | 43 | AuthenticatedBuilder(); 44 | 45 | @override 46 | void replace(Authenticated other) { 47 | if (other == null) { 48 | throw new ArgumentError.notNull('other'); 49 | } 50 | _$v = other as _$Authenticated; 51 | } 52 | 53 | @override 54 | void update(void Function(AuthenticatedBuilder) updates) { 55 | if (updates != null) updates(this); 56 | } 57 | 58 | @override 59 | _$Authenticated build() { 60 | final _$result = _$v ?? new _$Authenticated._(); 61 | replace(_$result); 62 | return _$result; 63 | } 64 | } 65 | 66 | class _$Unauthenticated extends Unauthenticated { 67 | factory _$Unauthenticated([void Function(UnauthenticatedBuilder) updates]) => 68 | (new UnauthenticatedBuilder()..update(updates)).build(); 69 | 70 | _$Unauthenticated._() : super._(); 71 | 72 | @override 73 | Unauthenticated rebuild(void Function(UnauthenticatedBuilder) updates) => 74 | (toBuilder()..update(updates)).build(); 75 | 76 | @override 77 | UnauthenticatedBuilder toBuilder() => 78 | new UnauthenticatedBuilder()..replace(this); 79 | 80 | @override 81 | bool operator ==(Object other) { 82 | if (identical(other, this)) return true; 83 | return other is Unauthenticated; 84 | } 85 | 86 | @override 87 | int get hashCode { 88 | return 685811249; 89 | } 90 | 91 | @override 92 | String toString() { 93 | return newBuiltValueToStringHelper('Unauthenticated').toString(); 94 | } 95 | } 96 | 97 | class UnauthenticatedBuilder 98 | implements Builder { 99 | _$Unauthenticated _$v; 100 | 101 | UnauthenticatedBuilder(); 102 | 103 | @override 104 | void replace(Unauthenticated other) { 105 | if (other == null) { 106 | throw new ArgumentError.notNull('other'); 107 | } 108 | _$v = other as _$Unauthenticated; 109 | } 110 | 111 | @override 112 | void update(void Function(UnauthenticatedBuilder) updates) { 113 | if (updates != null) updates(this); 114 | } 115 | 116 | @override 117 | _$Unauthenticated build() { 118 | final _$result = _$v ?? new _$Unauthenticated._(); 119 | replace(_$result); 120 | return _$result; 121 | } 122 | } 123 | 124 | class _$Uninitialized extends Uninitialized { 125 | factory _$Uninitialized([void Function(UninitializedBuilder) updates]) => 126 | (new UninitializedBuilder()..update(updates)).build(); 127 | 128 | _$Uninitialized._() : super._(); 129 | 130 | @override 131 | Uninitialized rebuild(void Function(UninitializedBuilder) updates) => 132 | (toBuilder()..update(updates)).build(); 133 | 134 | @override 135 | UninitializedBuilder toBuilder() => new UninitializedBuilder()..replace(this); 136 | 137 | @override 138 | bool operator ==(Object other) { 139 | if (identical(other, this)) return true; 140 | return other is Uninitialized; 141 | } 142 | 143 | @override 144 | int get hashCode { 145 | return 940951495; 146 | } 147 | 148 | @override 149 | String toString() { 150 | return newBuiltValueToStringHelper('Uninitialized').toString(); 151 | } 152 | } 153 | 154 | class UninitializedBuilder 155 | implements Builder { 156 | _$Uninitialized _$v; 157 | 158 | UninitializedBuilder(); 159 | 160 | @override 161 | void replace(Uninitialized other) { 162 | if (other == null) { 163 | throw new ArgumentError.notNull('other'); 164 | } 165 | _$v = other as _$Uninitialized; 166 | } 167 | 168 | @override 169 | void update(void Function(UninitializedBuilder) updates) { 170 | if (updates != null) updates(this); 171 | } 172 | 173 | @override 174 | _$Uninitialized build() { 175 | final _$result = _$v ?? new _$Uninitialized._(); 176 | replace(_$result); 177 | return _$result; 178 | } 179 | } 180 | 181 | // ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new 182 | -------------------------------------------------------------------------------- /lib/authentication/authentication_events.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'authentication_events.dart'; 4 | 5 | // ************************************************************************** 6 | // BuiltValueGenerator 7 | // ************************************************************************** 8 | 9 | class _$AppStarted extends AppStarted { 10 | factory _$AppStarted([void Function(AppStartedBuilder) updates]) => 11 | (new AppStartedBuilder()..update(updates)).build(); 12 | 13 | _$AppStarted._() : super._(); 14 | 15 | @override 16 | AppStarted rebuild(void Function(AppStartedBuilder) updates) => 17 | (toBuilder()..update(updates)).build(); 18 | 19 | @override 20 | AppStartedBuilder toBuilder() => new AppStartedBuilder()..replace(this); 21 | 22 | @override 23 | bool operator ==(Object other) { 24 | if (identical(other, this)) return true; 25 | return other is AppStarted; 26 | } 27 | 28 | @override 29 | int get hashCode { 30 | return 805240986; 31 | } 32 | 33 | @override 34 | String toString() { 35 | return newBuiltValueToStringHelper('AppStarted').toString(); 36 | } 37 | } 38 | 39 | class AppStartedBuilder implements Builder { 40 | _$AppStarted _$v; 41 | 42 | AppStartedBuilder(); 43 | 44 | @override 45 | void replace(AppStarted other) { 46 | if (other == null) { 47 | throw new ArgumentError.notNull('other'); 48 | } 49 | _$v = other as _$AppStarted; 50 | } 51 | 52 | @override 53 | void update(void Function(AppStartedBuilder) updates) { 54 | if (updates != null) updates(this); 55 | } 56 | 57 | @override 58 | _$AppStarted build() { 59 | final _$result = _$v ?? new _$AppStarted._(); 60 | replace(_$result); 61 | return _$result; 62 | } 63 | } 64 | 65 | class _$Authenticate extends Authenticate { 66 | @override 67 | final String code; 68 | 69 | factory _$Authenticate([void Function(AuthenticateBuilder) updates]) => 70 | (new AuthenticateBuilder()..update(updates)).build(); 71 | 72 | _$Authenticate._({this.code}) : super._() { 73 | if (code == null) { 74 | throw new BuiltValueNullFieldError('Authenticate', 'code'); 75 | } 76 | } 77 | 78 | @override 79 | Authenticate rebuild(void Function(AuthenticateBuilder) updates) => 80 | (toBuilder()..update(updates)).build(); 81 | 82 | @override 83 | AuthenticateBuilder toBuilder() => new AuthenticateBuilder()..replace(this); 84 | 85 | @override 86 | bool operator ==(Object other) { 87 | if (identical(other, this)) return true; 88 | return other is Authenticate && code == other.code; 89 | } 90 | 91 | @override 92 | int get hashCode { 93 | return $jf($jc(0, code.hashCode)); 94 | } 95 | 96 | @override 97 | String toString() { 98 | return (newBuiltValueToStringHelper('Authenticate')..add('code', code)) 99 | .toString(); 100 | } 101 | } 102 | 103 | class AuthenticateBuilder 104 | implements Builder { 105 | _$Authenticate _$v; 106 | 107 | String _code; 108 | String get code => _$this._code; 109 | set code(String code) => _$this._code = code; 110 | 111 | AuthenticateBuilder(); 112 | 113 | AuthenticateBuilder get _$this { 114 | if (_$v != null) { 115 | _code = _$v.code; 116 | _$v = null; 117 | } 118 | return this; 119 | } 120 | 121 | @override 122 | void replace(Authenticate other) { 123 | if (other == null) { 124 | throw new ArgumentError.notNull('other'); 125 | } 126 | _$v = other as _$Authenticate; 127 | } 128 | 129 | @override 130 | void update(void Function(AuthenticateBuilder) updates) { 131 | if (updates != null) updates(this); 132 | } 133 | 134 | @override 135 | _$Authenticate build() { 136 | final _$result = _$v ?? new _$Authenticate._(code: code); 137 | replace(_$result); 138 | return _$result; 139 | } 140 | } 141 | 142 | class _$SignOut extends SignOut { 143 | factory _$SignOut([void Function(SignOutBuilder) updates]) => 144 | (new SignOutBuilder()..update(updates)).build(); 145 | 146 | _$SignOut._() : super._(); 147 | 148 | @override 149 | SignOut rebuild(void Function(SignOutBuilder) updates) => 150 | (toBuilder()..update(updates)).build(); 151 | 152 | @override 153 | SignOutBuilder toBuilder() => new SignOutBuilder()..replace(this); 154 | 155 | @override 156 | bool operator ==(Object other) { 157 | if (identical(other, this)) return true; 158 | return other is SignOut; 159 | } 160 | 161 | @override 162 | int get hashCode { 163 | return 957153408; 164 | } 165 | 166 | @override 167 | String toString() { 168 | return newBuiltValueToStringHelper('SignOut').toString(); 169 | } 170 | } 171 | 172 | class SignOutBuilder implements Builder { 173 | _$SignOut _$v; 174 | 175 | SignOutBuilder(); 176 | 177 | @override 178 | void replace(SignOut other) { 179 | if (other == null) { 180 | throw new ArgumentError.notNull('other'); 181 | } 182 | _$v = other as _$SignOut; 183 | } 184 | 185 | @override 186 | void update(void Function(SignOutBuilder) updates) { 187 | if (updates != null) updates(this); 188 | } 189 | 190 | @override 191 | _$SignOut build() { 192 | final _$result = _$v ?? new _$SignOut._(); 193 | replace(_$result); 194 | return _$result; 195 | } 196 | } 197 | 198 | // ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,lines_longer_than_80_chars,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new 199 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:bloc/bloc.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter/services.dart'; 6 | import 'package:flutter_aws_app/authentication/authentication.dart'; 7 | import 'package:flutter_aws_app/identity/identity.dart'; 8 | import 'package:flutter_aws_app/packages/query_repository.dart'; 9 | import 'package:flutter_aws_app/packages/repository.dart'; 10 | import 'package:flutter_bloc/flutter_bloc.dart'; 11 | import 'package:uni_links/uni_links.dart'; 12 | 13 | import 'home/home.dart'; 14 | 15 | class SimpleBlocDelegate extends BlocDelegate { 16 | @override 17 | void onTransition(Bloc bloc, Transition transition) { 18 | super.onTransition(bloc, transition); 19 | print(transition); 20 | } 21 | } 22 | 23 | // The main entry point of this application. 24 | void main() async { 25 | // Bloc logging. 26 | BlocSupervisor().delegate = SimpleBlocDelegate(); 27 | // AWS Cognito. 28 | IdentityRepository identityRepository = IdentityRepository( 29 | region: "us-east-1", 30 | userPoolDomainPrefix: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", 31 | userPoolId: "us-east-1_xxxxxxxxx", 32 | userPoolAppClientId: "xxxxxxxxxxxxxxxxxxxxxxxxxx", 33 | identityPoolId: "us-east-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", 34 | cognitoIdentityPoolUrl: "https://cognito-identity.us-east-1.amazonaws.com", 35 | cognitoUserPoolLoginRedirectUrl: "https://my.app", 36 | cognitoUserPoolLogoutRedirectUrl: "https://my.app", 37 | cognitoUserPoolLoginScopes: "phone email openid profile", 38 | ); 39 | // AWS AppSync. 40 | QueryRepository queryRepository = QueryRepository( 41 | endpoint: 42 | "https://xxxxxxxxxxxxxxxxxxxxxxxxxx.appsync-api.us-east-1.amazonaws.com", 43 | region: "us-east-1", 44 | identityRepository: identityRepository, 45 | ); 46 | // Run the application page. 47 | runApp(AppPage(identityRepository, queryRepository)); 48 | } 49 | 50 | // The application's main page. 51 | class AppPage extends StatefulWidget { 52 | final IdentityRepository identityRepository; 53 | final QueryRepository queryRepository; 54 | 55 | AppPage(this.identityRepository, this.queryRepository); 56 | 57 | @override 58 | _AppPageState createState() => _AppPageState(); 59 | } 60 | 61 | // The application's main page state. 62 | class _AppPageState extends State { 63 | AuthenticationBloc _authenticationBloc; 64 | 65 | // A stream of deep links. 66 | StreamSubscription _linksStreamSubscription; 67 | 68 | // Initialize the platform. 69 | _initPlatformState() async { 70 | // Platform messages may fail, so we use a try/catch PlatformException. 71 | try { 72 | String initialLink = await getInitialLink(); 73 | // Parse the link and warn the user, if it is not correct, 74 | // but keep in mind it could be `null`. 75 | // ... 76 | } on PlatformException { 77 | // Handle exception by warning the user their action did not succeed 78 | // return? 79 | // ... 80 | } 81 | // Attach a listener to the stream. 82 | // Don't forget to call _sub.cancel() in dispose(). 83 | _linksStreamSubscription = getLinksStream().listen((String link) { 84 | // Parse the link and warn the user, if it is not correct 85 | // ... 86 | }, onError: (err) { 87 | // Handle exception by warning the user their action did not succeed 88 | // ... 89 | }); 90 | } 91 | 92 | // Dispose the platform. 93 | _disposePlatform() { 94 | _linksStreamSubscription.cancel(); 95 | } 96 | 97 | // Initialize the page. 98 | @override 99 | void initState() { 100 | super.initState(); 101 | _initPlatformState(); 102 | _authenticationBloc = 103 | AuthenticationBloc(identityRepository: widget.identityRepository); 104 | _authenticationBloc.dispatch(AppStarted()); 105 | } 106 | 107 | // Dispose the page. 108 | @override 109 | void dispose() { 110 | _authenticationBloc.dispose(); 111 | _disposePlatform(); 112 | super.dispose(); 113 | } 114 | 115 | // This widget is the root of your application. 116 | @override 117 | Widget build(BuildContext context) { 118 | return RepositoryProviderTree( 119 | repositoryProviders: [ 120 | RepositoryProvider( 121 | repository: widget.identityRepository, 122 | ), 123 | RepositoryProvider( 124 | repository: widget.queryRepository, 125 | ) 126 | ], 127 | child: BlocProviderTree( 128 | blocProviders: [ 129 | BlocProvider(bloc: _authenticationBloc), 130 | ], 131 | child: BlocBuilder( 132 | bloc: _authenticationBloc, 133 | builder: 134 | (BuildContext context, AuthenticationState authenticationState) { 135 | return MaterialApp( 136 | title: 'Flutter Demo', 137 | theme: ThemeData( 138 | // This is the theme of your application. 139 | // 140 | // Try running your application with "flutter run". You'll see the 141 | // application has a blue toolbar. Then, without quitting the app, try 142 | // changing the primarySwatch below to Colors.green and then invoke 143 | // "hot reload" (press "r" in the console where you ran "flutter run", 144 | // or simply save your changes to "hot reload" in a Flutter IDE). 145 | // Notice that the counter didn't reset back to zero; the application 146 | // is not restarted. 147 | primarySwatch: Colors.blue, 148 | ), 149 | onGenerateRoute: (RouteSettings routeSettings) { 150 | switch (routeSettings.name) { 151 | case '/': 152 | return MaterialPageRoute( 153 | builder: (context) => HomePage( 154 | title: "Bernd", 155 | )); 156 | case '/identity/signin': 157 | return MaterialPageRoute( 158 | builder: (context) => IdentitySignInPage()); 159 | case '/identity/signout': 160 | return MaterialPageRoute( 161 | builder: (context) => IdentitySignOutPage()); 162 | } 163 | }, 164 | ); 165 | }, 166 | ), 167 | ), 168 | ); 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /lib/home/home_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_aws_app/authentication/authentication.dart'; 3 | import 'package:flutter_aws_app/home/home.dart'; 4 | import 'package:flutter_aws_app/packages/query_repository.dart'; 5 | import 'package:flutter_aws_app/packages/repository.dart'; 6 | import 'package:flutter_bloc/flutter_bloc.dart'; 7 | import 'package:modal_progress_hud/modal_progress_hud.dart'; 8 | 9 | // This widget is the home page of your application. It is stateful, meaning 10 | // that it has a State object (defined below) that contains fields that affect 11 | // how it looks. 12 | class HomePage extends StatefulWidget { 13 | HomePage({Key key, this.title}) : super(key: key); 14 | 15 | // This class is the configuration for the state. It holds the values (in this 16 | // case the title) provided by the parent (in this case the App widget) and 17 | // used by the build method of the State. Fields in a Widget subclass are 18 | // always marked "final". 19 | 20 | final String title; 21 | 22 | @override 23 | _HomePageState createState() => _HomePageState(); 24 | } 25 | 26 | class _HomePageState extends State { 27 | QueryRepository _queryRepository; 28 | AuthenticationBloc _authenticationBloc; 29 | HomeBloc _homeBloc; 30 | int _counter = 0; 31 | 32 | @override 33 | void initState() { 34 | _queryRepository = RepositoryProvider.of(context); 35 | _authenticationBloc = BlocProvider.of(context); 36 | _homeBloc = HomeBloc(queryRepository: _queryRepository); 37 | _homeBloc.dispatch(Initialize()); 38 | // _homeBloc.dispatch(Fetch( 39 | // (b) => b 40 | // ..operationName = "listPets" 41 | // ..query = """ 42 | // query listPets { 43 | // listPets { 44 | // id 45 | // price 46 | // type 47 | // } 48 | // } 49 | // """, 50 | // )); 51 | super.initState(); 52 | } 53 | 54 | @override 55 | void dispose() { 56 | _homeBloc.dispose(); 57 | super.dispose(); 58 | } 59 | 60 | void _incrementCounter() async { 61 | setState(() { 62 | // This call to setState tells the Flutter framework that something has 63 | // changed in this State, which causes it to rerun the build method below 64 | // so that the display can reflect the updated values. If we changed 65 | // _counter without calling setState(), then the build method would not be 66 | // called again, and so nothing would appear to happen. 67 | _counter++; 68 | }); 69 | } 70 | 71 | @override 72 | Widget build(BuildContext context) { 73 | // This method is rerun every time setState is called, for instance as done 74 | // by the _incrementCounter method above. 75 | // 76 | // The Flutter framework has been optimized to make rerunning build methods 77 | // fast, so that you can just rebuild anything that needs updating rather 78 | // than having to individually change instances of widgets. 79 | return BlocBuilder( 80 | bloc: _authenticationBloc, 81 | builder: (BuildContext context, AuthenticationState authenticationState) { 82 | return Scaffold( 83 | appBar: AppBar( 84 | // Here we take the value from the MyHomePage object that was created by 85 | // the App.build method, and use it to set our appbar title. 86 | title: Text(widget.title), 87 | actions: [ 88 | authenticationState is Authenticated 89 | ? IconButton( 90 | icon: Icon(Icons.person), 91 | onPressed: () { 92 | Navigator.pushNamed(context, "/identity/signout"); 93 | }, 94 | ) 95 | : IconButton( 96 | icon: Icon(Icons.person_outline), 97 | onPressed: () { 98 | Navigator.pushNamed(context, "/identity/signin"); 99 | }, 100 | ) 101 | ], 102 | ), 103 | body: BlocBuilder( 104 | bloc: _homeBloc, 105 | builder: (BuildContext context, HomeState queryState) { 106 | return ModalProgressHUD( 107 | inAsyncCall: queryState is HomeLoading, 108 | dismissible: false, 109 | opacity: .8, 110 | color: Colors.white, 111 | child: Center( 112 | // Center is a layout widget. It takes a single child and positions it 113 | // in the middle of the parent. 114 | child: Column( 115 | // Column is also layout widget. It takes a list of children and 116 | // arranges them vertically. By default, it sizes itself to fit its 117 | // children horizontally, and tries to be as tall as its parent. 118 | // 119 | // Invoke "debug painting" (press "p" in the console, choose the 120 | // "Toggle Debug Paint" action from the Flutter Inspector in Android 121 | // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) 122 | // to see the wireframe for each widget. 123 | // 124 | // Column has various properties to control how it sizes itself and 125 | // how it positions its children. Here we use mainAxisAlignment to 126 | // center the children vertically; the main axis here is the vertical 127 | // axis because Columns are vertical (the cross axis would be 128 | // horizontal). 129 | mainAxisAlignment: MainAxisAlignment.center, 130 | children: [ 131 | Text( 132 | 'You have pushed the button this many times: !!!', 133 | ), 134 | Text( 135 | '$_counter', 136 | style: Theme.of(context).textTheme.display1, 137 | ), 138 | ], 139 | ), 140 | )); 141 | }), 142 | floatingActionButton: FloatingActionButton( 143 | onPressed: _incrementCounter, 144 | tooltip: 'Increment', 145 | child: Icon(Icons.add), 146 | ), // This trailing comma makes auto-formatting nicer for build methods. 147 | ); 148 | }, 149 | ); 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /lib/packages/sig_v4.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'package:convert/convert.dart'; 3 | import 'package:crypto/crypto.dart'; 4 | 5 | const _aws_sha_256 = 'AWS4-HMAC-SHA256'; 6 | const _aws4_request = 'aws4_request'; 7 | const _aws4 = 'AWS4'; 8 | const _x_amz_date = 'x-amz-date'; 9 | const _x_amz_security_token = 'x-amz-security-token'; 10 | const _host = 'host'; 11 | const _authorization = 'Authorization'; 12 | const _default_content_type = 'application/json; charset=utf-8'; 13 | const _default_accept_type = 'application/json'; 14 | 15 | class AwsSigV4Client { 16 | String endpoint; 17 | String pathComponent; 18 | String region; 19 | String accessKey; 20 | String secretKey; 21 | String sessionToken; 22 | String serviceName; 23 | String defaultContentType; 24 | String defaultAcceptType; 25 | AwsSigV4Client(this.accessKey, this.secretKey, String endpoint, 26 | {this.serviceName = 'execute-api', 27 | this.region = 'us-east-1', 28 | this.sessionToken, 29 | this.defaultContentType = _default_content_type, 30 | this.defaultAcceptType = _default_accept_type}) { 31 | final parsedUri = Uri.parse(endpoint); 32 | this.endpoint = '${parsedUri.scheme}://${parsedUri.host}'; 33 | this.pathComponent = parsedUri.path; 34 | } 35 | } 36 | 37 | class SigV4Request { 38 | String method; 39 | String path; 40 | Map queryParams; 41 | Map headers; 42 | String url; 43 | String body; 44 | AwsSigV4Client awsSigV4Client; 45 | String canonicalRequest; 46 | String hashedCanonicalRequest; 47 | String credentialScope; 48 | String stringToSign; 49 | String datetime; 50 | List signingKey; 51 | String signature; 52 | SigV4Request( 53 | this.awsSigV4Client, { 54 | String method, 55 | String path, 56 | this.datetime, 57 | this.queryParams, 58 | this.headers, 59 | dynamic body, 60 | }) { 61 | this.method = method.toUpperCase(); 62 | this.path = '${awsSigV4Client.pathComponent}$path'; 63 | if (headers == null) { 64 | headers = {}; 65 | } 66 | if (headers['Content-Type'] == null) { 67 | headers['Content-Type'] = awsSigV4Client.defaultContentType; 68 | } 69 | if (headers['Accept'] == null) { 70 | headers['Accept'] = awsSigV4Client.defaultAcceptType; 71 | } 72 | if (body == null || this.method == 'GET') { 73 | this.body = ''; 74 | } else { 75 | this.body = json.encode(body); 76 | } 77 | if (body == '') { 78 | headers.remove('Content-Type'); 79 | } 80 | if (datetime == null) { 81 | datetime = SigV4.generateDatetime(); 82 | } 83 | headers[_x_amz_date] = datetime; 84 | final endpointUri = Uri.parse(awsSigV4Client.endpoint); 85 | headers[_host] = endpointUri.host; 86 | 87 | headers[_authorization] = _generateAuthorization(datetime); 88 | if (awsSigV4Client.sessionToken != null) { 89 | headers[_x_amz_security_token] = awsSigV4Client.sessionToken; 90 | } 91 | headers.remove(_host); 92 | 93 | url = _generateUrl(); 94 | 95 | if (headers['Content-Type'] == null) { 96 | headers['Content-Type'] = awsSigV4Client.defaultContentType; 97 | } 98 | } 99 | 100 | String _generateUrl() { 101 | var url = '${awsSigV4Client.endpoint}$path'; 102 | if (queryParams != null) { 103 | final queryString = SigV4.buildCanonicalQueryString(queryParams); 104 | if (queryString != '') { 105 | url += '?$queryString'; 106 | } 107 | } 108 | return url; 109 | } 110 | 111 | String _generateAuthorization(String datetime) { 112 | canonicalRequest = 113 | SigV4.buildCanonicalRequest(method, path, queryParams, headers, body); 114 | hashedCanonicalRequest = SigV4.hashCanonicalRequest(canonicalRequest); 115 | credentialScope = SigV4.buildCredentialScope( 116 | datetime, awsSigV4Client.region, awsSigV4Client.serviceName); 117 | stringToSign = SigV4.buildStringToSign( 118 | datetime, credentialScope, hashedCanonicalRequest); 119 | signingKey = SigV4.calculateSigningKey(awsSigV4Client.secretKey, datetime, 120 | awsSigV4Client.region, awsSigV4Client.serviceName); 121 | signature = SigV4.calculateSignature(signingKey, stringToSign); 122 | return SigV4.buildAuthorizationHeader( 123 | awsSigV4Client.accessKey, credentialScope, headers, signature); 124 | } 125 | } 126 | 127 | class SigV4 { 128 | static String generateDatetime() { 129 | return new DateTime.now() 130 | .toUtc() 131 | .toString() 132 | .replaceAll(new RegExp(r'\.\d*Z$'), 'Z') 133 | .replaceAll(new RegExp(r'[:-]|\.\d{3}'), '') 134 | .split(' ') 135 | .join('T'); 136 | } 137 | 138 | static List hash(List value) { 139 | return sha256.convert(value).bytes; 140 | } 141 | 142 | static String hexEncode(List value) { 143 | return hex.encode(value); 144 | } 145 | 146 | static List sign(List key, String message) { 147 | Hmac hmac = new Hmac(sha256, key); 148 | Digest dig = hmac.convert(utf8.encode(message)); 149 | return dig.bytes; 150 | } 151 | 152 | static String hashCanonicalRequest(String request) { 153 | return hexEncode(hash(utf8.encode(request))); 154 | } 155 | 156 | static String buildCanonicalUri(String uri) { 157 | return Uri.encodeFull(uri); 158 | } 159 | 160 | static String buildCanonicalQueryString(Map queryParams) { 161 | if (queryParams == null) { 162 | return ''; 163 | } 164 | 165 | final List sortedQueryParams = []; 166 | queryParams.forEach((key, value) { 167 | sortedQueryParams.add(key); 168 | }); 169 | sortedQueryParams.sort(); 170 | 171 | final List canonicalQueryStrings = []; 172 | sortedQueryParams.forEach((key) { 173 | canonicalQueryStrings 174 | .add('$key=${Uri.encodeComponent(queryParams[key])}'); 175 | }); 176 | 177 | return canonicalQueryStrings.join('&'); 178 | } 179 | 180 | static String buildCanonicalHeaders(Map headers) { 181 | final List sortedKeys = []; 182 | headers.forEach((property, _) { 183 | sortedKeys.add(property); 184 | }); 185 | 186 | var canonicalHeaders = ''; 187 | sortedKeys.sort((a, b) => a.toLowerCase().compareTo(b.toLowerCase())); 188 | 189 | sortedKeys.forEach((property) { 190 | canonicalHeaders += '${property.toLowerCase()}:${headers[property]}\n'; 191 | }); 192 | 193 | return canonicalHeaders; 194 | } 195 | 196 | static String buildCanonicalSignedHeaders(Map headers) { 197 | final List sortedKeys = []; 198 | headers.forEach((property, _) { 199 | sortedKeys.add(property.toLowerCase()); 200 | }); 201 | sortedKeys.sort(); 202 | 203 | return sortedKeys.join(';'); 204 | } 205 | 206 | static String buildStringToSign( 207 | String datetime, String credentialScope, String hashedCanonicalRequest) { 208 | return '$_aws_sha_256\n$datetime\n$credentialScope\n$hashedCanonicalRequest'; 209 | } 210 | 211 | static String buildCredentialScope( 212 | String datetime, String region, String service) { 213 | return '${datetime.substring(0, 8)}/$region/$service/$_aws4_request'; 214 | } 215 | 216 | static String buildCanonicalRequest( 217 | String method, 218 | String path, 219 | Map queryParams, 220 | Map headers, 221 | String payload) { 222 | List canonicalRequest = [ 223 | method, 224 | buildCanonicalUri(path), 225 | buildCanonicalQueryString(queryParams), 226 | buildCanonicalHeaders(headers), 227 | buildCanonicalSignedHeaders(headers), 228 | hexEncode(hash(utf8.encode(payload))), 229 | ]; 230 | // print(canonicalRequest.join('\n')); 231 | return canonicalRequest.join('\n'); 232 | } 233 | 234 | static String buildAuthorizationHeader(String accessKey, 235 | String credentialScope, Map headers, String signature) { 236 | return _aws_sha_256 + 237 | ' Credential=' + 238 | accessKey + 239 | '/' + 240 | credentialScope + 241 | ', SignedHeaders=' + 242 | buildCanonicalSignedHeaders(headers) + 243 | ', Signature=' + 244 | signature; 245 | } 246 | 247 | static List calculateSigningKey( 248 | String secretKey, String datetime, String region, String service) { 249 | return sign( 250 | sign( 251 | sign( 252 | sign(utf8.encode('$_aws4$secretKey'), datetime.substring(0, 8)), 253 | region), 254 | service), 255 | _aws4_request); 256 | } 257 | 258 | static String calculateSignature(List signingKey, String stringToSign) { 259 | return hexEncode(sign(signingKey, stringToSign)); 260 | } 261 | } 262 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://www.dartlang.org/tools/pub/glossary#lockfile 3 | packages: 4 | analyzer: 5 | dependency: transitive 6 | description: 7 | name: analyzer 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "0.36.3" 11 | analyzer_plugin: 12 | dependency: transitive 13 | description: 14 | name: analyzer_plugin 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "0.0.1-alpha.8" 18 | args: 19 | dependency: transitive 20 | description: 21 | name: args 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.5.1" 25 | async: 26 | dependency: transitive 27 | description: 28 | name: async 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "2.1.0" 32 | bloc: 33 | dependency: "direct main" 34 | description: 35 | name: bloc 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "0.13.0" 39 | boolean_selector: 40 | dependency: transitive 41 | description: 42 | name: boolean_selector 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.0.4" 46 | build: 47 | dependency: transitive 48 | description: 49 | name: build 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "1.1.4" 53 | build_config: 54 | dependency: transitive 55 | description: 56 | name: build_config 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "0.4.0" 60 | build_daemon: 61 | dependency: transitive 62 | description: 63 | name: build_daemon 64 | url: "https://pub.dartlang.org" 65 | source: hosted 66 | version: "1.0.0" 67 | build_resolvers: 68 | dependency: transitive 69 | description: 70 | name: build_resolvers 71 | url: "https://pub.dartlang.org" 72 | source: hosted 73 | version: "1.0.5" 74 | build_runner: 75 | dependency: "direct dev" 76 | description: 77 | name: build_runner 78 | url: "https://pub.dartlang.org" 79 | source: hosted 80 | version: "1.5.0" 81 | build_runner_core: 82 | dependency: transitive 83 | description: 84 | name: build_runner_core 85 | url: "https://pub.dartlang.org" 86 | source: hosted 87 | version: "3.0.5" 88 | built_collection: 89 | dependency: "direct main" 90 | description: 91 | name: built_collection 92 | url: "https://pub.dartlang.org" 93 | source: hosted 94 | version: "4.2.2" 95 | built_value: 96 | dependency: "direct main" 97 | description: 98 | name: built_value 99 | url: "https://pub.dartlang.org" 100 | source: hosted 101 | version: "6.5.0" 102 | built_value_generator: 103 | dependency: "direct dev" 104 | description: 105 | name: built_value_generator 106 | url: "https://pub.dartlang.org" 107 | source: hosted 108 | version: "6.5.0" 109 | charcode: 110 | dependency: transitive 111 | description: 112 | name: charcode 113 | url: "https://pub.dartlang.org" 114 | source: hosted 115 | version: "1.1.2" 116 | code_builder: 117 | dependency: transitive 118 | description: 119 | name: code_builder 120 | url: "https://pub.dartlang.org" 121 | source: hosted 122 | version: "3.2.0" 123 | collection: 124 | dependency: transitive 125 | description: 126 | name: collection 127 | url: "https://pub.dartlang.org" 128 | source: hosted 129 | version: "1.14.11" 130 | convert: 131 | dependency: transitive 132 | description: 133 | name: convert 134 | url: "https://pub.dartlang.org" 135 | source: hosted 136 | version: "2.1.1" 137 | crypto: 138 | dependency: "direct main" 139 | description: 140 | name: crypto 141 | url: "https://pub.dartlang.org" 142 | source: hosted 143 | version: "2.0.6" 144 | csslib: 145 | dependency: transitive 146 | description: 147 | name: csslib 148 | url: "https://pub.dartlang.org" 149 | source: hosted 150 | version: "0.16.0" 151 | cupertino_icons: 152 | dependency: "direct main" 153 | description: 154 | name: cupertino_icons 155 | url: "https://pub.dartlang.org" 156 | source: hosted 157 | version: "0.1.2" 158 | dart_style: 159 | dependency: transitive 160 | description: 161 | name: dart_style 162 | url: "https://pub.dartlang.org" 163 | source: hosted 164 | version: "1.2.7" 165 | fixnum: 166 | dependency: transitive 167 | description: 168 | name: fixnum 169 | url: "https://pub.dartlang.org" 170 | source: hosted 171 | version: "0.10.9" 172 | flutter: 173 | dependency: "direct main" 174 | description: flutter 175 | source: sdk 176 | version: "0.0.0" 177 | flutter_bloc: 178 | dependency: "direct main" 179 | description: 180 | name: flutter_bloc 181 | url: "https://pub.dartlang.org" 182 | source: hosted 183 | version: "0.13.0" 184 | flutter_secure_storage: 185 | dependency: "direct main" 186 | description: 187 | name: flutter_secure_storage 188 | url: "https://pub.dartlang.org" 189 | source: hosted 190 | version: "3.2.1+1" 191 | flutter_test: 192 | dependency: "direct dev" 193 | description: flutter 194 | source: sdk 195 | version: "0.0.0" 196 | flutter_webview_plugin: 197 | dependency: "direct main" 198 | description: 199 | name: flutter_webview_plugin 200 | url: "https://pub.dartlang.org" 201 | source: hosted 202 | version: "0.3.4" 203 | front_end: 204 | dependency: transitive 205 | description: 206 | name: front_end 207 | url: "https://pub.dartlang.org" 208 | source: hosted 209 | version: "0.1.18" 210 | glob: 211 | dependency: transitive 212 | description: 213 | name: glob 214 | url: "https://pub.dartlang.org" 215 | source: hosted 216 | version: "1.1.7" 217 | graphs: 218 | dependency: transitive 219 | description: 220 | name: graphs 221 | url: "https://pub.dartlang.org" 222 | source: hosted 223 | version: "0.2.0" 224 | html: 225 | dependency: transitive 226 | description: 227 | name: html 228 | url: "https://pub.dartlang.org" 229 | source: hosted 230 | version: "0.14.0+2" 231 | http: 232 | dependency: "direct main" 233 | description: 234 | name: http 235 | url: "https://pub.dartlang.org" 236 | source: hosted 237 | version: "0.12.0+2" 238 | http_multi_server: 239 | dependency: transitive 240 | description: 241 | name: http_multi_server 242 | url: "https://pub.dartlang.org" 243 | source: hosted 244 | version: "2.0.6" 245 | http_parser: 246 | dependency: transitive 247 | description: 248 | name: http_parser 249 | url: "https://pub.dartlang.org" 250 | source: hosted 251 | version: "3.1.3" 252 | io: 253 | dependency: transitive 254 | description: 255 | name: io 256 | url: "https://pub.dartlang.org" 257 | source: hosted 258 | version: "0.3.3" 259 | js: 260 | dependency: transitive 261 | description: 262 | name: js 263 | url: "https://pub.dartlang.org" 264 | source: hosted 265 | version: "0.6.1+1" 266 | json_annotation: 267 | dependency: transitive 268 | description: 269 | name: json_annotation 270 | url: "https://pub.dartlang.org" 271 | source: hosted 272 | version: "2.4.0" 273 | kernel: 274 | dependency: transitive 275 | description: 276 | name: kernel 277 | url: "https://pub.dartlang.org" 278 | source: hosted 279 | version: "0.3.18" 280 | logging: 281 | dependency: transitive 282 | description: 283 | name: logging 284 | url: "https://pub.dartlang.org" 285 | source: hosted 286 | version: "0.11.3+2" 287 | matcher: 288 | dependency: transitive 289 | description: 290 | name: matcher 291 | url: "https://pub.dartlang.org" 292 | source: hosted 293 | version: "0.12.5" 294 | meta: 295 | dependency: transitive 296 | description: 297 | name: meta 298 | url: "https://pub.dartlang.org" 299 | source: hosted 300 | version: "1.1.6" 301 | mime: 302 | dependency: transitive 303 | description: 304 | name: mime 305 | url: "https://pub.dartlang.org" 306 | source: hosted 307 | version: "0.9.6+3" 308 | modal_progress_hud: 309 | dependency: "direct main" 310 | description: 311 | name: modal_progress_hud 312 | url: "https://pub.dartlang.org" 313 | source: hosted 314 | version: "0.1.3" 315 | package_config: 316 | dependency: transitive 317 | description: 318 | name: package_config 319 | url: "https://pub.dartlang.org" 320 | source: hosted 321 | version: "1.0.5" 322 | package_resolver: 323 | dependency: transitive 324 | description: 325 | name: package_resolver 326 | url: "https://pub.dartlang.org" 327 | source: hosted 328 | version: "1.0.10" 329 | path: 330 | dependency: transitive 331 | description: 332 | name: path 333 | url: "https://pub.dartlang.org" 334 | source: hosted 335 | version: "1.6.2" 336 | pedantic: 337 | dependency: transitive 338 | description: 339 | name: pedantic 340 | url: "https://pub.dartlang.org" 341 | source: hosted 342 | version: "1.5.0" 343 | pool: 344 | dependency: transitive 345 | description: 346 | name: pool 347 | url: "https://pub.dartlang.org" 348 | source: hosted 349 | version: "1.4.0" 350 | pub_semver: 351 | dependency: transitive 352 | description: 353 | name: pub_semver 354 | url: "https://pub.dartlang.org" 355 | source: hosted 356 | version: "1.4.2" 357 | pubspec_parse: 358 | dependency: transitive 359 | description: 360 | name: pubspec_parse 361 | url: "https://pub.dartlang.org" 362 | source: hosted 363 | version: "0.1.4" 364 | quiver: 365 | dependency: transitive 366 | description: 367 | name: quiver 368 | url: "https://pub.dartlang.org" 369 | source: hosted 370 | version: "2.0.2" 371 | rxdart: 372 | dependency: transitive 373 | description: 374 | name: rxdart 375 | url: "https://pub.dartlang.org" 376 | source: hosted 377 | version: "0.22.0" 378 | shelf: 379 | dependency: transitive 380 | description: 381 | name: shelf 382 | url: "https://pub.dartlang.org" 383 | source: hosted 384 | version: "0.7.5" 385 | shelf_web_socket: 386 | dependency: transitive 387 | description: 388 | name: shelf_web_socket 389 | url: "https://pub.dartlang.org" 390 | source: hosted 391 | version: "0.2.3" 392 | sky_engine: 393 | dependency: transitive 394 | description: flutter 395 | source: sdk 396 | version: "0.0.99" 397 | source_gen: 398 | dependency: transitive 399 | description: 400 | name: source_gen 401 | url: "https://pub.dartlang.org" 402 | source: hosted 403 | version: "0.9.4+2" 404 | source_span: 405 | dependency: transitive 406 | description: 407 | name: source_span 408 | url: "https://pub.dartlang.org" 409 | source: hosted 410 | version: "1.5.5" 411 | stack_trace: 412 | dependency: transitive 413 | description: 414 | name: stack_trace 415 | url: "https://pub.dartlang.org" 416 | source: hosted 417 | version: "1.9.3" 418 | stream_channel: 419 | dependency: transitive 420 | description: 421 | name: stream_channel 422 | url: "https://pub.dartlang.org" 423 | source: hosted 424 | version: "2.0.0" 425 | stream_transform: 426 | dependency: transitive 427 | description: 428 | name: stream_transform 429 | url: "https://pub.dartlang.org" 430 | source: hosted 431 | version: "0.0.19" 432 | string_scanner: 433 | dependency: transitive 434 | description: 435 | name: string_scanner 436 | url: "https://pub.dartlang.org" 437 | source: hosted 438 | version: "1.0.4" 439 | term_glyph: 440 | dependency: transitive 441 | description: 442 | name: term_glyph 443 | url: "https://pub.dartlang.org" 444 | source: hosted 445 | version: "1.1.0" 446 | test_api: 447 | dependency: transitive 448 | description: 449 | name: test_api 450 | url: "https://pub.dartlang.org" 451 | source: hosted 452 | version: "0.2.4" 453 | timing: 454 | dependency: transitive 455 | description: 456 | name: timing 457 | url: "https://pub.dartlang.org" 458 | source: hosted 459 | version: "0.1.1+1" 460 | typed_data: 461 | dependency: transitive 462 | description: 463 | name: typed_data 464 | url: "https://pub.dartlang.org" 465 | source: hosted 466 | version: "1.1.6" 467 | uni_links: 468 | dependency: "direct main" 469 | description: 470 | name: uni_links 471 | url: "https://pub.dartlang.org" 472 | source: hosted 473 | version: "0.2.0" 474 | vector_math: 475 | dependency: transitive 476 | description: 477 | name: vector_math 478 | url: "https://pub.dartlang.org" 479 | source: hosted 480 | version: "2.0.8" 481 | watcher: 482 | dependency: transitive 483 | description: 484 | name: watcher 485 | url: "https://pub.dartlang.org" 486 | source: hosted 487 | version: "0.9.7+10" 488 | web_socket_channel: 489 | dependency: transitive 490 | description: 491 | name: web_socket_channel 492 | url: "https://pub.dartlang.org" 493 | source: hosted 494 | version: "1.0.13" 495 | yaml: 496 | dependency: transitive 497 | description: 498 | name: yaml 499 | url: "https://pub.dartlang.org" 500 | source: hosted 501 | version: "2.1.15" 502 | sdks: 503 | dart: ">=2.3.0-dev.0.1 <3.0.0" 504 | flutter: ">=0.1.4 <2.0.0" 505 | -------------------------------------------------------------------------------- /lib/identity/identity_repository.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter_aws_app/authentication/authentication.dart'; 4 | import 'package:flutter_aws_app/packages/repository.dart'; 5 | import 'package:flutter_secure_storage/flutter_secure_storage.dart'; 6 | import 'package:http/http.dart' as http; 7 | import 'package:meta/meta.dart'; 8 | 9 | class IdentityRepository extends Repository { 10 | final String region; 11 | final String userPoolDomainPrefix; 12 | final String userPoolId; 13 | final String userPoolAppClientId; 14 | final String identityPoolId; 15 | final String cognitoIdentityPoolUrl; 16 | final String cognitoUserPoolLoginRedirectUrl; 17 | final String cognitoUserPoolLogoutRedirectUrl; 18 | final String cognitoUserPoolLoginScopes; 19 | 20 | IdentityRepository({ 21 | @required this.region, 22 | @required this.userPoolDomainPrefix, 23 | @required this.userPoolId, 24 | @required this.userPoolAppClientId, 25 | @required this.identityPoolId, 26 | @required this.cognitoIdentityPoolUrl, 27 | @required this.cognitoUserPoolLoginRedirectUrl, 28 | @required this.cognitoUserPoolLogoutRedirectUrl, 29 | @required this.cognitoUserPoolLoginScopes, 30 | }); 31 | 32 | String get cognitoUserPoolLoginUrl => 33 | "https://$userPoolDomainPrefix.auth.$region.amazoncognito.com/login?redirect_uri=${Uri.encodeFull(cognitoUserPoolLoginRedirectUrl)}&response_type=code&client_id=$userPoolAppClientId&identity_provider=COGNITO&scopes=${Uri.encodeFull(cognitoUserPoolLoginScopes)}"; 34 | 35 | String get cognitoUserPoolLogoutUrl => 36 | "https://$userPoolDomainPrefix.auth.$region.amazoncognito.com/logout?logout_uri=${Uri.encodeFull(cognitoUserPoolLogoutRedirectUrl)}&client_id=$userPoolAppClientId"; 37 | 38 | String get cognitoUserPoolTokenUrl => 39 | "https://$userPoolDomainPrefix.auth.$region.amazoncognito.com/oauth2/token"; 40 | 41 | Future isAuthenticated() async { 42 | // called on AppStarted 43 | _authenticationTokens = await _getStoredTokens(); 44 | return _authenticationTokens != null; 45 | } 46 | 47 | Future authenticate(String code) async { 48 | _authenticationTokens = await _exchangeGrantForTokens(code); 49 | if (_authenticationTokens == null) { 50 | return false; 51 | } 52 | return await _storeTokens(_authenticationTokens); 53 | } 54 | 55 | Future signOut() async { 56 | final storage = new FlutterSecureStorage(); 57 | await storage.delete(key: "AuthenticationTokens"); 58 | _authenticationTokens = null; 59 | await storage.delete(key: "AuthenticationIdentityId"); 60 | _authenticationIdentityId = null; 61 | await storage.delete(key: "AuthenticationCredentials"); 62 | _authenticationCredentials = null; 63 | return true; 64 | } 65 | 66 | Future get tokens async { 67 | // Do we have an authenticated user pool identity already? 68 | if (_authenticationTokens == null) { 69 | // Try to get the last user. 70 | _authenticationTokens = await _getStoredTokens(); 71 | } 72 | // Are the users tokens valid and not expired? 73 | if (_authenticationTokens != null && _authenticationTokens.hasExpired) { 74 | // Refresh the tokens and store them. 75 | _authenticationTokens = 76 | await _refreshTokens(_authenticationTokens.refreshToken); 77 | await _storeTokens(_authenticationTokens); 78 | } 79 | // If there hasn't been a last user then we return null, 80 | // otherwise we return the refreshed tokens. 81 | return _authenticationTokens; 82 | } 83 | 84 | Future get credentials async { 85 | // Do we have credentials already? 86 | if (_authenticationCredentials == null) { 87 | // Try to get the last credentials. 88 | _authenticationCredentials = await _getStoredCredentials(); 89 | } 90 | // Are the credentials valid and not expired? 91 | if (_authenticationCredentials == null || 92 | _authenticationCredentials.hasExpired) { 93 | // Do we have an identity pool identity already? 94 | if (_authenticationIdentityId == null) { 95 | // Try to get the last identity. 96 | _authenticationIdentityId = await _getStoredIdentityId(); 97 | // Do we have an identity? 98 | if (_authenticationIdentityId == null) { 99 | // Get a new identity for the user. 100 | _authenticationIdentityId = await _getNewIdentity(); 101 | // Store it. 102 | _storeIdentityId(_authenticationIdentityId); 103 | } 104 | } 105 | // Get valid user pool tokens. 106 | _authenticationTokens = await tokens; 107 | // Get new credentials for the user. 108 | _authenticationCredentials = await _getNewCredentials( 109 | _authenticationIdentityId, _authenticationTokens); 110 | if (_authenticationCredentials != null) { 111 | await _storeCredentials(_authenticationCredentials); 112 | } 113 | } 114 | return _authenticationCredentials; 115 | } 116 | 117 | // -------------------------------------------------------------------------- 118 | // internals 119 | // -------------------------------------------------------------------------- 120 | 121 | AuthenticationTokens _authenticationTokens; 122 | AuthenticationCredentials _authenticationCredentials; 123 | String _authenticationIdentityId; 124 | 125 | Future _getStoredIdentityId() async { 126 | final storage = new FlutterSecureStorage(); 127 | return await storage.read(key: "AuthenticationIdentityId"); 128 | } 129 | 130 | Future _storeIdentityId(String identityId) async { 131 | final storage = new FlutterSecureStorage(); 132 | await storage.write(key: "AuthenticationIdentityId", value: identityId); 133 | return true; 134 | } 135 | 136 | Future _getStoredTokens() async { 137 | final storage = new FlutterSecureStorage(); 138 | String tokensJson = await storage.read(key: "AuthenticationTokens"); 139 | if (tokensJson == null) { 140 | return null; 141 | } 142 | return AuthenticationTokens.fromJson(tokensJson); 143 | } 144 | 145 | Future _storeTokens(AuthenticationTokens authenticationTokens) async { 146 | final storage = new FlutterSecureStorage(); 147 | await storage.write( 148 | key: "AuthenticationTokens", value: authenticationTokens.toJson()); 149 | return true; 150 | } 151 | 152 | Future _getStoredCredentials() async { 153 | final storage = new FlutterSecureStorage(); 154 | String credentialsJson = 155 | await storage.read(key: "AuthenticationCredentials"); 156 | if (credentialsJson == null) { 157 | return null; 158 | } 159 | return AuthenticationCredentials.fromJson(credentialsJson); 160 | } 161 | 162 | Future _storeCredentials( 163 | AuthenticationCredentials authenticationCredentials) async { 164 | final storage = new FlutterSecureStorage(); 165 | await storage.write( 166 | key: "AuthenticationCredentials", 167 | value: authenticationCredentials.toJson()); 168 | return true; 169 | } 170 | 171 | Future _exchangeGrantForTokens(String code) async { 172 | Map body = { 173 | "grant_type": "authorization_code", 174 | "code": code, 175 | "client_id": userPoolAppClientId, 176 | "redirect_uri": cognitoUserPoolLoginRedirectUrl, 177 | }; 178 | http.Response response; 179 | try { 180 | response = await http.Client() 181 | .post( 182 | cognitoUserPoolTokenUrl, 183 | headers: { 184 | "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" 185 | }, 186 | body: body, 187 | ) 188 | .timeout(const Duration(seconds: 10)); 189 | } catch (e) { 190 | print("$cognitoUserPoolTokenUrl : $e"); 191 | return null; 192 | } 193 | 194 | var data; 195 | try { 196 | data = json.decode(response.body); 197 | } catch (e) { 198 | print("$cognitoUserPoolTokenUrl : $e"); 199 | return null; 200 | } 201 | if (response.statusCode < 200 || response.statusCode > 299) { 202 | String errorType = "UnknownError"; 203 | for (String header in response.headers.keys) { 204 | if (header.toLowerCase() == "x-amzn-errortype") { 205 | errorType = response.headers[header].split(':')[0]; 206 | break; 207 | } 208 | } 209 | if (data == null) { 210 | print( 211 | "$cognitoUserPoolTokenUrl : $errorType, statusCode: ${response.statusCode}"); 212 | } 213 | return null; 214 | } 215 | 216 | var tokens = AuthenticationTokens( 217 | accessToken: data["access_token"], 218 | expiryDateTime: 219 | DateTime.now().add(new Duration(seconds: data["expires_in"])), 220 | idToken: data["id_token"], 221 | refreshToken: data["refresh_token"], 222 | ); 223 | return tokens; 224 | } 225 | 226 | Future _refreshTokens(String refreshToken) async { 227 | Map body = { 228 | "grant_type": "refresh_token", 229 | "refresh_token": refreshToken, 230 | "client_id": userPoolAppClientId, 231 | }; 232 | http.Response response; 233 | try { 234 | response = await http.Client() 235 | .post( 236 | cognitoUserPoolTokenUrl, 237 | headers: { 238 | "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" 239 | }, 240 | body: body, 241 | ) 242 | .timeout(const Duration(seconds: 10)); 243 | } catch (e) { 244 | print("$cognitoUserPoolTokenUrl : $e"); 245 | return null; 246 | } 247 | 248 | var data; 249 | try { 250 | data = json.decode(response.body); 251 | } catch (e) { 252 | print("$cognitoUserPoolTokenUrl : $e"); 253 | return null; 254 | } 255 | if (response.statusCode < 200 || response.statusCode > 299) { 256 | String errorType = "UnknownError"; 257 | for (String header in response.headers.keys) { 258 | if (header.toLowerCase() == "x-amzn-errortype") { 259 | errorType = response.headers[header].split(':')[0]; 260 | break; 261 | } 262 | } 263 | if (data == null) { 264 | print( 265 | "$cognitoUserPoolTokenUrl : $errorType, statusCode: ${response.statusCode}"); 266 | } 267 | return null; 268 | } 269 | 270 | var tokens = AuthenticationTokens( 271 | accessToken: data["access_token"], 272 | expiryDateTime: 273 | DateTime.now().add(new Duration(seconds: data["expires_in"])), 274 | idToken: data["id_token"], 275 | refreshToken: refreshToken, 276 | ); 277 | return tokens; 278 | } 279 | 280 | Future _getNewIdentity() async { 281 | http.Response response; 282 | try { 283 | response = await http.Client() 284 | .post( 285 | cognitoIdentityPoolUrl, 286 | headers: { 287 | "Content-Type": "application/x-amz-json-1.1", 288 | "X-Amz-Target": "AWSCognitoIdentityService.GetId", 289 | }, 290 | body: jsonEncode({"IdentityPoolId": identityPoolId}), 291 | ) 292 | .timeout(const Duration(seconds: 10)); 293 | } catch (e) { 294 | print("$cognitoIdentityPoolUrl : AWSCognitoIdentityService.GetId : $e"); 295 | return null; 296 | } 297 | 298 | var data; 299 | try { 300 | data = json.decode(response.body); 301 | } catch (e) { 302 | print("$cognitoIdentityPoolUrl : AWSCognitoIdentityService.GetId : $e"); 303 | return null; 304 | } 305 | if (response.statusCode < 200 || response.statusCode > 299) { 306 | String errorType = "UnknownError"; 307 | for (String header in response.headers.keys) { 308 | if (header.toLowerCase() == "x-amzn-errortype") { 309 | errorType = response.headers[header].split(':')[0]; 310 | break; 311 | } 312 | } 313 | if (data == null) { 314 | print( 315 | "$cognitoIdentityPoolUrl : AWSCognitoIdentityService.GetId : $errorType, statusCode: ${response.statusCode}"); 316 | } 317 | return null; 318 | } 319 | return data["IdentityId"]; 320 | } 321 | 322 | Future _getNewCredentials( 323 | String authenticationIdentityId, 324 | AuthenticationTokens authenticationTokens) async { 325 | http.Response response; 326 | try { 327 | response = await http.Client() 328 | .post( 329 | cognitoIdentityPoolUrl, 330 | headers: { 331 | "Content-Type": "application/x-amz-json-1.1", 332 | "X-Amz-Target": 333 | "AWSCognitoIdentityService.GetCredentialsForIdentity", 334 | }, 335 | body: jsonEncode({ 336 | "IdentityId": authenticationIdentityId, 337 | "Logins": { 338 | "cognito-idp.$region.amazonaws.com/$userPoolId": 339 | authenticationTokens.idToken, 340 | } 341 | }), 342 | ) 343 | .timeout(const Duration(seconds: 10)); 344 | } catch (e) { 345 | print( 346 | "$cognitoIdentityPoolUrl : AWSCognitoIdentityService.GetCredentialsForIdentity : $e"); 347 | return null; 348 | } 349 | 350 | var data; 351 | try { 352 | data = json.decode(response.body); 353 | } catch (e) { 354 | print( 355 | "$cognitoIdentityPoolUrl : AWSCognitoIdentityService.GetCredentialsForIdentity : $e"); 356 | return null; 357 | } 358 | if (response.statusCode < 200 || response.statusCode > 299) { 359 | String errorType = "UnknownError"; 360 | for (String header in response.headers.keys) { 361 | if (header.toLowerCase() == "x-amzn-errortype") { 362 | errorType = response.headers[header].split(':')[0]; 363 | break; 364 | } 365 | } 366 | if (data == null) { 367 | print( 368 | "$cognitoIdentityPoolUrl : AWSCognitoIdentityService.GetCredentialsForIdentity : $errorType, statusCode: ${response.statusCode}"); 369 | } 370 | return null; 371 | } 372 | double expiration = data["Credentials"]["Expiration"]; 373 | var credentials = AuthenticationCredentials( 374 | accessKeyId: data["Credentials"]["AccessKeyId"], 375 | secretKey: data["Credentials"]["SecretKey"], 376 | sessionToken: data["Credentials"]["SessionToken"], 377 | expiryDateTime: 378 | DateTime.fromMillisecondsSinceEpoch(expiration.toInt() * 1000), 379 | ); 380 | return credentials; 381 | } 382 | } 383 | -------------------------------------------------------------------------------- /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 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 13 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 14 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 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 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 19 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 20 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXCopyFilesBuildPhase section */ 24 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 25 | isa = PBXCopyFilesBuildPhase; 26 | buildActionMask = 2147483647; 27 | dstPath = ""; 28 | dstSubfolderSpec = 10; 29 | files = ( 30 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, 31 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, 32 | ); 33 | name = "Embed Frameworks"; 34 | runOnlyForDeploymentPostprocessing = 0; 35 | }; 36 | /* End PBXCopyFilesBuildPhase section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 40 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 41 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 42 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 43 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 44 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 45 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 46 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 47 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 48 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 49 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 51 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 52 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 53 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | /* End PBXFileReference section */ 55 | 56 | /* Begin PBXFrameworksBuildPhase section */ 57 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 58 | isa = PBXFrameworksBuildPhase; 59 | buildActionMask = 2147483647; 60 | files = ( 61 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 62 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | /* End PBXFrameworksBuildPhase section */ 67 | 68 | /* Begin PBXGroup section */ 69 | 9740EEB11CF90186004384FC /* Flutter */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | 3B80C3931E831B6300D905FE /* App.framework */, 73 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 74 | 9740EEBA1CF902C7004384FC /* Flutter.framework */, 75 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 76 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 77 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 78 | ); 79 | name = Flutter; 80 | sourceTree = ""; 81 | }; 82 | 97C146E51CF9000F007C117D = { 83 | isa = PBXGroup; 84 | children = ( 85 | 9740EEB11CF90186004384FC /* Flutter */, 86 | 97C146F01CF9000F007C117D /* Runner */, 87 | 97C146EF1CF9000F007C117D /* Products */, 88 | ); 89 | sourceTree = ""; 90 | }; 91 | 97C146EF1CF9000F007C117D /* Products */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | 97C146EE1CF9000F007C117D /* Runner.app */, 95 | ); 96 | name = Products; 97 | sourceTree = ""; 98 | }; 99 | 97C146F01CF9000F007C117D /* Runner */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 103 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 104 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 105 | 97C147021CF9000F007C117D /* Info.plist */, 106 | 97C146F11CF9000F007C117D /* Supporting Files */, 107 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 108 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 109 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 110 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 111 | ); 112 | path = Runner; 113 | sourceTree = ""; 114 | }; 115 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | ); 119 | name = "Supporting Files"; 120 | sourceTree = ""; 121 | }; 122 | /* End PBXGroup section */ 123 | 124 | /* Begin PBXNativeTarget section */ 125 | 97C146ED1CF9000F007C117D /* Runner */ = { 126 | isa = PBXNativeTarget; 127 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 128 | buildPhases = ( 129 | 9740EEB61CF901F6004384FC /* Run Script */, 130 | 97C146EA1CF9000F007C117D /* Sources */, 131 | 97C146EB1CF9000F007C117D /* Frameworks */, 132 | 97C146EC1CF9000F007C117D /* Resources */, 133 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 134 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 135 | ); 136 | buildRules = ( 137 | ); 138 | dependencies = ( 139 | ); 140 | name = Runner; 141 | productName = Runner; 142 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 143 | productType = "com.apple.product-type.application"; 144 | }; 145 | /* End PBXNativeTarget section */ 146 | 147 | /* Begin PBXProject section */ 148 | 97C146E61CF9000F007C117D /* Project object */ = { 149 | isa = PBXProject; 150 | attributes = { 151 | LastUpgradeCheck = 0910; 152 | ORGANIZATIONNAME = "The Chromium Authors"; 153 | TargetAttributes = { 154 | 97C146ED1CF9000F007C117D = { 155 | CreatedOnToolsVersion = 7.3.1; 156 | LastSwiftMigration = 0910; 157 | }; 158 | }; 159 | }; 160 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 161 | compatibilityVersion = "Xcode 3.2"; 162 | developmentRegion = English; 163 | hasScannedForEncodings = 0; 164 | knownRegions = ( 165 | en, 166 | Base, 167 | ); 168 | mainGroup = 97C146E51CF9000F007C117D; 169 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 170 | projectDirPath = ""; 171 | projectRoot = ""; 172 | targets = ( 173 | 97C146ED1CF9000F007C117D /* Runner */, 174 | ); 175 | }; 176 | /* End PBXProject section */ 177 | 178 | /* Begin PBXResourcesBuildPhase section */ 179 | 97C146EC1CF9000F007C117D /* Resources */ = { 180 | isa = PBXResourcesBuildPhase; 181 | buildActionMask = 2147483647; 182 | files = ( 183 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 184 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 185 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 186 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 187 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 188 | ); 189 | runOnlyForDeploymentPostprocessing = 0; 190 | }; 191 | /* End PBXResourcesBuildPhase section */ 192 | 193 | /* Begin PBXShellScriptBuildPhase section */ 194 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 195 | isa = PBXShellScriptBuildPhase; 196 | buildActionMask = 2147483647; 197 | files = ( 198 | ); 199 | inputPaths = ( 200 | ); 201 | name = "Thin Binary"; 202 | outputPaths = ( 203 | ); 204 | runOnlyForDeploymentPostprocessing = 0; 205 | shellPath = /bin/sh; 206 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; 207 | }; 208 | 9740EEB61CF901F6004384FC /* Run Script */ = { 209 | isa = PBXShellScriptBuildPhase; 210 | buildActionMask = 2147483647; 211 | files = ( 212 | ); 213 | inputPaths = ( 214 | ); 215 | name = "Run Script"; 216 | outputPaths = ( 217 | ); 218 | runOnlyForDeploymentPostprocessing = 0; 219 | shellPath = /bin/sh; 220 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 221 | }; 222 | /* End PBXShellScriptBuildPhase section */ 223 | 224 | /* Begin PBXSourcesBuildPhase section */ 225 | 97C146EA1CF9000F007C117D /* Sources */ = { 226 | isa = PBXSourcesBuildPhase; 227 | buildActionMask = 2147483647; 228 | files = ( 229 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 230 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | /* End PBXSourcesBuildPhase section */ 235 | 236 | /* Begin PBXVariantGroup section */ 237 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 238 | isa = PBXVariantGroup; 239 | children = ( 240 | 97C146FB1CF9000F007C117D /* Base */, 241 | ); 242 | name = Main.storyboard; 243 | sourceTree = ""; 244 | }; 245 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 246 | isa = PBXVariantGroup; 247 | children = ( 248 | 97C147001CF9000F007C117D /* Base */, 249 | ); 250 | name = LaunchScreen.storyboard; 251 | sourceTree = ""; 252 | }; 253 | /* End PBXVariantGroup section */ 254 | 255 | /* Begin XCBuildConfiguration section */ 256 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 257 | isa = XCBuildConfiguration; 258 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 259 | buildSettings = { 260 | ALWAYS_SEARCH_USER_PATHS = NO; 261 | CLANG_ANALYZER_NONNULL = YES; 262 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 263 | CLANG_CXX_LIBRARY = "libc++"; 264 | CLANG_ENABLE_MODULES = YES; 265 | CLANG_ENABLE_OBJC_ARC = YES; 266 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 267 | CLANG_WARN_BOOL_CONVERSION = YES; 268 | CLANG_WARN_COMMA = YES; 269 | CLANG_WARN_CONSTANT_CONVERSION = YES; 270 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 271 | CLANG_WARN_EMPTY_BODY = YES; 272 | CLANG_WARN_ENUM_CONVERSION = YES; 273 | CLANG_WARN_INFINITE_RECURSION = YES; 274 | CLANG_WARN_INT_CONVERSION = YES; 275 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 276 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 277 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 278 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 279 | CLANG_WARN_STRICT_PROTOTYPES = YES; 280 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 281 | CLANG_WARN_UNREACHABLE_CODE = YES; 282 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 283 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 284 | COPY_PHASE_STRIP = NO; 285 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 286 | ENABLE_NS_ASSERTIONS = NO; 287 | ENABLE_STRICT_OBJC_MSGSEND = YES; 288 | GCC_C_LANGUAGE_STANDARD = gnu99; 289 | GCC_NO_COMMON_BLOCKS = YES; 290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 292 | GCC_WARN_UNDECLARED_SELECTOR = YES; 293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 294 | GCC_WARN_UNUSED_FUNCTION = YES; 295 | GCC_WARN_UNUSED_VARIABLE = YES; 296 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 297 | MTL_ENABLE_DEBUG_INFO = NO; 298 | SDKROOT = iphoneos; 299 | TARGETED_DEVICE_FAMILY = "1,2"; 300 | VALIDATE_PRODUCT = YES; 301 | }; 302 | name = Profile; 303 | }; 304 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 305 | isa = XCBuildConfiguration; 306 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 307 | buildSettings = { 308 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 309 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 310 | DEVELOPMENT_TEAM = S8QB4VV633; 311 | ENABLE_BITCODE = NO; 312 | FRAMEWORK_SEARCH_PATHS = ( 313 | "$(inherited)", 314 | "$(PROJECT_DIR)/Flutter", 315 | ); 316 | INFOPLIST_FILE = Runner/Info.plist; 317 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 318 | LIBRARY_SEARCH_PATHS = ( 319 | "$(inherited)", 320 | "$(PROJECT_DIR)/Flutter", 321 | ); 322 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterAwsApp; 323 | PRODUCT_NAME = "$(TARGET_NAME)"; 324 | SWIFT_VERSION = 4.0; 325 | VERSIONING_SYSTEM = "apple-generic"; 326 | }; 327 | name = Profile; 328 | }; 329 | 97C147031CF9000F007C117D /* Debug */ = { 330 | isa = XCBuildConfiguration; 331 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 332 | buildSettings = { 333 | ALWAYS_SEARCH_USER_PATHS = NO; 334 | CLANG_ANALYZER_NONNULL = YES; 335 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 336 | CLANG_CXX_LIBRARY = "libc++"; 337 | CLANG_ENABLE_MODULES = YES; 338 | CLANG_ENABLE_OBJC_ARC = YES; 339 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 340 | CLANG_WARN_BOOL_CONVERSION = YES; 341 | CLANG_WARN_COMMA = YES; 342 | CLANG_WARN_CONSTANT_CONVERSION = YES; 343 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 344 | CLANG_WARN_EMPTY_BODY = YES; 345 | CLANG_WARN_ENUM_CONVERSION = YES; 346 | CLANG_WARN_INFINITE_RECURSION = YES; 347 | CLANG_WARN_INT_CONVERSION = YES; 348 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 349 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 350 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 351 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 352 | CLANG_WARN_STRICT_PROTOTYPES = YES; 353 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 354 | CLANG_WARN_UNREACHABLE_CODE = YES; 355 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 356 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 357 | COPY_PHASE_STRIP = NO; 358 | DEBUG_INFORMATION_FORMAT = dwarf; 359 | ENABLE_STRICT_OBJC_MSGSEND = YES; 360 | ENABLE_TESTABILITY = YES; 361 | GCC_C_LANGUAGE_STANDARD = gnu99; 362 | GCC_DYNAMIC_NO_PIC = NO; 363 | GCC_NO_COMMON_BLOCKS = YES; 364 | GCC_OPTIMIZATION_LEVEL = 0; 365 | GCC_PREPROCESSOR_DEFINITIONS = ( 366 | "DEBUG=1", 367 | "$(inherited)", 368 | ); 369 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 370 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 371 | GCC_WARN_UNDECLARED_SELECTOR = YES; 372 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 373 | GCC_WARN_UNUSED_FUNCTION = YES; 374 | GCC_WARN_UNUSED_VARIABLE = YES; 375 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 376 | MTL_ENABLE_DEBUG_INFO = YES; 377 | ONLY_ACTIVE_ARCH = YES; 378 | SDKROOT = iphoneos; 379 | TARGETED_DEVICE_FAMILY = "1,2"; 380 | }; 381 | name = Debug; 382 | }; 383 | 97C147041CF9000F007C117D /* Release */ = { 384 | isa = XCBuildConfiguration; 385 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 386 | buildSettings = { 387 | ALWAYS_SEARCH_USER_PATHS = NO; 388 | CLANG_ANALYZER_NONNULL = YES; 389 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 390 | CLANG_CXX_LIBRARY = "libc++"; 391 | CLANG_ENABLE_MODULES = YES; 392 | CLANG_ENABLE_OBJC_ARC = YES; 393 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 394 | CLANG_WARN_BOOL_CONVERSION = YES; 395 | CLANG_WARN_COMMA = YES; 396 | CLANG_WARN_CONSTANT_CONVERSION = YES; 397 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 398 | CLANG_WARN_EMPTY_BODY = YES; 399 | CLANG_WARN_ENUM_CONVERSION = YES; 400 | CLANG_WARN_INFINITE_RECURSION = YES; 401 | CLANG_WARN_INT_CONVERSION = YES; 402 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 403 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 404 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 405 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 406 | CLANG_WARN_STRICT_PROTOTYPES = YES; 407 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 408 | CLANG_WARN_UNREACHABLE_CODE = YES; 409 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 410 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 411 | COPY_PHASE_STRIP = NO; 412 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 413 | ENABLE_NS_ASSERTIONS = NO; 414 | ENABLE_STRICT_OBJC_MSGSEND = YES; 415 | GCC_C_LANGUAGE_STANDARD = gnu99; 416 | GCC_NO_COMMON_BLOCKS = YES; 417 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 418 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 419 | GCC_WARN_UNDECLARED_SELECTOR = YES; 420 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 421 | GCC_WARN_UNUSED_FUNCTION = YES; 422 | GCC_WARN_UNUSED_VARIABLE = YES; 423 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 424 | MTL_ENABLE_DEBUG_INFO = NO; 425 | SDKROOT = iphoneos; 426 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 427 | TARGETED_DEVICE_FAMILY = "1,2"; 428 | VALIDATE_PRODUCT = YES; 429 | }; 430 | name = Release; 431 | }; 432 | 97C147061CF9000F007C117D /* Debug */ = { 433 | isa = XCBuildConfiguration; 434 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 435 | buildSettings = { 436 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 437 | CLANG_ENABLE_MODULES = YES; 438 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 439 | ENABLE_BITCODE = NO; 440 | FRAMEWORK_SEARCH_PATHS = ( 441 | "$(inherited)", 442 | "$(PROJECT_DIR)/Flutter", 443 | ); 444 | INFOPLIST_FILE = Runner/Info.plist; 445 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 446 | LIBRARY_SEARCH_PATHS = ( 447 | "$(inherited)", 448 | "$(PROJECT_DIR)/Flutter", 449 | ); 450 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterAwsApp; 451 | PRODUCT_NAME = "$(TARGET_NAME)"; 452 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 453 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 454 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 455 | SWIFT_VERSION = 4.0; 456 | VERSIONING_SYSTEM = "apple-generic"; 457 | }; 458 | name = Debug; 459 | }; 460 | 97C147071CF9000F007C117D /* Release */ = { 461 | isa = XCBuildConfiguration; 462 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 463 | buildSettings = { 464 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 465 | CLANG_ENABLE_MODULES = YES; 466 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 467 | ENABLE_BITCODE = NO; 468 | FRAMEWORK_SEARCH_PATHS = ( 469 | "$(inherited)", 470 | "$(PROJECT_DIR)/Flutter", 471 | ); 472 | INFOPLIST_FILE = Runner/Info.plist; 473 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 474 | LIBRARY_SEARCH_PATHS = ( 475 | "$(inherited)", 476 | "$(PROJECT_DIR)/Flutter", 477 | ); 478 | PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterAwsApp; 479 | PRODUCT_NAME = "$(TARGET_NAME)"; 480 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 481 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 482 | SWIFT_VERSION = 4.0; 483 | VERSIONING_SYSTEM = "apple-generic"; 484 | }; 485 | name = Release; 486 | }; 487 | /* End XCBuildConfiguration section */ 488 | 489 | /* Begin XCConfigurationList section */ 490 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 491 | isa = XCConfigurationList; 492 | buildConfigurations = ( 493 | 97C147031CF9000F007C117D /* Debug */, 494 | 97C147041CF9000F007C117D /* Release */, 495 | 249021D3217E4FDB00AE95B9 /* Profile */, 496 | ); 497 | defaultConfigurationIsVisible = 0; 498 | defaultConfigurationName = Release; 499 | }; 500 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 501 | isa = XCConfigurationList; 502 | buildConfigurations = ( 503 | 97C147061CF9000F007C117D /* Debug */, 504 | 97C147071CF9000F007C117D /* Release */, 505 | 249021D4217E4FDB00AE95B9 /* Profile */, 506 | ); 507 | defaultConfigurationIsVisible = 0; 508 | defaultConfigurationName = Release; 509 | }; 510 | /* End XCConfigurationList section */ 511 | 512 | }; 513 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 514 | } 515 | --------------------------------------------------------------------------------