From 9f7000cf83579d36298b591961a4ff4cf85dda38 Mon Sep 17 00:00:00 2001 From: Miller Adulu Date: Sat, 24 Aug 2024 01:14:24 +0300 Subject: [PATCH] Fixes a bug with a missing context because of multiple initializations of the router (#109) --- ios/Runner.xcodeproj/project.pbxproj | 18 ++++++++++++++++++ lib/app.dart | 2 +- lib/common/utils/notification_service.dart | 8 +++++--- lib/common/utils/router.dart | 4 ++++ pubspec.lock | 4 ++-- pubspec.yaml | 2 +- 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index a49ea1e..5fc9e63 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -535,7 +535,9 @@ isa = XCBuildConfiguration; baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + BUILD_LIBRARY_FOR_DISTRIBUTION = NO; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; @@ -630,7 +632,9 @@ isa = XCBuildConfiguration; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + BUILD_LIBRARY_FOR_DISTRIBUTION = NO; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; @@ -720,7 +724,9 @@ isa = XCBuildConfiguration; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = NO; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + BUILD_LIBRARY_FOR_DISTRIBUTION = NO; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; @@ -815,7 +821,9 @@ isa = XCBuildConfiguration; baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-dev"; + BUILD_LIBRARY_FOR_DISTRIBUTION = NO; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; @@ -908,7 +916,9 @@ isa = XCBuildConfiguration; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-dev"; + BUILD_LIBRARY_FOR_DISTRIBUTION = NO; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; @@ -1000,7 +1010,9 @@ isa = XCBuildConfiguration; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-dev"; + BUILD_LIBRARY_FOR_DISTRIBUTION = NO; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; @@ -1095,7 +1107,9 @@ isa = XCBuildConfiguration; baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-stg"; + BUILD_LIBRARY_FOR_DISTRIBUTION = NO; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; @@ -1190,7 +1204,9 @@ isa = XCBuildConfiguration; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-stg"; + BUILD_LIBRARY_FOR_DISTRIBUTION = NO; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; @@ -1280,7 +1296,9 @@ isa = XCBuildConfiguration; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { + APPLICATION_EXTENSION_API_ONLY = NO; ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-stg"; + BUILD_LIBRARY_FOR_DISTRIBUTION = NO; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; diff --git a/lib/app.dart b/lib/app.dart index 80b6ef8..dc84e48 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -35,7 +35,7 @@ class MyAppState extends State { debugShowCheckedModeBanner: false, localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, - routerConfig: FlutterConRouter.router, + routerConfig: getIt().config(), ); }, ); diff --git a/lib/common/utils/notification_service.dart b/lib/common/utils/notification_service.dart index 67fb671..472630e 100644 --- a/lib/common/utils/notification_service.dart +++ b/lib/common/utils/notification_service.dart @@ -2,8 +2,8 @@ import 'package:awesome_notifications/awesome_notifications.dart'; import 'package:flutter/material.dart'; import 'package:fluttercon/common/data/models/local/local_session.dart'; import 'package:fluttercon/common/utils/router.dart'; +import 'package:fluttercon/core/di/injectable.dart'; import 'package:fluttercon/core/theme/theme_colors.dart'; -import 'package:go_router/go_router.dart'; import 'package:injectable/injectable.dart'; import 'package:logger/logger.dart'; @@ -86,8 +86,10 @@ class NotificationService { Logger().f(receivedAction); switch (receivedAction.channelKey) { case 'session_channel': - FlutterConRouter.globalNavigatorKey.currentContext - ?.pushReplacementNamed(FlutterConRouter.feedbackRoute); + Logger().f('Navigating to feedback screen'); + await getIt() + .config() + .push(FlutterConRouter.feedbackRoute); } } } diff --git a/lib/common/utils/router.dart b/lib/common/utils/router.dart index ba025ad..eeb1ab7 100644 --- a/lib/common/utils/router.dart +++ b/lib/common/utils/router.dart @@ -11,7 +11,9 @@ import 'package:fluttercon/features/home/ui/speakers_list_screen.dart'; import 'package:fluttercon/features/sessions/ui/session_details/session_details.dart'; import 'package:fluttercon/features/splash/splash_screen.dart'; import 'package:go_router/go_router.dart'; +import 'package:injectable/injectable.dart'; +@singleton class FlutterConRouter { static GoRouter get router => _router; @@ -24,6 +26,8 @@ class FlutterConRouter { static const String organiserDetailsRoute = '/organiser-details'; static const String feedbackRoute = '/feedback'; + GoRouter config() => router; + static GlobalKey get globalNavigatorKey => GlobalKey(); diff --git a/pubspec.lock b/pubspec.lock index 1324fa8..84d973d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1366,10 +1366,10 @@ packages: dependency: transitive description: name: vm_service - sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "14.2.4" + version: "14.2.5" watcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 19e9aa6..9a4a7f8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: fluttercon description: "A new Flutter project." publish_to: 'none' -version: 1.12.09+11209 +version: 1.13.00+11300 environment: sdk: ">=3.5.0 <4.0.0"