diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ba765e..e99e036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.3.1 [2022-02-26] +- fixes alignment + ## 0.3.0 [2022-02-26] - adds parameters for manipulating size animation - enables disabling of size animation for performance reasons diff --git a/example/pubspec.lock b/example/pubspec.lock index 8fc67e3..869d93a 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -49,7 +49,7 @@ packages: path: ".." relative: true source: path - version: "0.2.1" + version: "0.3.0" fake_async: dependency: transitive description: diff --git a/lib/src/cross_fade_widget.dart b/lib/src/cross_fade_widget.dart index 69937ee..508faae 100644 --- a/lib/src/cross_fade_widget.dart +++ b/lib/src/cross_fade_widget.dart @@ -111,18 +111,18 @@ class _CrossFadeState extends State> super.initState(); _todo = [widget.value]; _opacityController = - AnimationController(vsync: this, duration: widget.duration, value: 1.0) - ..addStatusListener((status) { - if (status == AnimationStatus.completed) { - if (_todo.length <= 1) return; - _todo.removeAt(0); - // rebuild necessary for setting GlobalKeys simultaneously - setState(() {}); - if (_todo.length > 1) { - _animateNext(); - } - } - }); + AnimationController(vsync: this, duration: widget.duration, value: 1.0) + ..addStatusListener((status) { + if (status == AnimationStatus.completed) { + if (_todo.length <= 1) return; + _todo.removeAt(0); + // rebuild necessary for setting GlobalKeys simultaneously + setState(() {}); + if (_todo.length > 1) { + _animateNext(); + } + } + }); _sizeController = AnimationController( vsync: this, @@ -199,6 +199,7 @@ class _CrossFadeState extends State> Widget build(BuildContext context) { bool twoActive = _todo.length > 1; T current = twoActive ? _todo[1] : _todo[0]; + T first = _todo[0]; return LayoutBuilder( builder: (context, constraints) => Stack( fit: StackFit.passthrough, @@ -223,8 +224,8 @@ class _CrossFadeState extends State> child: child, ), child: EmptyWidget( - key: _getKey(_todo[0]), - child: widget.builder(context, _todo[0])), + key: _getKey(first), + child: widget.builder(context, first)), ), ), ), @@ -241,6 +242,7 @@ class _CrossFadeState extends State> clipBehavior: widget.clipBehavior, duration: widget.sizeDuration ?? widget.duration, curve: widget.sizeCurve, + alignment: widget.stackAlignment, child: AnimatedBuilder( animation: _opacityAnimation, builder: (context, child) => Opacity( diff --git a/lib/src/widgets/animated_size.dart b/lib/src/widgets/animated_size.dart index d0f2539..d6f45d5 100644 --- a/lib/src/widgets/animated_size.dart +++ b/lib/src/widgets/animated_size.dart @@ -8,6 +8,7 @@ class CustomAnimatedSize extends StatefulWidget { final Duration duration; final Curve curve; final Widget child; + final AlignmentGeometry alignment; const CustomAnimatedSize({ Key? key, @@ -15,6 +16,7 @@ class CustomAnimatedSize extends StatefulWidget { required this.duration, this.curve = Curves.linear, required this.child, + this.alignment = Alignment.center, }) : super(key: key); @override @@ -32,7 +34,8 @@ class _CustomAnimatedSizeState extends State { clipBehavior: widget.clipBehavior, duration: widget.duration, curve: widget.curve, + alignment: widget.alignment, child: child, ); } -} \ No newline at end of file +} diff --git a/pubspec.yaml b/pubspec.yaml index f405789..e5d1c5e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: cross_fade description: A widget to apply a crossfade animation between different states and/or widgets. -version: 0.3.0 +version: 0.3.1 repository: https://github.com/SplashByte/cross_fade environment: