Created
October 31, 2022 11:24
-
-
Save VB10/897533953e687aacc738a45eab84be3f to your computer and use it in GitHub Desktop.
Widget switcher with animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:kartal/kartal.dart'; | |
class AnimatedPageSwitch extends StatelessWidget { | |
const AnimatedPageSwitch( | |
{super.key, | |
required this.isPageLoaded, | |
required this.loaderChild, | |
required this.completedChild}); | |
final bool isPageLoaded; | |
final Widget loaderChild; | |
final Widget completedChild; | |
@override | |
Widget build(BuildContext context) { | |
return AnimatedCrossFade( | |
duration: context.durationLow, | |
crossFadeState: | |
isPageLoaded ? CrossFadeState.showFirst : CrossFadeState.showSecond, | |
firstChild: loaderChild, | |
secondChild: isPageLoaded ? const SizedBox.shrink() : completedChild, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment