Allow nullable tweens in TweenAnimationBuilder (#72476)
This commit is contained in:
parent
15c009b805
commit
5eabfc2447
@ -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)]);
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user