From 6ac0456313a4550e24e34da6eb0edc50624178f7 Mon Sep 17 00:00:00 2001 From: Misir Jafarov Date: Wed, 5 May 2021 14:03:48 +0400 Subject: [PATCH 1/3] Upgrade provider --- ios/Flutter/flutter_export_environment.sh | 13 +++++++++++++ lib/main.dart | 16 ++++++++-------- lib/src/game_screen/character_pool_page.dart | 10 +++++----- lib/src/game_screen/task_pool_page.dart | 2 +- lib/src/widgets/app_bar/stat_badge.dart | 2 +- pubspec.yaml | 2 +- test/world_test.dart | 10 +++++----- 7 files changed, 34 insertions(+), 21 deletions(-) create mode 100755 ios/Flutter/flutter_export_environment.sh diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh new file mode 100755 index 0000000..5e4b682 --- /dev/null +++ b/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=/Users/misir/Workspace/tools/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/misir/Workspace/repos/github.com/2d-inc/developer_quest" +export "FLUTTER_TARGET=lib/main.dart" +export "FLUTTER_BUILD_DIR=build" +export "SYMROOT=${SOURCE_ROOT}/../build/ios" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=false" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.packages" diff --git a/lib/main.dart b/lib/main.dart index edb6f43..bb3fc43 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -36,14 +36,14 @@ class _MyAppState extends State { Widget build(BuildContext context) { return MultiProvider( providers: [ - ChangeNotifierProvider(builder: (_) => User()), - ChangeNotifierProvider.value(notifier: world), - ChangeNotifierProvider.value(notifier: world.characterPool), - ChangeNotifierProvider.value(notifier: world.taskPool), - ChangeNotifierProvider.value(notifier: world.company), - ChangeNotifierProvider.value(notifier: world.company.users), - ChangeNotifierProvider.value(notifier: world.company.joy), - ChangeNotifierProvider.value(notifier: world.company.coin), + ChangeNotifierProvider(create: (_) => User()), + ChangeNotifierProvider.value(value: world), + ChangeNotifierProvider.value(value: world.characterPool), + ChangeNotifierProvider.value(value: world.taskPool), + ChangeNotifierProvider.value(value: world.company), + ChangeNotifierProvider.value(value: world.company.users), + ChangeNotifierProvider.value(value: world.company.joy), + ChangeNotifierProvider.value(value: world.company.coin), ], child: MaterialApp( title: 'Flutter Demo', diff --git a/lib/src/game_screen/character_pool_page.dart b/lib/src/game_screen/character_pool_page.dart index 8ead772..f68adf7 100644 --- a/lib/src/game_screen/character_pool_page.dart +++ b/lib/src/game_screen/character_pool_page.dart @@ -24,10 +24,10 @@ class CharacterPoolPage extends StatelessWidget { gridDelegate: _gridStructure, itemBuilder: (context, index) => ChangeNotifierProvider.value( - notifier: characterPool.children[index], - key: ValueKey(characterPool.children[index]), - child: CharacterListItem(), - ), + value: characterPool.children[index], + key: ValueKey(characterPool.children[index]), + child: CharacterListItem(), + ), ), _fadeOverlay, ], @@ -132,7 +132,7 @@ class CharacterDisplay extends StatelessWidget { context: context, builder: (BuildContext context) { return ChangeNotifierProvider.value( - notifier: character, + value: character, child: CharacterModal(), ); }); diff --git a/lib/src/game_screen/task_pool_page.dart b/lib/src/game_screen/task_pool_page.dart index 63f9c2f..0dbd9de 100644 --- a/lib/src/game_screen/task_pool_page.dart +++ b/lib/src/game_screen/task_pool_page.dart @@ -32,7 +32,7 @@ class TaskPoolPage extends StatelessWidget { delegate: SliverChildBuilderDelegate((context, index) { WorkItem item = workItems[index]; return ChangeNotifierProvider.value( - notifier: item, + value: item, key: ValueKey(item), child: item is Bug ? BugListItem() : TaskListItem(), ); diff --git a/lib/src/widgets/app_bar/stat_badge.dart b/lib/src/widgets/app_bar/stat_badge.dart index 36ca157..cd7b694 100644 --- a/lib/src/widgets/app_bar/stat_badge.dart +++ b/lib/src/widgets/app_bar/stat_badge.dart @@ -54,7 +54,7 @@ class StatBadgeState extends State> { /// Since [widget.statValue] is [ValueListenable], we can subscribe to /// its changes in [didUpdateWidget]. void valueChanged() { - T change = widget.statValue.number - _lastStatValue; + T change = widget.statValue.number - _lastStatValue as T; if (widget.celebrateAfter == 0 || change > widget.celebrateAfter) { controls.play('points'); _lastStatValue = widget.statValue.number; diff --git a/pubspec.yaml b/pubspec.yaml index ddeefa0..072485c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,10 +19,10 @@ dependencies: flutter: sdk: flutter intl: any - provider: ^2.0.0 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. + provider: ^4.0.0 cupertino_icons: ^0.1.2 flare_flutter: ^1.8.3 auto_size_text: ^1.1.2 diff --git a/test/world_test.dart b/test/world_test.dart index 2ab554e..5e8c64c 100644 --- a/test/world_test.dart +++ b/test/world_test.dart @@ -9,14 +9,14 @@ void main() { await tester.pumpWidget( ChangeNotifierProvider( - builder: (_) => World(), + create: (_) => World(), child: MaterialApp( home: Consumer( builder: (context, world, child) => FlatButton( - key: buttonKey, - onPressed: () => world.start(), - child: Text(world.isRunning ? 'Stop' : 'Start'), - ), + key: buttonKey, + onPressed: () => world.start(), + child: Text(world.isRunning ? 'Stop' : 'Start'), + ), ), ), ), From 2264310d22710fea69b2583e2afc755f513b5b13 Mon Sep 17 00:00:00 2001 From: Misir Jafarov Date: Wed, 5 May 2021 14:18:27 +0400 Subject: [PATCH 2/3] Migrate to Android Embedded 2 --- android/app/build.gradle | 2 +- android/app/src/main/AndroidManifest.xml | 14 +++++++------- .../main/kotlin/dev/flutter/devrpg/MainActivity.kt | 9 +-------- pubspec.yaml | 2 +- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 15f6715..9e15d52 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -32,7 +32,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 27 + compileSdkVersion 30 sourceSets { main.java.srcDirs += 'src/main/kotlin' diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 5c9ee34..ac06536 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -13,7 +13,6 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> - + + + android:name="io.flutter.embedding.android.SplashScreenDrawable" + android:resource="@drawable/launch_background" /> + diff --git a/android/app/src/main/kotlin/dev/flutter/devrpg/MainActivity.kt b/android/app/src/main/kotlin/dev/flutter/devrpg/MainActivity.kt index 26aae51..e25e6d5 100644 --- a/android/app/src/main/kotlin/dev/flutter/devrpg/MainActivity.kt +++ b/android/app/src/main/kotlin/dev/flutter/devrpg/MainActivity.kt @@ -1,13 +1,6 @@ package dev.flutter.devrpg -import android.os.Bundle - -import io.flutter.app.FlutterActivity -import io.flutter.plugins.GeneratedPluginRegistrant +import io.flutter.embedding.android.FlutterActivity class MainActivity: FlutterActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - GeneratedPluginRegistrant.registerWith(this) - } } diff --git a/pubspec.yaml b/pubspec.yaml index 072485c..5bf8e45 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. provider: ^4.0.0 - cupertino_icons: ^0.1.2 + cupertino_icons: ^1.0.3 flare_flutter: ^1.8.3 auto_size_text: ^1.1.2 From a5695dc10819e7618a8ef2cc6220cb5f7799f512 Mon Sep 17 00:00:00 2001 From: Misir Jafarov Date: Wed, 5 May 2021 14:54:08 +0400 Subject: [PATCH 3/3] Migrate to AndroidX --- android/app/build.gradle | 8 ++++---- android/build.gradle | 4 ++-- android/gradle.properties | 3 +++ android/gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 9e15d52..e936d9d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -45,10 +45,10 @@ android { defaultConfig { applicationId "dev.flutter.devRpg" minSdkVersion 16 - targetSdkVersion 27 + targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } signingConfigs { release { @@ -81,6 +81,6 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' } diff --git a/android/build.gradle b/android/build.gradle index b7faad8..67a72cd 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.2.71' + ext.kotlin_version = '1.3.10' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.5.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/android/gradle.properties b/android/gradle.properties index 8bd86f6..768bee6 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1 +1,4 @@ +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536M +android.enableR8=true \ No newline at end of file diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 2819f02..dfd5f01 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip \ No newline at end of file