From ebc2738da43ee9dea7942c1bcf886042b7f5cfd9 Mon Sep 17 00:00:00 2001 From: gusrod-coder Date: Sun, 22 Mar 2026 22:21:55 -0400 Subject: [PATCH 1/2] Added center map and fixed compile error Added centering for map (on app start, or directly after the user declares that they will allow location tracking) - Edited build gradle and settings gradle to remove compiling error (kotlin 2.3 instead of 2.1). --- android/app/build.gradle.kts | 6 ++++-- android/settings.gradle.kts | 2 +- lib/screens/map_screen.dart | 7 +++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 4cc0d1f..b0540ed 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -38,9 +38,11 @@ android { isCoreLibraryDesugaringEnabled = true } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_11.toString() + kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11 } +} defaultConfig { applicationId = "com.ishankumar.maizebus" diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts index 5067194..06d5bca 100644 --- a/android/settings.gradle.kts +++ b/android/settings.gradle.kts @@ -24,7 +24,7 @@ plugins { id("com.google.gms.google-services") version("4.3.15") apply false // END: FlutterFire Configuration - id("org.jetbrains.kotlin.android") version "2.1.0" apply false + id("org.jetbrains.kotlin.android") version "2.3.0" apply false } include(":app") diff --git a/lib/screens/map_screen.dart b/lib/screens/map_screen.dart index c30b8c9..460ffa3 100644 --- a/lib/screens/map_screen.dart +++ b/lib/screens/map_screen.dart @@ -272,6 +272,7 @@ class _MaizeBusCoreState extends State { content: Text(startupData.persistantMessage), ); } + // loading all this data in parallel await Future.wait([ @@ -306,6 +307,10 @@ class _MaizeBusCoreState extends State { busProvider.startBusUpdates(); busProvider.startRouteUpdates(); await Future.delayed(const Duration(milliseconds: 180)); + + // Center map on user's location on startup if available + + } // need this to make sure that the stop names exist in the cache @@ -1080,6 +1085,7 @@ class _MaizeBusCoreState extends State { void _onMapCreated(GoogleMapController controller) { _mapController = controller; + _centerOnLocation(true); } void _onCameraMove(CameraPosition position) async { @@ -1936,6 +1942,7 @@ class _MaizeBusCoreState extends State { } Position? position = await Geolocator.getLastKnownPosition(); + _centerOnLocation(true); return position; } catch (e) { ScaffoldMessenger.of(context).showSnackBar( From 9e849cc7b1518a0fd9dfd6bd5c8eaebfc89e8a2e Mon Sep 17 00:00:00 2001 From: gusrod-coder Date: Mon, 23 Mar 2026 18:01:13 -0400 Subject: [PATCH 2/2] Fixed Centering Infinite Loop Removed unneccessary comments and reimplemented location centering immediately after location permissions are provided to avoid infinite centering loop --- lib/screens/map_screen.dart | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/screens/map_screen.dart b/lib/screens/map_screen.dart index 460ffa3..4fc5017 100644 --- a/lib/screens/map_screen.dart +++ b/lib/screens/map_screen.dart @@ -307,10 +307,6 @@ class _MaizeBusCoreState extends State { busProvider.startBusUpdates(); busProvider.startRouteUpdates(); await Future.delayed(const Duration(milliseconds: 180)); - - // Center map on user's location on startup if available - - } // need this to make sure that the stop names exist in the cache @@ -1927,6 +1923,10 @@ class _MaizeBusCoreState extends State { ); return null; } + else { + //Center map once right after user grants location permissions + _centerOnLocation(true); + } } if (permission == LocationPermission.deniedForever) { @@ -1942,7 +1942,6 @@ class _MaizeBusCoreState extends State { } Position? position = await Geolocator.getLastKnownPosition(); - _centerOnLocation(true); return position; } catch (e) { ScaffoldMessenger.of(context).showSnackBar(