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';
|
import 'home_screen.dart';
|
||||||
|
|
||||||
|
Widget _defaultNextScreen() => const HomeScreen();
|
||||||
|
|
||||||
/// Logo-assembly splash: four glossy blocks fly in to form a 2x2 mark, the
|
/// 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
|
/// wordmark fades in, then we hand off. SaveRepository is already opened in
|
||||||
/// main() so this doubles as perceived-zero loading time.
|
/// main() so this doubles as perceived-zero loading time.
|
||||||
class SplashScreen extends StatefulWidget {
|
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
|
/// Built when the splash finishes; the season title card task repoints
|
||||||
/// repoints this.
|
/// the default.
|
||||||
static Widget Function() nextScreen = () => const HomeScreen();
|
final Widget Function() nextScreen;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<SplashScreen> createState() => _SplashScreenState();
|
State<SplashScreen> createState() => _SplashScreenState();
|
||||||
@@ -24,7 +26,7 @@ class _SplashScreenState extends State<SplashScreen>
|
|||||||
)..addStatusListener((status) {
|
)..addStatusListener((status) {
|
||||||
if (status == AnimationStatus.completed && mounted) {
|
if (status == AnimationStatus.completed && mounted) {
|
||||||
Navigator.of(context).pushReplacement(
|
Navigator.of(context).pushReplacement(
|
||||||
MaterialPageRoute(builder: (_) => SplashScreen.nextScreen()),
|
MaterialPageRoute(builder: (_) => widget.nextScreen()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user