Fix duplicate launch screen and native splash exit flashing
This commit is contained in:
@@ -1,48 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'tp_launch_page.dart';
|
||||
|
||||
/// Displays the brand during real initialization, without a minimum wait.
|
||||
class TpStartup extends StatelessWidget {
|
||||
const TpStartup({super.key, required this.ready, required this.child});
|
||||
final Future<void> ready;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => FutureBuilder<void>(
|
||||
future: ready,
|
||||
builder: (context, snapshot) {
|
||||
final complete = snapshot.connectionState == ConnectionState.done;
|
||||
final reduceMotion =
|
||||
MediaQuery.maybeOf(context)?.disableAnimations ??
|
||||
WidgetsBinding
|
||||
.instance
|
||||
.platformDispatcher
|
||||
.accessibilityFeatures
|
||||
.disableAnimations;
|
||||
return AnimatedSwitcher(
|
||||
duration: reduceMotion
|
||||
? Duration.zero
|
||||
: const Duration(milliseconds: 220),
|
||||
switchInCurve: Curves.easeOut,
|
||||
switchOutCurve: Curves.easeIn,
|
||||
child: complete
|
||||
? AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
key: const ValueKey('tp-ready'),
|
||||
value: SystemUiOverlayStyle.dark.copyWith(
|
||||
statusBarColor: Colors.transparent,
|
||||
systemNavigationBarColor: const Color(0xFFF3F7FF),
|
||||
systemNavigationBarIconBrightness: Brightness.dark,
|
||||
),
|
||||
child: child,
|
||||
)
|
||||
: const MaterialApp(
|
||||
key: ValueKey('tp-launch'),
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: TpLaunchPage(),
|
||||
),
|
||||
);
|
||||
},
|
||||
/// The native launch screen remains until runApp submits the initialized app.
|
||||
/// Use normal bootstrap instead of a second splash or deferred warm-up frames.
|
||||
Future<void> launchApplication({
|
||||
required Future<void> ready,
|
||||
required Widget child,
|
||||
}) async {
|
||||
try {
|
||||
await ready;
|
||||
} catch (_) {
|
||||
// AppController exposes initialization failures in its recovery UI.
|
||||
// Preserve access to that UI instead of leaving the native launch visible.
|
||||
}
|
||||
runApp(
|
||||
AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: SystemUiOverlayStyle.dark.copyWith(
|
||||
statusBarColor: Colors.transparent,
|
||||
systemNavigationBarColor: const Color(0xFFF3F7FF),
|
||||
systemNavigationBarIconBrightness: Brightness.dark,
|
||||
),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user