Created
July 25, 2020 12:36
-
-
Save mutant0113/047d0138b089684d1f01e296f8089245 to your computer and use it in GitHub Desktop.
FlutterContainerTransformShrink
This file contains hidden or 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
class _PageAState extends State<PageA> { | |
... | |
// A widget for page transition between the `pageA` and `pageB` after tapping the `FAB button`. | |
Widget get _pageTransition { | |
// Dismiss ripple widget if `_pageTransitionRect` is null. | |
if (_pageTransitionRect == null) { | |
return Container(); | |
} | |
return AnimatedPositioned.fromRect( | |
rect: _pageTransitionRect, | |
duration: Duration(milliseconds: 300), | |
child: Container( | |
decoration: BoxDecoration( | |
shape: BoxShape.circle, | |
color: _FabButtonColor, | |
), | |
), | |
onEnd: () { | |
bool shouldNavigatePage = _pageTransitionRect != _fabButtonRect; | |
if (shouldNavigatePage) { | |
Navigator.push( | |
context, | |
FadeRouteBuilder(page: PageB()), | |
).then((_) { | |
// Shrink back to the normal FAB button size. | |
setState(() => _pageTransitionRect = _fabButtonRect); | |
}); | |
} else { | |
// Dismiss ripple widget after shrinking finishes. | |
setState(() => _pageTransitionRect = null); | |
} | |
}, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment