refactor: splash nextScreen as constructor param instead of mutable static
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,15 +2,17 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'home_screen.dart';
|
||||
|
||||
Widget _defaultNextScreen() => const HomeScreen();
|
||||
|
||||
/// Logo-assembly splash: four glossy blocks fly in to form a 2x2 mark, the
|
||||
/// wordmark fades in, then we hand off. SaveRepository is already opened in
|
||||
/// main() so this doubles as perceived-zero loading time.
|
||||
class SplashScreen extends StatefulWidget {
|
||||
const SplashScreen({super.key});
|
||||
const SplashScreen({super.key, this.nextScreen = _defaultNextScreen});
|
||||
|
||||
/// Where the splash goes when finished; the season title card task
|
||||
/// repoints this.
|
||||
static Widget Function() nextScreen = () => const HomeScreen();
|
||||
/// Built when the splash finishes; the season title card task repoints
|
||||
/// the default.
|
||||
final Widget Function() nextScreen;
|
||||
|
||||
@override
|
||||
State<SplashScreen> createState() => _SplashScreenState();
|
||||
@@ -24,7 +26,7 @@ class _SplashScreenState extends State<SplashScreen>
|
||||
)..addStatusListener((status) {
|
||||
if (status == AnimationStatus.completed && mounted) {
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(builder: (_) => SplashScreen.nextScreen()),
|
||||
MaterialPageRoute(builder: (_) => widget.nextScreen()),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user