Unverified Commit 6ec3f3b7 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Remove extensions (#91453)

parent 61a0add2
...@@ -307,7 +307,7 @@ class NavigationDestination extends StatelessWidget { ...@@ -307,7 +307,7 @@ class NavigationDestination extends StatelessWidget {
_StatusTransitionWidgetBuilder( _StatusTransitionWidgetBuilder(
animation: animation, animation: animation,
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
return animation.isForwardOrCompleted return _isForwardOrCompleted(animation)
? selectedIconWidget ? selectedIconWidget
: unselectedIconWidget; : unselectedIconWidget;
}, },
...@@ -329,7 +329,7 @@ class NavigationDestination extends StatelessWidget { ...@@ -329,7 +329,7 @@ class NavigationDestination extends StatelessWidget {
upperLimit: 1, upperLimit: 1,
child: Text( child: Text(
label, label,
style: animation.isForwardOrCompleted style: _isForwardOrCompleted(animation)
? effectiveSelectedLabelTextStyle ? effectiveSelectedLabelTextStyle
: effectiveUnselectedLabelTextStyle, : effectiveUnselectedLabelTextStyle,
), ),
...@@ -566,7 +566,7 @@ class _NavigationIndicator extends StatelessWidget { ...@@ -566,7 +566,7 @@ class _NavigationIndicator extends StatelessWidget {
animation: animation, animation: animation,
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
return _SelectableAnimatedBuilder( return _SelectableAnimatedBuilder(
isSelected: animation.isForwardOrCompleted, isSelected: _isForwardOrCompleted(animation),
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
alwaysDoFullAnimation: true, alwaysDoFullAnimation: true,
builder: (BuildContext context, Animation<double> fadeAnimation) { builder: (BuildContext context, Animation<double> fadeAnimation) {
...@@ -725,7 +725,7 @@ class _NavigationBarDestinationSemantics extends StatelessWidget { ...@@ -725,7 +725,7 @@ class _NavigationBarDestinationSemantics extends StatelessWidget {
animation: destinationInfo.selectedAnimation, animation: destinationInfo.selectedAnimation,
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
return Semantics( return Semantics(
selected: destinationInfo.selectedAnimation.isForwardOrCompleted, selected: _isForwardOrCompleted(destinationInfo.selectedAnimation),
container: true, container: true,
child: child, child: child,
); );
...@@ -1154,9 +1154,9 @@ class _CurvedAnimationBuilderState extends State<_CurvedAnimationBuilder> { ...@@ -1154,9 +1154,9 @@ class _CurvedAnimationBuilderState extends State<_CurvedAnimationBuilder> {
} }
} }
/// Convenience static extensions on Animation. /// Returns `true` if this animation is ticking forward, or has completed,
extension _AnimationUtils on Animation<double> { /// based on [status].
/// Returns `true` if this animation is ticking forward, or has completed, bool _isForwardOrCompleted(Animation<double> animation) {
/// based on [status]. return animation.status == AnimationStatus.forward
bool get isForwardOrCompleted => status == AnimationStatus.forward || status == AnimationStatus.completed; || animation.status == AnimationStatus.completed;
} }
...@@ -15,10 +15,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -15,10 +15,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../image_data.dart'; import '../image_data.dart';
ByteData testByteData(double scale) => ByteData(8)..setFloat64(0, scale); ByteData testByteData(double scale) => ByteData(8)..setFloat64(0, scale);
double scaleOf(ByteData data) => data.getFloat64(0);
extension on ByteData {
double get scale => getFloat64(0);
}
const String testManifest = ''' const String testManifest = '''
{ {
...@@ -89,9 +86,8 @@ class TestAssetImage extends AssetImage { ...@@ -89,9 +86,8 @@ class TestAssetImage extends AssetImage {
ImageStreamCompleter load(AssetBundleImageKey key, DecoderCallback decode) { ImageStreamCompleter load(AssetBundleImageKey key, DecoderCallback decode) {
late ImageInfo imageInfo; late ImageInfo imageInfo;
key.bundle.load(key.name).then<void>((ByteData data) { key.bundle.load(key.name).then<void>((ByteData data) {
final ByteData testData = data; final ui.Image image = images[scaleOf(data)]!;
final ui.Image image = images[testData.scale]!; assert(image != null, 'Expected ${scaleOf(data)} to have a key in $images');
assert(image != null, 'Expected ${testData.scale} to have a key in $images');
imageInfo = ImageInfo(image: image, scale: key.scale); imageInfo = ImageInfo(image: image, scale: key.scale);
}); });
return FakeImageStreamCompleter( return FakeImageStreamCompleter(
......
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