-
Notifications
You must be signed in to change notification settings - Fork 1
refactor(splash) : Adjusted splash page and utilized flutter hooks #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| part of 'splash.dart'; | ||
|
|
||
| double useSplashPage() { | ||
| final context = useContext(); | ||
| // Using Flutter Hook to manage the breathing animation controller | ||
| final breathingAnimation = useAnimationController( | ||
| duration: const Duration(milliseconds: 500), | ||
| )..forward(); | ||
|
|
||
| final breathe = useAnimation(Tween<double>(begin: 0.8, end: 1.5).animate( | ||
| CurvedAnimation(parent: breathingAnimation, curve: Curves.easeOut), | ||
| )); | ||
|
|
||
| Future<void> checkFirstInstall(BuildContext context) async { | ||
| await Future.delayed(const Duration(seconds: 2)); | ||
| SharedPreferences prefs = await SharedPreferences.getInstance(); | ||
| final firstInstall = prefs.getBool('firstInstall') ?? true; | ||
|
|
||
| if (context.mounted) { | ||
| if (firstInstall) { | ||
| context.pushReplacement(Routes.onboarding); | ||
| prefs.setBool('firstInstall', false); | ||
| } else { | ||
| context.pushReplacement(Routes.authHome); | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+14
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Example: part of 'splash.dart';
double useSplashPage() {
final context = useContext();
// ... other hooks
useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((_) async {
await _checkFirstInstall(context);
});
return null;
}, []);
return breathe;
}
Future<void> _checkFirstInstall(BuildContext context) async {
// ... implementation
} |
||
|
|
||
| useEffect(() { | ||
| // Trigger the first-install check after the first frame. | ||
| WidgetsBinding.instance.addPostFrameCallback((_) async { | ||
| await checkFirstInstall(context); | ||
| }); | ||
| return null; | ||
| }, []); | ||
|
|
||
| return breathe; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a Flutter best practice to include
super.keyin widget constructors. This allows the framework to efficiently update and identify widgets. Please add it to the_StackedBoxesconstructor.