diff --git a/example/navigator_example/android/app/build.gradle b/example/navigator_example/android/app/build.gradle index 2243edfa1..e3cec84b2 100644 --- a/example/navigator_example/android/app/build.gradle +++ b/example/navigator_example/android/app/build.gradle @@ -1,67 +1,70 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') +def localPropertiesFile = rootProject.file("local.properties") if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> + localPropertiesFile.withReader("UTF-8") { reader -> localProperties.load(reader) } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +def flutterVersionCode = localProperties.getProperty("flutter.versionCode") if (flutterVersionCode == null) { - flutterVersionCode = '1' + flutterVersionCode = "1" } -def flutterVersionName = localProperties.getProperty('flutter.versionName') +def flutterVersionName = localProperties.getProperty("flutter.versionName") if (flutterVersionName == null) { - flutterVersionName = '1.0' + flutterVersionName = "1.0" } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { - compileSdkVersion 31 + namespace = "com.example.new_architecture" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8 } - lintOptions { - disable 'InvalidPackage' + sourceSets { + main.java.srcDirs += "src/main/kotlin" } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.example.new_architecture" - minSdkVersion 16 - targetSdkVersion 28 - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + applicationId = "com.example.new_architecture" + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutterVersionCode.toInteger() + versionName = flutterVersionName + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug + signingConfig = signingConfigs.debug } } } flutter { - source '../..' + source = "../.." } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test:runner:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' + testImplementation "junit:junit:4.13.2" + androidTestImplementation "androidx.test:runner:1.5.2" + androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1" } diff --git a/example/navigator_example/android/app/src/debug/AndroidManifest.xml b/example/navigator_example/android/app/src/debug/AndroidManifest.xml index dcb365cd6..f880684a6 100644 --- a/example/navigator_example/android/app/src/debug/AndroidManifest.xml +++ b/example/navigator_example/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/example/navigator_example/android/app/src/main/AndroidManifest.xml b/example/navigator_example/android/app/src/main/AndroidManifest.xml index 09fe11a9d..db7a04c46 100644 --- a/example/navigator_example/android/app/src/main/AndroidManifest.xml +++ b/example/navigator_example/android/app/src/main/AndroidManifest.xml @@ -1,11 +1,11 @@ - + - + diff --git a/example/navigator_example/android/app/src/profile/AndroidManifest.xml b/example/navigator_example/android/app/src/profile/AndroidManifest.xml index dcb365cd6..f880684a6 100644 --- a/example/navigator_example/android/app/src/profile/AndroidManifest.xml +++ b/example/navigator_example/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/example/navigator_example/android/build.gradle b/example/navigator_example/android/build.gradle index 7087ad19f..aacc6d0f3 100644 --- a/example/navigator_example/android/build.gradle +++ b/example/navigator_example/android/build.gradle @@ -1,31 +1,56 @@ -buildscript { - ext.kotlin_version = '1.4.10' - repositories { - google() - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() - jcenter() + mavenCentral() } } -rootProject.buildDir = '../build' +rootProject.buildDir = "../build" subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } + +// Some older Flutter plugins still declare their package via the manifest's +// `package` attribute and don't set an AGP `namespace`, which AGP 8+ requires. +// Backfill the namespace from the manifest package so these plugins keep building. +// Registered before `evaluationDependsOn(":app")` below, which would otherwise +// force-evaluate projects before this hook is attached. +subprojects { + afterEvaluate { project -> + if (project.hasProperty("android")) { + project.android { + if (namespace == null) { + def manifestFile = android.sourceSets.main.manifest.srcFile + def manifestPackage = new XmlSlurper() + .parse(manifestFile) + .@package + .text() + if (manifestPackage) { + namespace = manifestPackage + } + } + + // Older plugins don't pin a JVM target, so Kotlin defaults to the + // running JDK (21) while Java compiles at 1.8, which AGP rejects. + // Force both onto a consistent target. + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + } + if (project.plugins.hasPlugin("org.jetbrains.kotlin.android")) { + project.android.kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } + } + } + } +} + subprojects { - project.evaluationDependsOn(':app') + project.evaluationDependsOn(":app") } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/navigator_example/android/gradle.properties b/example/navigator_example/android/gradle.properties index 38c8d4544..4147ba381 100644 --- a/example/navigator_example/android/gradle.properties +++ b/example/navigator_example/android/gradle.properties @@ -1,4 +1,7 @@ -org.gradle.jvmargs=-Xmx1536M -android.enableR8=true +org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true +# This builtInKotlin flag was added automatically by Flutter migrator +android.builtInKotlin=false +# This newDsl flag was added automatically by Flutter migrator +android.newDsl=false diff --git a/example/navigator_example/android/gradle/wrapper/gradle-wrapper.properties b/example/navigator_example/android/gradle/wrapper/gradle-wrapper.properties index 296b146b7..7aeeb11c6 100644 --- a/example/navigator_example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/navigator_example/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-5.6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip diff --git a/example/navigator_example/android/settings.gradle b/example/navigator_example/android/settings.gradle index 5a2f14fb1..8ea797467 100644 --- a/example/navigator_example/android/settings.gradle +++ b/example/navigator_example/android/settings.gradle @@ -1,15 +1,25 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() -def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -if (pluginsFile.exists()) { - pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } } -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.6.0" apply false + id "org.jetbrains.kotlin.android" version "1.9.24" apply false } + +include ":app" diff --git a/example/navigator_example/lib/app/app.bottomsheets.dart b/example/navigator_example/lib/app/app.bottomsheets.dart index 0fe3dfd8b..6ea1d2fcd 100644 --- a/example/navigator_example/lib/app/app.bottomsheets.dart +++ b/example/navigator_example/lib/app/app.bottomsheets.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // StackedBottomsheetGenerator diff --git a/example/navigator_example/lib/app/app.dialogs.dart b/example/navigator_example/lib/app/app.dialogs.dart index d88b69705..587f9fbb0 100644 --- a/example/navigator_example/lib/app/app.dialogs.dart +++ b/example/navigator_example/lib/app/app.dialogs.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // StackedDialogGenerator diff --git a/example/navigator_example/lib/app/app.locator.dart b/example/navigator_example/lib/app/app.locator.dart index 8286a1d31..0563bf448 100644 --- a/example/navigator_example/lib/app/app.locator.dart +++ b/example/navigator_example/lib/app/app.locator.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // StackedLocatorGenerator @@ -21,10 +21,8 @@ import '../ui/bottom_nav/history/history_viewmodel.dart'; final exampleLocator = StackedLocator.instance; -Future setupExampleLocator({ - String? environment, - EnvironmentFilter? environmentFilter, -}) async { +Future setupExampleLocator( + {String? environment, EnvironmentFilter? environmentFilter}) async { // Register environments exampleLocator.registerEnvironment( environment: environment, environmentFilter: environmentFilter); diff --git a/example/navigator_example/lib/app/app.logger.dart b/example/navigator_example/lib/app/app.logger.dart index 1e82ef264..c3a3830ad 100644 --- a/example/navigator_example/lib/app/app.logger.dart +++ b/example/navigator_example/lib/app/app.logger.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // StackedLoggerGenerator @@ -34,13 +34,13 @@ class SimpleLogPrinter extends LogPrinter { ); @override List log(LogEvent event) { - var color = printer.levelColors?[event.level]; - var emoji = printer.levelEmojis?[event.level]; + var color = PrettyPrinter.defaultLevelColors[event.level]; + var emoji = PrettyPrinter.defaultLevelEmojis[event.level]; var methodName = _getMethodName(); var methodNameSection = printCallingFunctionName && methodName != null ? ' | $methodName' : ''; - var stackLog = event.stackTrace.toString(); + var stackLog = event.stackTrace?.toString() ?? ''; var output = '$emoji $className$methodNameSection - ${event.message}${event.error != null ? '\nERROR: ${event.error}\n' : ''}${printCallStack ? '\nSTACKTRACE:\n$stackLog' : ''}'; @@ -59,7 +59,7 @@ class SimpleLogPrinter extends LogPrinter { if (kReleaseMode) { return match.group(0)!; } else { - return color!(match.group(0)!); + return color != null ? color(match.group(0)!) : match.group(0)!; } })); } diff --git a/example/navigator_example/lib/app/app.router.dart b/example/navigator_example/lib/app/app.router.dart index 773266e6f..ea5cb1a1c 100644 --- a/example/navigator_example/lib/app/app.router.dart +++ b/example/navigator_example/lib/app/app.router.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // StackedNavigatorGenerator @@ -48,11 +48,26 @@ class Routes { class StackedRouter extends _i2.RouterBase { final _routes = <_i2.RouteDef>[ - _i2.RouteDef(Routes.homeView, page: _i3.HomeView), - _i2.RouteDef(Routes.bottomNavExample, page: _i4.BottomNavExample), - _i2.RouteDef(Routes.streamCounterView, page: _i5.StreamCounterView), - _i2.RouteDef(Routes.exampleFormView, page: _i6.ExampleFormView), - _i2.RouteDef(Routes.nonReactiveView, page: _i7.NonReactiveView), + _i2.RouteDef( + Routes.homeView, + page: _i3.HomeView, + ), + _i2.RouteDef( + Routes.bottomNavExample, + page: _i4.BottomNavExample, + ), + _i2.RouteDef( + Routes.streamCounterView, + page: _i5.StreamCounterView, + ), + _i2.RouteDef( + Routes.exampleFormView, + page: _i6.ExampleFormView, + ), + _i2.RouteDef( + Routes.nonReactiveView, + page: _i7.NonReactiveView, + ), ]; final _pagesMap = { @@ -62,12 +77,11 @@ class StackedRouter extends _i2.RouterBase { ); return _i8.MaterialPageRoute( builder: (context) => _i3.HomeView( - key: args.key, - title: args.title, - isLoggedIn: args.isLoggedIn, - clashableGetter: args.clashableGetter, - homeTypes: args.homeTypes, - ), + key: args.key, + title: args.title, + isLoggedIn: args.isLoggedIn, + clashableGetter: args.clashableGetter, + homeTypes: args.homeTypes), settings: data, ); }, @@ -84,9 +98,7 @@ class StackedRouter extends _i2.RouterBase { final args = data.getArgs(nullOk: false); return _i8.MaterialPageRoute( builder: (context) => _i5.StreamCounterView( - key: args.key, - clashableTwo: args.clashableTwo, - ), + key: args.key, clashableTwo: args.clashableTwo), settings: data, ); }, @@ -186,7 +198,10 @@ class BottomNavExampleArguments { } class StreamCounterViewArguments { - const StreamCounterViewArguments({this.key, required this.clashableTwo}); + const StreamCounterViewArguments({ + this.key, + required this.clashableTwo, + }); final _i8.Key? key; @@ -210,7 +225,10 @@ class StreamCounterViewArguments { } class ExampleFormViewArguments { - const ExampleFormViewArguments({this.key, required this.clashableOne}); + const ExampleFormViewArguments({ + this.key, + required this.clashableOne, + }); final _i8.Key? key; @@ -262,17 +280,27 @@ class BottomNavExampleRoutes { static const profileView = 'profile-view'; - static const all = {historyView, favoritesView, profileView}; + static const all = { + historyView, + favoritesView, + profileView, + }; } class BottomNavExampleRouter extends _i2.RouterBase { final _routes = <_i2.RouteDef>[ - _i2.RouteDef(BottomNavExampleRoutes.historyView, page: _i12.HistoryView), + _i2.RouteDef( + BottomNavExampleRoutes.historyView, + page: _i12.HistoryView, + ), _i2.RouteDef( BottomNavExampleRoutes.favoritesView, page: _i13.FavoritesView, ), - _i2.RouteDef(BottomNavExampleRoutes.profileView, page: _i14.ProfileView), + _i2.RouteDef( + BottomNavExampleRoutes.profileView, + page: _i14.ProfileView, + ), ]; final _pagesMap = { @@ -337,7 +365,10 @@ class NestedHistoryViewArguments { } class FavoritesViewArguments { - const FavoritesViewArguments({this.key, this.id}); + const FavoritesViewArguments({ + this.key, + this.id, + }); final _i8.Key? key; @@ -387,7 +418,10 @@ class FavoritesViewRoutes { static const historyView = 'history-view'; - static const all = {multipleFuturesExampleView, historyView}; + static const all = { + multipleFuturesExampleView, + historyView, + }; } class FavoritesViewRouter extends _i2.RouterBase { @@ -396,7 +430,10 @@ class FavoritesViewRouter extends _i2.RouterBase { FavoritesViewRoutes.multipleFuturesExampleView, page: _i16.MultipleFuturesExampleView, ), - _i2.RouteDef(FavoritesViewRoutes.historyView, page: _i12.HistoryView), + _i2.RouteDef( + FavoritesViewRoutes.historyView, + page: _i12.HistoryView, + ), ]; final _pagesMap = { @@ -462,7 +499,7 @@ extension NavigatorStateExtension on _i17.NavigationService { _i10.Clashable Function(String)? clashableGetter, List<_i1.HomeType> homeTypes = const [ _i1.HomeType.apartment, - _i1.HomeType.house, + _i1.HomeType.house ], int? routerId, bool preventDuplicates = true, @@ -470,20 +507,17 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return navigateTo( - Routes.homeView, - arguments: HomeViewArguments( - key: key, - title: title, - isLoggedIn: isLoggedIn, - clashableGetter: clashableGetter, - homeTypes: homeTypes, - ), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return navigateTo(Routes.homeView, + arguments: HomeViewArguments( + key: key, + title: title, + isLoggedIn: isLoggedIn, + clashableGetter: clashableGetter, + homeTypes: homeTypes), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future navigateToBottomNavExample({ @@ -494,14 +528,12 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return navigateTo( - Routes.bottomNavExample, - arguments: BottomNavExampleArguments(key: key), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return navigateTo(Routes.bottomNavExample, + arguments: BottomNavExampleArguments(key: key), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future navigateToStreamCounterView({ @@ -513,17 +545,13 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return navigateTo( - Routes.streamCounterView, - arguments: StreamCounterViewArguments( - key: key, - clashableTwo: clashableTwo, - ), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return navigateTo(Routes.streamCounterView, + arguments: + StreamCounterViewArguments(key: key, clashableTwo: clashableTwo), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future navigateToExampleFormView({ @@ -535,14 +563,13 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return navigateTo( - Routes.exampleFormView, - arguments: ExampleFormViewArguments(key: key, clashableOne: clashableOne), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return navigateTo(Routes.exampleFormView, + arguments: + ExampleFormViewArguments(key: key, clashableOne: clashableOne), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future navigateToNonReactiveView({ @@ -553,14 +580,12 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return navigateTo( - Routes.nonReactiveView, - arguments: NonReactiveViewArguments(key: key), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return navigateTo(Routes.nonReactiveView, + arguments: NonReactiveViewArguments(key: key), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future navigateToNestedHistoryViewInBottomNavExampleRouter({ @@ -571,14 +596,12 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return navigateTo( - BottomNavExampleRoutes.historyView, - arguments: NestedHistoryViewArguments(key: key), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return navigateTo(BottomNavExampleRoutes.historyView, + arguments: NestedHistoryViewArguments(key: key), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future navigateToFavoritesView({ @@ -590,14 +613,12 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return navigateTo( - BottomNavExampleRoutes.favoritesView, - arguments: FavoritesViewArguments(key: key, id: id), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return navigateTo(BottomNavExampleRoutes.favoritesView, + arguments: FavoritesViewArguments(key: key, id: id), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future navigateToNestedProfileViewInBottomNavExampleRouter({ @@ -608,14 +629,12 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return navigateTo( - BottomNavExampleRoutes.profileView, - arguments: NestedProfileViewArguments(key: key), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return navigateTo(BottomNavExampleRoutes.profileView, + arguments: NestedProfileViewArguments(key: key), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future @@ -627,14 +646,12 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return navigateTo( - FavoritesViewRoutes.multipleFuturesExampleView, - arguments: NestedMultipleFuturesExampleViewArguments(key: key), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return navigateTo(FavoritesViewRoutes.multipleFuturesExampleView, + arguments: NestedMultipleFuturesExampleViewArguments(key: key), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future navigateToNestedHistoryViewInFavoritesViewRouter({ @@ -645,14 +662,12 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return navigateTo( - FavoritesViewRoutes.historyView, - arguments: NestedHistoryViewArguments(key: key), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return navigateTo(FavoritesViewRoutes.historyView, + arguments: NestedHistoryViewArguments(key: key), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future replaceWithHomeView({ @@ -662,7 +677,7 @@ extension NavigatorStateExtension on _i17.NavigationService { _i10.Clashable Function(String)? clashableGetter, List<_i1.HomeType> homeTypes = const [ _i1.HomeType.apartment, - _i1.HomeType.house, + _i1.HomeType.house ], int? routerId, bool preventDuplicates = true, @@ -670,20 +685,17 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return replaceWith( - Routes.homeView, - arguments: HomeViewArguments( - key: key, - title: title, - isLoggedIn: isLoggedIn, - clashableGetter: clashableGetter, - homeTypes: homeTypes, - ), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return replaceWith(Routes.homeView, + arguments: HomeViewArguments( + key: key, + title: title, + isLoggedIn: isLoggedIn, + clashableGetter: clashableGetter, + homeTypes: homeTypes), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future replaceWithBottomNavExample({ @@ -694,14 +706,12 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return replaceWith( - Routes.bottomNavExample, - arguments: BottomNavExampleArguments(key: key), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return replaceWith(Routes.bottomNavExample, + arguments: BottomNavExampleArguments(key: key), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future replaceWithStreamCounterView({ @@ -713,17 +723,13 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return replaceWith( - Routes.streamCounterView, - arguments: StreamCounterViewArguments( - key: key, - clashableTwo: clashableTwo, - ), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return replaceWith(Routes.streamCounterView, + arguments: + StreamCounterViewArguments(key: key, clashableTwo: clashableTwo), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future replaceWithExampleFormView({ @@ -735,14 +741,13 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return replaceWith( - Routes.exampleFormView, - arguments: ExampleFormViewArguments(key: key, clashableOne: clashableOne), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return replaceWith(Routes.exampleFormView, + arguments: + ExampleFormViewArguments(key: key, clashableOne: clashableOne), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future replaceWithNonReactiveView({ @@ -753,14 +758,12 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return replaceWith( - Routes.nonReactiveView, - arguments: NonReactiveViewArguments(key: key), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return replaceWith(Routes.nonReactiveView, + arguments: NonReactiveViewArguments(key: key), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future replaceWithNestedHistoryViewInBottomNavExampleRouter({ @@ -771,14 +774,12 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return replaceWith( - BottomNavExampleRoutes.historyView, - arguments: NestedHistoryViewArguments(key: key), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return replaceWith(BottomNavExampleRoutes.historyView, + arguments: NestedHistoryViewArguments(key: key), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future replaceWithFavoritesView({ @@ -790,14 +791,12 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return replaceWith( - BottomNavExampleRoutes.favoritesView, - arguments: FavoritesViewArguments(key: key, id: id), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return replaceWith(BottomNavExampleRoutes.favoritesView, + arguments: FavoritesViewArguments(key: key, id: id), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future replaceWithNestedProfileViewInBottomNavExampleRouter({ @@ -808,14 +807,12 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return replaceWith( - BottomNavExampleRoutes.profileView, - arguments: NestedProfileViewArguments(key: key), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return replaceWith(BottomNavExampleRoutes.profileView, + arguments: NestedProfileViewArguments(key: key), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future @@ -827,14 +824,12 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return replaceWith( - FavoritesViewRoutes.multipleFuturesExampleView, - arguments: NestedMultipleFuturesExampleViewArguments(key: key), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return replaceWith(FavoritesViewRoutes.multipleFuturesExampleView, + arguments: NestedMultipleFuturesExampleViewArguments(key: key), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } Future replaceWithNestedHistoryViewInFavoritesViewRouter({ @@ -845,13 +840,11 @@ extension NavigatorStateExtension on _i17.NavigationService { Widget Function(BuildContext, Animation, Animation, Widget)? transition, }) async { - return replaceWith( - FavoritesViewRoutes.historyView, - arguments: NestedHistoryViewArguments(key: key), - id: routerId, - preventDuplicates: preventDuplicates, - parameters: parameters, - transition: transition, - ); + return replaceWith(FavoritesViewRoutes.historyView, + arguments: NestedHistoryViewArguments(key: key), + id: routerId, + preventDuplicates: preventDuplicates, + parameters: parameters, + transition: transition); } } diff --git a/example/navigator_example/lib/ui/drop_down_menu_from/select_location_view.form.dart b/example/navigator_example/lib/ui/drop_down_menu_from/select_location_view.form.dart index 21a38d2b5..3391ac4f9 100644 --- a/example/navigator_example/lib/ui/drop_down_menu_from/select_location_view.form.dart +++ b/example/navigator_example/lib/ui/drop_down_menu_from/select_location_view.form.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // StackedFormGenerator diff --git a/example/navigator_example/lib/ui/form/example_form_view.form.dart b/example/navigator_example/lib/ui/form/example_form_view.form.dart index 02732adf6..2475022c5 100644 --- a/example/navigator_example/lib/ui/form/example_form_view.form.dart +++ b/example/navigator_example/lib/ui/form/example_form_view.form.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // StackedFormGenerator @@ -297,7 +297,7 @@ String? getValidationMessage(String key) { if (validatorForKey == null) return null; String? validationMessageForKey = validatorForKey( - _ExampleFormViewTextEditingControllers[key]!.text, + _ExampleFormViewTextEditingControllers[key]?.text, ); return validationMessageForKey; diff --git a/example/navigator_example/lib/ui/stream_view/stream_counter_viewmodel.dart b/example/navigator_example/lib/ui/stream_view/stream_counter_viewmodel.dart index 0e091bcdb..c1f97c0cc 100644 --- a/example/navigator_example/lib/ui/stream_view/stream_counter_viewmodel.dart +++ b/example/navigator_example/lib/ui/stream_view/stream_counter_viewmodel.dart @@ -38,7 +38,7 @@ class StreamCounterViewModel extends StreamViewModel { void onSubscribed() {} @override - void onError(error) {} + void onError(dynamic error, StackTrace? stackTrace) {} void changeStreamSources() { isSlowEpochNumbers = !isSlowEpochNumbers; diff --git a/example/navigator_example/pubspec.yaml b/example/navigator_example/pubspec.yaml index 8c89cd7a6..9e589d738 100644 --- a/example/navigator_example/pubspec.yaml +++ b/example/navigator_example/pubspec.yaml @@ -35,7 +35,6 @@ dependencies: flutter_hooks: ^0.18.4 # navigation - get: ^4.6.3 animations: ^2.0.3 dependency_overrides: diff --git a/example/router_example/android/app/build.gradle b/example/router_example/android/app/build.gradle index 587620b3d..e3cec84b2 100644 --- a/example/router_example/android/app/build.gradle +++ b/example/router_example/android/app/build.gradle @@ -1,67 +1,70 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') +def localPropertiesFile = rootProject.file("local.properties") if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> + localPropertiesFile.withReader("UTF-8") { reader -> localProperties.load(reader) } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +def flutterVersionCode = localProperties.getProperty("flutter.versionCode") if (flutterVersionCode == null) { - flutterVersionCode = '1' + flutterVersionCode = "1" } -def flutterVersionName = localProperties.getProperty('flutter.versionName') +def flutterVersionName = localProperties.getProperty("flutter.versionName") if (flutterVersionName == null) { - flutterVersionName = '1.0' + flutterVersionName = "1.0" } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { - compileSdkVersion 31 + namespace = "com.example.new_architecture" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8 } - lintOptions { - disable 'InvalidPackage' + sourceSets { + main.java.srcDirs += "src/main/kotlin" } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.example.new_architecture" - minSdkVersion 16 - targetSdkVersion 28 - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + applicationId = "com.example.new_architecture" + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutterVersionCode.toInteger() + versionName = flutterVersionName + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug + signingConfig = signingConfigs.debug } } } flutter { - source '../..' + source = "../.." } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test:runner:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + testImplementation "junit:junit:4.13.2" + androidTestImplementation "androidx.test:runner:1.5.2" + androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1" } diff --git a/example/router_example/android/app/src/debug/AndroidManifest.xml b/example/router_example/android/app/src/debug/AndroidManifest.xml index dcb365cd6..f880684a6 100644 --- a/example/router_example/android/app/src/debug/AndroidManifest.xml +++ b/example/router_example/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/example/router_example/android/app/src/main/AndroidManifest.xml b/example/router_example/android/app/src/main/AndroidManifest.xml index 09fe11a9d..db7a04c46 100644 --- a/example/router_example/android/app/src/main/AndroidManifest.xml +++ b/example/router_example/android/app/src/main/AndroidManifest.xml @@ -1,11 +1,11 @@ - + - + diff --git a/example/router_example/android/app/src/profile/AndroidManifest.xml b/example/router_example/android/app/src/profile/AndroidManifest.xml index dcb365cd6..f880684a6 100644 --- a/example/router_example/android/app/src/profile/AndroidManifest.xml +++ b/example/router_example/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/example/router_example/android/build.gradle b/example/router_example/android/build.gradle index 7087ad19f..aacc6d0f3 100644 --- a/example/router_example/android/build.gradle +++ b/example/router_example/android/build.gradle @@ -1,31 +1,56 @@ -buildscript { - ext.kotlin_version = '1.4.10' - repositories { - google() - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() - jcenter() + mavenCentral() } } -rootProject.buildDir = '../build' +rootProject.buildDir = "../build" subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } + +// Some older Flutter plugins still declare their package via the manifest's +// `package` attribute and don't set an AGP `namespace`, which AGP 8+ requires. +// Backfill the namespace from the manifest package so these plugins keep building. +// Registered before `evaluationDependsOn(":app")` below, which would otherwise +// force-evaluate projects before this hook is attached. +subprojects { + afterEvaluate { project -> + if (project.hasProperty("android")) { + project.android { + if (namespace == null) { + def manifestFile = android.sourceSets.main.manifest.srcFile + def manifestPackage = new XmlSlurper() + .parse(manifestFile) + .@package + .text() + if (manifestPackage) { + namespace = manifestPackage + } + } + + // Older plugins don't pin a JVM target, so Kotlin defaults to the + // running JDK (21) while Java compiles at 1.8, which AGP rejects. + // Force both onto a consistent target. + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + } + if (project.plugins.hasPlugin("org.jetbrains.kotlin.android")) { + project.android.kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } + } + } + } +} + subprojects { - project.evaluationDependsOn(':app') + project.evaluationDependsOn(":app") } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/router_example/android/gradle.properties b/example/router_example/android/gradle.properties index 38c8d4544..4147ba381 100644 --- a/example/router_example/android/gradle.properties +++ b/example/router_example/android/gradle.properties @@ -1,4 +1,7 @@ -org.gradle.jvmargs=-Xmx1536M -android.enableR8=true +org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true +# This builtInKotlin flag was added automatically by Flutter migrator +android.builtInKotlin=false +# This newDsl flag was added automatically by Flutter migrator +android.newDsl=false diff --git a/example/router_example/android/gradle/wrapper/gradle-wrapper.properties b/example/router_example/android/gradle/wrapper/gradle-wrapper.properties index bc24dcf03..7aeeb11c6 100644 --- a/example/router_example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/router_example/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-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip diff --git a/example/router_example/android/settings.gradle b/example/router_example/android/settings.gradle index 5a2f14fb1..8ea797467 100644 --- a/example/router_example/android/settings.gradle +++ b/example/router_example/android/settings.gradle @@ -1,15 +1,25 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() -def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -if (pluginsFile.exists()) { - pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } } -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.6.0" apply false + id "org.jetbrains.kotlin.android" version "1.9.24" apply false } + +include ":app" diff --git a/example/router_example/integration_test/app_test.dart b/example/router_example/integration_test/app_test.dart index 561ec54aa..2387e2c24 100644 --- a/example/router_example/integration_test/app_test.dart +++ b/example/router_example/integration_test/app_test.dart @@ -34,7 +34,7 @@ void main() { // Example Form View Widgets final exampleFormTitle = find.text('Example Form View'); - final formLoremText = find.text('Lorem'); + final formLoremText = find.text('lorem@test.com'); final formPasswordTextField = find.byKey(const ValueKey('passwordField')); final passwordErrorText = find.text('Password should not be empty'); final dobButton = find.text('Select your Date of birth'); diff --git a/example/router_example/lib/app/app.bottomsheets.dart b/example/router_example/lib/app/app.bottomsheets.dart index 0fe3dfd8b..6ea1d2fcd 100644 --- a/example/router_example/lib/app/app.bottomsheets.dart +++ b/example/router_example/lib/app/app.bottomsheets.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // StackedBottomsheetGenerator diff --git a/example/router_example/lib/app/app.dart b/example/router_example/lib/app/app.dart index e20c59174..f6ace933f 100644 --- a/example/router_example/lib/app/app.dart +++ b/example/router_example/lib/app/app.dart @@ -49,14 +49,7 @@ import 'package:stacked_themes/stacked_themes.dart'; ]), MaterialRoute(page: StreamCounterView), MaterialRoute(page: ExampleFormView), - // CustomRoute( - // page: NonReactiveView, - // transitionsBuilder: CustomRouteTransition.sharedAxis, - // ), - CustomRoute( - page: NonReactiveView, - customRouteBuilder: RouteBuilders.bottomSheetBuilder, - ) + MaterialRoute(page: NonReactiveView), ], dependencies: [ // Lazy singletons @@ -100,31 +93,3 @@ import 'package:stacked_themes/stacked_themes.dart'; class App { /// This class has no puporse besides housing the annotation that generates the required functionality } - -abstract class RouteBuilders { - static Route bottomSheetBuilder( - BuildContext context, - Widget child, - CustomPage page, - ) { - return ModalBottomSheetRoute( - builder: page.buildPage, - settings: page, - isScrollControlled: false, - isDismissible: false, - enableDrag: false, - useSafeArea: true, - showDragHandle: false, - scrollControlDisabledMaxHeightRatio: 0.5, - constraints: BoxConstraints( - maxHeight: MediaQuery.of(context).size.height * 0.8, - ), - backgroundColor: Colors.amber, - modalBarrierColor: Colors.black.withValues(alpha: 0.6), - elevation: 5, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.vertical(top: Radius.circular(12)), - ), - ); - } -} diff --git a/example/router_example/lib/app/app.dialogs.dart b/example/router_example/lib/app/app.dialogs.dart index d88b69705..587f9fbb0 100644 --- a/example/router_example/lib/app/app.dialogs.dart +++ b/example/router_example/lib/app/app.dialogs.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // StackedDialogGenerator diff --git a/example/router_example/lib/app/app.locator.dart b/example/router_example/lib/app/app.locator.dart index 7b479eaab..2b3341461 100644 --- a/example/router_example/lib/app/app.locator.dart +++ b/example/router_example/lib/app/app.locator.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // StackedLocatorGenerator @@ -25,11 +25,10 @@ import 'app.router.dart'; final exampleLocator = StackedLocator.instance; -Future setupExampleLocator({ - String? environment, - EnvironmentFilter? environmentFilter, - StackedRouterWeb? stackedRouter, -}) async { +Future setupExampleLocator( + {String? environment, + EnvironmentFilter? environmentFilter, + StackedRouterWeb? stackedRouter}) async { // Register environments exampleLocator.registerEnvironment( environment: environment, environmentFilter: environmentFilter); diff --git a/example/router_example/lib/app/app.logger.dart b/example/router_example/lib/app/app.logger.dart index 1e82ef264..c3a3830ad 100644 --- a/example/router_example/lib/app/app.logger.dart +++ b/example/router_example/lib/app/app.logger.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // StackedLoggerGenerator @@ -34,13 +34,13 @@ class SimpleLogPrinter extends LogPrinter { ); @override List log(LogEvent event) { - var color = printer.levelColors?[event.level]; - var emoji = printer.levelEmojis?[event.level]; + var color = PrettyPrinter.defaultLevelColors[event.level]; + var emoji = PrettyPrinter.defaultLevelEmojis[event.level]; var methodName = _getMethodName(); var methodNameSection = printCallingFunctionName && methodName != null ? ' | $methodName' : ''; - var stackLog = event.stackTrace.toString(); + var stackLog = event.stackTrace?.toString() ?? ''; var output = '$emoji $className$methodNameSection - ${event.message}${event.error != null ? '\nERROR: ${event.error}\n' : ''}${printCallStack ? '\nSTACKTRACE:\n$stackLog' : ''}'; @@ -59,7 +59,7 @@ class SimpleLogPrinter extends LogPrinter { if (kReleaseMode) { return match.group(0)!; } else { - return color!(match.group(0)!); + return color != null ? color(match.group(0)!) : match.group(0)!; } })); } diff --git a/example/router_example/lib/app/app.router.dart b/example/router_example/lib/app/app.router.dart index 8794a1bd8..65c3bf7b3 100644 --- a/example/router_example/lib/app/app.router.dart +++ b/example/router_example/lib/app/app.router.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // StackedRouterGenerator @@ -10,8 +10,8 @@ import 'package:flutter/material.dart' as _i13; import 'package:stacked/stacked.dart' as _i12; import 'package:stacked_services/stacked_services.dart' as _i11; -import '../datamodels/clashable_one.dart' as _i15; -import '../datamodels/clashable_two.dart' as _i16; +import '../datamodels/clashable_one.dart' as _i14; +import '../datamodels/clashable_two.dart' as _i15; import '../datamodels/home_type.dart' as _i1; import '../ui/bottom_nav/bottom_nav_example.dart' as _i3; import '../ui/bottom_nav/favorites/favorites_view.dart' as _i7; @@ -23,11 +23,9 @@ import '../ui/multiple_futures_example/multiple_futures_example_view.dart' as _i10; import '../ui/nonreactive/nonreactive_view.dart' as _i6; import '../ui/stream_view/stream_counter_view.dart' as _i4; -import 'app.dart' as _i14; -final stackedRouter = StackedRouterWeb( - navigatorKey: _i11.StackedService.navigatorKey, -); +final stackedRouter = + StackedRouterWeb(navigatorKey: _i11.StackedService.navigatorKey); class StackedRouterWeb extends _i12.RootStackRouter { StackedRouterWeb({_i13.GlobalKey<_i13.NavigatorState>? navigatorKey}) @@ -36,9 +34,8 @@ class StackedRouterWeb extends _i12.RootStackRouter { @override final Map pagesMap = { HomeViewRoute.name: (routeData) { - final args = routeData.argsAs( - orElse: () => const HomeViewArgs(), - ); + final args = + routeData.argsAs(orElse: () => const HomeViewArgs()); return _i12.MaterialPageX( routeData: routeData, child: _i2.HomeView( @@ -52,8 +49,7 @@ class StackedRouterWeb extends _i12.RootStackRouter { }, BottomNavExampleRoute.name: (routeData) { final args = routeData.argsAs( - orElse: () => const BottomNavExampleArgs(), - ); + orElse: () => const BottomNavExampleArgs()); return _i12.MaterialPageX( routeData: routeData, child: _i3.BottomNavExample(key: args.key), @@ -81,30 +77,27 @@ class StackedRouterWeb extends _i12.RootStackRouter { }, NonReactiveViewRoute.name: (routeData) { final args = routeData.argsAs( - orElse: () => const NonReactiveViewArgs(), - ); - return _i12.CustomPage( + orElse: () => const NonReactiveViewArgs()); + return _i12.MaterialPageX( routeData: routeData, child: _i6.NonReactiveView(key: args.key), - customRouteBuilder: _i14.RouteBuilders.bottomSheetBuilder, - opaque: true, - barrierDismissible: false, ); }, FavoritesViewRoute.name: (routeData) { final args = routeData.argsAs( - orElse: () => const FavoritesViewArgs(), - ); + orElse: () => const FavoritesViewArgs()); return _i12.AdaptivePage( routeData: routeData, - child: _i7.FavoritesView(key: args.key, id: args.id), + child: _i7.FavoritesView( + key: args.key, + id: args.id, + ), opaque: true, ); }, HistoryViewRoute.name: (routeData) { final args = routeData.argsAs( - orElse: () => const HistoryViewArgs(), - ); + orElse: () => const HistoryViewArgs()); return _i12.CustomPage( routeData: routeData, child: _i8.HistoryView(key: args.key), @@ -114,8 +107,7 @@ class StackedRouterWeb extends _i12.RootStackRouter { }, ProfileViewRoute.name: (routeData) { final args = routeData.argsAs( - orElse: () => const ProfileViewArgs(), - ); + orElse: () => const ProfileViewArgs()); return _i12.CupertinoPageX( routeData: routeData, child: _i9.ProfileView(key: args.key), @@ -123,8 +115,7 @@ class StackedRouterWeb extends _i12.RootStackRouter { }, MultipleFuturesExampleViewRoute.name: (routeData) { final args = routeData.argsAs( - orElse: () => const MultipleFuturesExampleViewArgs(), - ); + orElse: () => const MultipleFuturesExampleViewArgs()); return _i12.MaterialPageX( routeData: routeData, child: _i10.MultipleFuturesExampleView(key: args.key), @@ -134,7 +125,10 @@ class StackedRouterWeb extends _i12.RootStackRouter { @override List<_i12.RouteConfig> get routes => [ - _i12.RouteConfig(HomeViewRoute.name, path: '/'), + _i12.RouteConfig( + HomeViewRoute.name, + path: '/', + ), _i12.RouteConfig( BottomNavExampleRoute.name, path: '/bottom-nav-example', @@ -175,10 +169,18 @@ class StackedRouterWeb extends _i12.RootStackRouter { ), ], ), - _i12.RouteConfig(StreamCounterViewRoute.name, - path: '/stream-counter-view'), - _i12.RouteConfig(ExampleFormViewRoute.name, path: '/example-form-view'), - _i12.RouteConfig(NonReactiveViewRoute.name, path: '/non-reactive-view'), + _i12.RouteConfig( + StreamCounterViewRoute.name, + path: '/stream-counter-view', + ), + _i12.RouteConfig( + ExampleFormViewRoute.name, + path: '/example-form-view', + ), + _i12.RouteConfig( + NonReactiveViewRoute.name, + path: '/non-reactive-view', + ), ]; } @@ -189,10 +191,10 @@ class HomeViewRoute extends _i12.PageRouteInfo { _i13.Key? key, String? title = 'hello', bool? isLoggedIn = false, - _i15.Clashable Function(String)? clashableGetter, + _i14.Clashable Function(String)? clashableGetter, List<_i1.HomeType> homeTypes = const [ _i1.HomeType.apartment, - _i1.HomeType.house, + _i1.HomeType.house ], }) : super( HomeViewRoute.name, @@ -224,7 +226,7 @@ class HomeViewArgs { final bool? isLoggedIn; - final _i15.Clashable Function(String)? clashableGetter; + final _i14.Clashable Function(String)? clashableGetter; final List<_i1.HomeType> homeTypes; @@ -237,8 +239,10 @@ class HomeViewArgs { /// generated route for /// [_i3.BottomNavExample] class BottomNavExampleRoute extends _i12.PageRouteInfo { - BottomNavExampleRoute({_i13.Key? key, List<_i12.PageRouteInfo>? children}) - : super( + BottomNavExampleRoute({ + _i13.Key? key, + List<_i12.PageRouteInfo>? children, + }) : super( BottomNavExampleRoute.name, path: '/bottom-nav-example', args: BottomNavExampleArgs(key: key), @@ -264,22 +268,28 @@ class BottomNavExampleArgs { class StreamCounterViewRoute extends _i12.PageRouteInfo { StreamCounterViewRoute({ _i13.Key? key, - required List<_i16.Clashable> clashableTwo, + required List<_i15.Clashable> clashableTwo, }) : super( StreamCounterViewRoute.name, path: '/stream-counter-view', - args: StreamCounterViewArgs(key: key, clashableTwo: clashableTwo), + args: StreamCounterViewArgs( + key: key, + clashableTwo: clashableTwo, + ), ); static const String name = 'StreamCounterView'; } class StreamCounterViewArgs { - const StreamCounterViewArgs({this.key, required this.clashableTwo}); + const StreamCounterViewArgs({ + this.key, + required this.clashableTwo, + }); final _i13.Key? key; - final List<_i16.Clashable> clashableTwo; + final List<_i15.Clashable> clashableTwo; @override String toString() { @@ -290,22 +300,30 @@ class StreamCounterViewArgs { /// generated route for /// [_i5.ExampleFormView] class ExampleFormViewRoute extends _i12.PageRouteInfo { - ExampleFormViewRoute({_i13.Key? key, required _i15.Clashable clashableOne}) - : super( + ExampleFormViewRoute({ + _i13.Key? key, + required _i14.Clashable clashableOne, + }) : super( ExampleFormViewRoute.name, path: '/example-form-view', - args: ExampleFormViewArgs(key: key, clashableOne: clashableOne), + args: ExampleFormViewArgs( + key: key, + clashableOne: clashableOne, + ), ); static const String name = 'ExampleFormView'; } class ExampleFormViewArgs { - const ExampleFormViewArgs({this.key, required this.clashableOne}); + const ExampleFormViewArgs({ + this.key, + required this.clashableOne, + }); final _i13.Key? key; - final _i15.Clashable clashableOne; + final _i14.Clashable clashableOne; @override String toString() { @@ -347,7 +365,10 @@ class FavoritesViewRoute extends _i12.PageRouteInfo { }) : super( FavoritesViewRoute.name, path: 'favourites', - args: FavoritesViewArgs(key: key, id: id), + args: FavoritesViewArgs( + key: key, + id: id, + ), initialChildren: children, ); @@ -355,7 +376,10 @@ class FavoritesViewRoute extends _i12.PageRouteInfo { } class FavoritesViewArgs { - const FavoritesViewArgs({this.key, this.id}); + const FavoritesViewArgs({ + this.key, + this.id, + }); final _i13.Key? key; @@ -445,10 +469,10 @@ extension RouterStateExtension on _i11.RouterService { _i13.Key? key, String? title = 'hello', bool? isLoggedIn = false, - _i15.Clashable Function(String)? clashableGetter, + _i14.Clashable Function(String)? clashableGetter, List<_i1.HomeType> homeTypes = const [ _i1.HomeType.apartment, - _i1.HomeType.house, + _i1.HomeType.house ], void Function(_i12.NavigationFailure)? onFailure, }) async { @@ -468,27 +492,38 @@ extension RouterStateExtension on _i11.RouterService { _i13.Key? key, void Function(_i12.NavigationFailure)? onFailure, }) async { - return navigateTo(BottomNavExampleRoute(key: key), onFailure: onFailure); + return navigateTo( + BottomNavExampleRoute( + key: key, + ), + onFailure: onFailure, + ); } Future navigateToStreamCounterView({ _i13.Key? key, - required List<_i16.Clashable> clashableTwo, + required List<_i15.Clashable> clashableTwo, void Function(_i12.NavigationFailure)? onFailure, }) async { return navigateTo( - StreamCounterViewRoute(key: key, clashableTwo: clashableTwo), + StreamCounterViewRoute( + key: key, + clashableTwo: clashableTwo, + ), onFailure: onFailure, ); } Future navigateToExampleFormView({ _i13.Key? key, - required _i15.Clashable clashableOne, + required _i14.Clashable clashableOne, void Function(_i12.NavigationFailure)? onFailure, }) async { return navigateTo( - ExampleFormViewRoute(key: key, clashableOne: clashableOne), + ExampleFormViewRoute( + key: key, + clashableOne: clashableOne, + ), onFailure: onFailure, ); } @@ -497,7 +532,12 @@ extension RouterStateExtension on _i11.RouterService { _i13.Key? key, void Function(_i12.NavigationFailure)? onFailure, }) async { - return navigateTo(NonReactiveViewRoute(key: key), onFailure: onFailure); + return navigateTo( + NonReactiveViewRoute( + key: key, + ), + onFailure: onFailure, + ); } Future navigateToFavoritesView({ @@ -506,7 +546,10 @@ extension RouterStateExtension on _i11.RouterService { void Function(_i12.NavigationFailure)? onFailure, }) async { return navigateTo( - FavoritesViewRoute(key: key, id: id), + FavoritesViewRoute( + key: key, + id: id, + ), onFailure: onFailure, ); } @@ -515,14 +558,24 @@ extension RouterStateExtension on _i11.RouterService { _i13.Key? key, void Function(_i12.NavigationFailure)? onFailure, }) async { - return navigateTo(HistoryViewRoute(key: key), onFailure: onFailure); + return navigateTo( + HistoryViewRoute( + key: key, + ), + onFailure: onFailure, + ); } Future navigateToNestedProfileViewInBottomNavExampleRouter({ _i13.Key? key, void Function(_i12.NavigationFailure)? onFailure, }) async { - return navigateTo(ProfileViewRoute(key: key), onFailure: onFailure); + return navigateTo( + ProfileViewRoute( + key: key, + ), + onFailure: onFailure, + ); } Future @@ -531,7 +584,9 @@ extension RouterStateExtension on _i11.RouterService { void Function(_i12.NavigationFailure)? onFailure, }) async { return navigateTo( - MultipleFuturesExampleViewRoute(key: key), + MultipleFuturesExampleViewRoute( + key: key, + ), onFailure: onFailure, ); } @@ -540,17 +595,22 @@ extension RouterStateExtension on _i11.RouterService { _i13.Key? key, void Function(_i12.NavigationFailure)? onFailure, }) async { - return navigateTo(HistoryViewRoute(key: key), onFailure: onFailure); + return navigateTo( + HistoryViewRoute( + key: key, + ), + onFailure: onFailure, + ); } Future replaceWithHomeView({ _i13.Key? key, String? title = 'hello', bool? isLoggedIn = false, - _i15.Clashable Function(String)? clashableGetter, + _i14.Clashable Function(String)? clashableGetter, List<_i1.HomeType> homeTypes = const [ _i1.HomeType.apartment, - _i1.HomeType.house, + _i1.HomeType.house ], void Function(_i12.NavigationFailure)? onFailure, }) async { @@ -570,27 +630,38 @@ extension RouterStateExtension on _i11.RouterService { _i13.Key? key, void Function(_i12.NavigationFailure)? onFailure, }) async { - return replaceWith(BottomNavExampleRoute(key: key), onFailure: onFailure); + return replaceWith( + BottomNavExampleRoute( + key: key, + ), + onFailure: onFailure, + ); } Future replaceWithStreamCounterView({ _i13.Key? key, - required List<_i16.Clashable> clashableTwo, + required List<_i15.Clashable> clashableTwo, void Function(_i12.NavigationFailure)? onFailure, }) async { return replaceWith( - StreamCounterViewRoute(key: key, clashableTwo: clashableTwo), + StreamCounterViewRoute( + key: key, + clashableTwo: clashableTwo, + ), onFailure: onFailure, ); } Future replaceWithExampleFormView({ _i13.Key? key, - required _i15.Clashable clashableOne, + required _i14.Clashable clashableOne, void Function(_i12.NavigationFailure)? onFailure, }) async { return replaceWith( - ExampleFormViewRoute(key: key, clashableOne: clashableOne), + ExampleFormViewRoute( + key: key, + clashableOne: clashableOne, + ), onFailure: onFailure, ); } @@ -599,7 +670,12 @@ extension RouterStateExtension on _i11.RouterService { _i13.Key? key, void Function(_i12.NavigationFailure)? onFailure, }) async { - return replaceWith(NonReactiveViewRoute(key: key), onFailure: onFailure); + return replaceWith( + NonReactiveViewRoute( + key: key, + ), + onFailure: onFailure, + ); } Future replaceWithFavoritesView({ @@ -608,7 +684,10 @@ extension RouterStateExtension on _i11.RouterService { void Function(_i12.NavigationFailure)? onFailure, }) async { return replaceWith( - FavoritesViewRoute(key: key, id: id), + FavoritesViewRoute( + key: key, + id: id, + ), onFailure: onFailure, ); } @@ -617,14 +696,24 @@ extension RouterStateExtension on _i11.RouterService { _i13.Key? key, void Function(_i12.NavigationFailure)? onFailure, }) async { - return replaceWith(HistoryViewRoute(key: key), onFailure: onFailure); + return replaceWith( + HistoryViewRoute( + key: key, + ), + onFailure: onFailure, + ); } Future replaceWithNestedProfileViewInBottomNavExampleRouter({ _i13.Key? key, void Function(_i12.NavigationFailure)? onFailure, }) async { - return replaceWith(ProfileViewRoute(key: key), onFailure: onFailure); + return replaceWith( + ProfileViewRoute( + key: key, + ), + onFailure: onFailure, + ); } Future @@ -633,7 +722,9 @@ extension RouterStateExtension on _i11.RouterService { void Function(_i12.NavigationFailure)? onFailure, }) async { return replaceWith( - MultipleFuturesExampleViewRoute(key: key), + MultipleFuturesExampleViewRoute( + key: key, + ), onFailure: onFailure, ); } @@ -642,6 +733,11 @@ extension RouterStateExtension on _i11.RouterService { _i13.Key? key, void Function(_i12.NavigationFailure)? onFailure, }) async { - return replaceWith(HistoryViewRoute(key: key), onFailure: onFailure); + return replaceWith( + HistoryViewRoute( + key: key, + ), + onFailure: onFailure, + ); } } diff --git a/example/router_example/lib/ui/drop_down_menu_from/select_location_view.form.dart b/example/router_example/lib/ui/drop_down_menu_from/select_location_view.form.dart index f990d00fd..3391ac4f9 100644 --- a/example/router_example/lib/ui/drop_down_menu_from/select_location_view.form.dart +++ b/example/router_example/lib/ui/drop_down_menu_from/select_location_view.form.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // StackedFormGenerator @@ -7,6 +7,7 @@ // ignore_for_file: public_member_api_docs, constant_identifier_names, non_constant_identifier_names,unnecessary_this +import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart'; const String CountryValueKey = 'country'; diff --git a/example/router_example/lib/ui/form/example_form_view.dart b/example/router_example/lib/ui/form/example_form_view.dart index d35aeb377..0593a7df4 100644 --- a/example/router_example/lib/ui/form/example_form_view.dart +++ b/example/router_example/lib/ui/form/example_form_view.dart @@ -13,7 +13,7 @@ import 'example_form_viewmodel.dart'; fields: [ FormTextField( name: 'email', - initialValue: "Lorem", + initialValue: "lorem@test.com", validator: FormValidators.emailValidator, ), FormTextField( diff --git a/example/router_example/lib/ui/form/example_form_view.form.dart b/example/router_example/lib/ui/form/example_form_view.form.dart index 35b39f258..d5d63950c 100644 --- a/example/router_example/lib/ui/form/example_form_view.form.dart +++ b/example/router_example/lib/ui/form/example_form_view.form.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // StackedFormGenerator @@ -39,7 +39,8 @@ final Map _ExampleFormViewTextValidations = mixin $ExampleFormView { TextEditingController get emailController => - _getFormTextEditingController(EmailValueKey, initialValue: 'Lorem'); + _getFormTextEditingController(EmailValueKey, + initialValue: 'lorem@test.com'); CustomEditingController get passwordController => _getPasswordCustomFormTextEditingController(PasswordValueKey); CustomEditingController get shortBioController => @@ -310,7 +311,7 @@ String? getValidationMessage(String key) { if (validatorForKey == null) return null; String? validationMessageForKey = validatorForKey( - _ExampleFormViewTextEditingControllers[key]!.text, + _ExampleFormViewTextEditingControllers[key]?.text, ); return validationMessageForKey; diff --git a/example/router_example/lib/ui/form/example_form_viewmodel.dart b/example/router_example/lib/ui/form/example_form_viewmodel.dart index 61762b0df..ea78ed762 100644 --- a/example/router_example/lib/ui/form/example_form_viewmodel.dart +++ b/example/router_example/lib/ui/form/example_form_viewmodel.dart @@ -37,6 +37,9 @@ class ExampleFormViewModel extends FormViewModel { // data to the backend or db. Future saveData() async { + // Run the field validators before checking validity. Newer generated forms + // no longer validate implicitly inside `isFormValid`. + validateForm(); if (!isFormValid) return; // here we can run custom functionality to save to our api diff --git a/example/router_example/lib/ui/future_example_view/future_example_viewmodel.dart b/example/router_example/lib/ui/future_example_view/future_example_viewmodel.dart index 49521d0a0..8a40a5997 100644 --- a/example/router_example/lib/ui/future_example_view/future_example_viewmodel.dart +++ b/example/router_example/lib/ui/future_example_view/future_example_viewmodel.dart @@ -8,7 +8,7 @@ class FutureExampleViewModel extends FutureViewModel { } @override - void onError(error) {} + void onError(dynamic error, StackTrace? stackTrace) {} @override Future futureToRun() => getDataFromServer(); diff --git a/example/router_example/lib/ui/stream_view/stream_counter_viewmodel.dart b/example/router_example/lib/ui/stream_view/stream_counter_viewmodel.dart index 6c88f1f7e..58b9357e6 100644 --- a/example/router_example/lib/ui/stream_view/stream_counter_viewmodel.dart +++ b/example/router_example/lib/ui/stream_view/stream_counter_viewmodel.dart @@ -38,7 +38,7 @@ class StreamCounterViewModel extends StreamViewModel { void onSubscribed() {} @override - void onError(error) {} + void onError(dynamic error, StackTrace? stackTrace) {} void changeStreamSources() { isSlowEpochNumbers = !isSlowEpochNumbers; diff --git a/example/router_example/macos/Flutter/GeneratedPluginRegistrant.swift b/example/router_example/macos/Flutter/GeneratedPluginRegistrant.swift index 2e86147d3..860d705af 100644 --- a/example/router_example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/example/router_example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -15,6 +15,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) FLTFirebaseCrashlyticsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCrashlyticsPlugin")) - FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) + FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) } diff --git a/example/router_example/pubspec.yaml b/example/router_example/pubspec.yaml index 5ffc30b66..8315f7ef7 100644 --- a/example/router_example/pubspec.yaml +++ b/example/router_example/pubspec.yaml @@ -35,7 +35,6 @@ dependencies: flutter_hooks: ^0.18.4 # navigation - get: ^4.6.3 animations: ^2.0.3 url_strategy: ^0.2.0 shared_preferences: ^2.1.1 diff --git a/example/router_example/windows/flutter/generated_plugin_registrant.cc b/example/router_example/windows/flutter/generated_plugin_registrant.cc index 8b6d4680a..1a82e7d01 100644 --- a/example/router_example/windows/flutter/generated_plugin_registrant.cc +++ b/example/router_example/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,9 @@ #include "generated_plugin_registrant.h" +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + FirebaseCorePluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); } diff --git a/example/router_example/windows/flutter/generated_plugins.cmake b/example/router_example/windows/flutter/generated_plugins.cmake index b93c4c30c..fa8a39bab 100644 --- a/example/router_example/windows/flutter/generated_plugins.cmake +++ b/example/router_example/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + firebase_core ) list(APPEND FLUTTER_FFI_PLUGIN_LIST