Unverified Commit 5eabfc24 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Allow nullable tweens in TweenAnimationBuilder (#72476)

parent 15c009b8
......@@ -113,7 +113,7 @@ import 'value_listenable_builder.dart';
/// [AnimatedBuilder], which can be used similarly to this
/// [TweenAnimationBuilder], but unlike the latter it is powered by a
/// developer-managed [AnimationController].
class TweenAnimationBuilder<T extends Object> extends ImplicitlyAnimatedWidget {
class TweenAnimationBuilder<T extends Object?> extends ImplicitlyAnimatedWidget {
/// Creates a [TweenAnimationBuilder].
///
/// The properties [tween], [duration], and [builder] are required. The values
......@@ -194,7 +194,7 @@ class TweenAnimationBuilder<T extends Object> extends ImplicitlyAnimatedWidget {
}
}
class _TweenAnimationBuilderState<T extends Object> extends AnimatedWidgetBaseState<TweenAnimationBuilder<T>> {
class _TweenAnimationBuilderState<T extends Object?> extends AnimatedWidgetBaseState<TweenAnimationBuilder<T>> {
Tween<T>? _currentTween;
@override
......
......@@ -387,4 +387,21 @@ void main() {
await tester.pump(const Duration(seconds: 2));
expect(values, everyElement(300));
});
testWidgets('Works with nullable tweens', (WidgetTester tester) async {
final List<Size?> values = <Size?>[];
await tester.pumpWidget(
TweenAnimationBuilder<Size?>(
duration: const Duration(seconds: 1),
tween: SizeTween(end: const Size(10,10)),
builder: (BuildContext context, Size? s, Widget? child) {
values.add(s);
return const Placeholder();
},
),
);
expect(values, <Size>[const Size(10,10)]);
await tester.pump(const Duration(seconds: 2));
expect(values, <Size>[const Size(10,10)]);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment