diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 8e53312..210c57a 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -18,9 +18,8 @@ - - - + + (create: (_) => AppState()), ], child: Api.isDev - ? Banner( - message: "DEV", - location: BannerLocation.topEnd, - color: Colors.orange, - textStyle: const TextStyle( - fontSize: 10, - fontWeight: FontWeight.bold, - color: Colors.white, - ), - layoutDirection: TextDirection.ltr, - child: MaterialApp( - scaffoldMessengerKey: rootScaffoldMessengerKey, - debugShowCheckedModeBanner: false, - title: "Payfrit DEV", - initialRoute: AppRoutes.splash, - routes: AppRoutes.routes, + ? Directionality( + textDirection: TextDirection.ltr, + child: Banner( + message: "DEV", + location: BannerLocation.topEnd, + color: Colors.orange, + child: MaterialApp( + scaffoldMessengerKey: rootScaffoldMessengerKey, + debugShowCheckedModeBanner: false, + title: "Payfrit DEV", + initialRoute: AppRoutes.splash, + routes: AppRoutes.routes, + ), ), ) : MaterialApp( diff --git a/lib/screens/splash_screen.dart b/lib/screens/splash_screen.dart index 4af740f..78ec8e4 100644 --- a/lib/screens/splash_screen.dart +++ b/lib/screens/splash_screen.dart @@ -246,11 +246,18 @@ class _SplashScreenState extends State with TickerProviderStateMix // Initialize beacon scanning try { + // Close any existing ranging streams first + await flutterBeacon.close; + await flutterBeacon.initializeScanning; - // Only add delay if permissions were freshly granted (Bluetooth subsystem needs warmup) + // Always add warmup delay - Bluetooth adapter needs time to initialize + print('[Splash] 🔄 Bluetooth warmup...'); + await Future.delayed(const Duration(milliseconds: 2000)); + + // Extra delay if permissions were freshly granted if (_permissionsWereFreshlyGranted) { - print('[Splash] 🔄 Fresh permissions - adding Bluetooth warmup delay'); + print('[Splash] 🆕 Fresh permissions - adding extra warmup'); await Future.delayed(const Duration(milliseconds: 1500)); } @@ -274,7 +281,8 @@ class _SplashScreenState extends State with TickerProviderStateMix } }); - await Future.delayed(const Duration(milliseconds: 2000)); + // Scan for 5 seconds to ensure we catch beacons + await Future.delayed(const Duration(milliseconds: 5000)); await subscription.cancel(); // Now lookup business info for found beacons