[various] Clean up deprecated_member_use ignores (#6123)

As of https://github.com/flutter/packages/pull/6111 `deprecated_member_use` is no longer on in the repository, so we no longer need (most; see below) of these annotations. Since we will not be annotating deprecated usage going forward, the associated comments with TODOs have also been removed, for consistency with the new process. This also opportunistically removes `deprecated_member_use_from_same_package` everywhere, since that has been disabled for a long time, so they were cruft.

I have ensured that issues are filed for all of these usages, with the new `p: deprecated api` tag, per the new process for tracking deprecated APIs that is now described in the Ecosystem gardener rotation handbook. (In summary: there will be a manual weekly process of checking for new deprecations and filing them, and the [update-stable-in-this-repo process](https://github.com/flutter/flutter/wiki/Updating-Packages-repo-for-a-stable-release) will involve causing anything that is unblocked to be re-triaged.)

The only annotations that are left are for cases where we have integration tests testing deprecated APIs in that package, as those are false positives; they are conceptually `deprecated_member_use_from_same_package` and aren't tech debt (or used by clients), but technically are from a different package since integration tests are in the example app. This will prevent them from showing up in the manual weekly check.
This commit is contained in:
stuartmorgan
2024-02-14 09:33:03 -08:00
committed by GitHub
parent 3c5687cc12
commit de9654f06b
25 changed files with 20 additions and 82 deletions

View File

@ -14,9 +14,6 @@ void main() {
(WidgetTester tester) async { (WidgetTester tester) async {
MediaQuery slot(double width) { MediaQuery slot(double width) {
return MediaQuery( return MediaQuery(
// TODO(stuartmorgan): Replace with .fromView once this package requires
// Flutter 3.8+.
// ignore: deprecated_member_use
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window) data: MediaQueryData.fromWindow(WidgetsBinding.instance.window)
.copyWith(size: Size(width, 800)), .copyWith(size: Size(width, 800)),
child: Directionality( child: Directionality(
@ -420,9 +417,6 @@ AnimatedWidget leftInOut(Widget child, Animation<double> animation) {
MediaQuery slot(double width) { MediaQuery slot(double width) {
return MediaQuery( return MediaQuery(
// TODO(stuartmorgan): Replace with .fromView once this package requires
// Flutter 3.8+.
// ignore: deprecated_member_use
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window) data: MediaQueryData.fromWindow(WidgetsBinding.instance.window)
.copyWith(size: Size(width, 800)), .copyWith(size: Size(width, 800)),
child: Directionality( child: Directionality(

View File

@ -151,9 +151,6 @@ enum SimulatedLayout {
MediaQuery get slot { MediaQuery get slot {
return MediaQuery( return MediaQuery(
// TODO(stuartmorgan): Replace with .fromView once this package requires
// Flutter 3.8+.
// ignore: deprecated_member_use
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window) data: MediaQueryData.fromWindow(WidgetsBinding.instance.window)
.copyWith(size: Size(_width, _height)), .copyWith(size: Size(_width, _height)),
child: Theme( child: Theme(

View File

@ -101,9 +101,6 @@ class NetworkImageWithRetry extends ImageProvider<NetworkImageWithRetry> {
@override @override
ImageStreamCompleter loadBuffer( ImageStreamCompleter loadBuffer(
NetworkImageWithRetry key, NetworkImageWithRetry key,
// TODO(LongCatIsLooong): migrate to use new `loadImage` API.
// https://github.com/flutter/flutter/issues/132856
// ignore: deprecated_member_use
DecoderBufferCallback decode, DecoderBufferCallback decode,
) { ) {
return OneFrameImageStreamCompleter(_loadWithRetry(key, decode), return OneFrameImageStreamCompleter(_loadWithRetry(key, decode),

View File

@ -142,9 +142,6 @@ void assertThatImageLoadingFails(
) { ) {
final ImageStreamCompleter completer = subject.loadBuffer( final ImageStreamCompleter completer = subject.loadBuffer(
subject, subject,
// TODO(LongCatIsLooong): migrate to use new `instantiateImageCodecWithSize` API.
// https://github.com/flutter/flutter/issues/132856
// ignore: deprecated_member_use
PaintingBinding.instance.instantiateImageCodecFromBuffer, PaintingBinding.instance.instantiateImageCodecFromBuffer,
); );
completer.addListener(ImageStreamListener( completer.addListener(ImageStreamListener(
@ -162,9 +159,6 @@ void assertThatImageLoadingSucceeds(
) { ) {
final ImageStreamCompleter completer = subject.loadBuffer( final ImageStreamCompleter completer = subject.loadBuffer(
subject, subject,
// TODO(LongCatIsLooong): migrate to use new `instantiateImageCodecWithSize` API.
// https://github.com/flutter/flutter/issues/132856
// ignore: deprecated_member_use
PaintingBinding.instance.instantiateImageCodecFromBuffer, PaintingBinding.instance.instantiateImageCodecFromBuffer,
); );
completer.addListener(ImageStreamListener( completer.addListener(ImageStreamListener(

View File

@ -64,8 +64,7 @@ final MarkdownStyleSheet Function(BuildContext, MarkdownStyleSheetBaseTheme?)
} }
return result.copyWith( return result.copyWith(
textScaleFactor: textScaleFactor: MediaQuery.textScaleFactorOf(context),
MediaQuery.textScaleFactorOf(context), // ignore: deprecated_member_use
); );
}; };

View File

@ -66,8 +66,7 @@ final MarkdownStyleSheet Function(BuildContext, MarkdownStyleSheetBaseTheme?)
} }
return result.copyWith( return result.copyWith(
textScaleFactor: textScaleFactor: MediaQuery.textScaleFactorOf(context),
MediaQuery.textScaleFactorOf(context), // ignore: deprecated_member_use
); );
}; };

View File

@ -867,7 +867,6 @@ class MarkdownBuilder implements md.NodeVisitor {
if (selectable) { if (selectable) {
return SelectableText.rich( return SelectableText.rich(
text!, text!,
// ignore: deprecated_member_use
textScaleFactor: styleSheet.textScaleFactor, textScaleFactor: styleSheet.textScaleFactor,
textAlign: textAlign ?? TextAlign.start, textAlign: textAlign ?? TextAlign.start,
onTap: onTapText, onTap: onTapText,
@ -876,7 +875,6 @@ class MarkdownBuilder implements md.NodeVisitor {
} else { } else {
return Text.rich( return Text.rich(
text!, text!,
// ignore: deprecated_member_use
textScaleFactor: styleSheet.textScaleFactor, textScaleFactor: styleSheet.textScaleFactor,
textAlign: textAlign ?? TextAlign.start, textAlign: textAlign ?? TextAlign.start,
key: k, key: k,

View File

@ -25,7 +25,7 @@ void defineTests() {
); );
final RichText richText = tester.widget(find.byType(RichText)); final RichText richText = tester.widget(find.byType(RichText));
expect(richText.textScaleFactor, 2.0); // ignore: deprecated_member_use expect(richText.textScaleFactor, 2.0);
}, },
); );
@ -36,7 +36,6 @@ void defineTests() {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
const MediaQuery( const MediaQuery(
// ignore: deprecated_member_use
data: MediaQueryData(textScaleFactor: 2.0), data: MediaQueryData(textScaleFactor: 2.0),
child: MarkdownBody( child: MarkdownBody(
data: data, data: data,
@ -46,7 +45,7 @@ void defineTests() {
); );
final RichText richText = tester.widget(find.byType(RichText)); final RichText richText = tester.widget(find.byType(RichText));
expect(richText.textScaleFactor, 2.0); // ignore: deprecated_member_use expect(richText.textScaleFactor, 2.0);
}, },
); );
@ -57,7 +56,6 @@ void defineTests() {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
const MediaQuery( const MediaQuery(
// ignore: deprecated_member_use
data: MediaQueryData(textScaleFactor: 2.0), data: MediaQueryData(textScaleFactor: 2.0),
child: MarkdownBody( child: MarkdownBody(
data: data, data: data,
@ -69,7 +67,6 @@ void defineTests() {
final SelectableText selectableText = final SelectableText selectableText =
tester.widget(find.byType(SelectableText)); tester.widget(find.byType(SelectableText));
// ignore: deprecated_member_use
expect(selectableText.textScaleFactor, 2.0); expect(selectableText.textScaleFactor, 2.0);
}, },
); );

View File

@ -169,8 +169,6 @@ void expectLinkTap(MarkdownLink? actual, MarkdownLink expected) {
} }
String dumpRenderView() { String dumpRenderView() {
// TODO(goderbauer): Migrate to rootElement once v3.9.0 is the oldest supported Flutter version.
// ignore: deprecated_member_use
return WidgetsBinding.instance.renderViewElement!.toStringDeep().replaceAll( return WidgetsBinding.instance.renderViewElement!.toStringDeep().replaceAll(
RegExp(r'SliverChildListDelegate#\d+', multiLine: true), RegExp(r'SliverChildListDelegate#\d+', multiLine: true),
'SliverChildListDelegate', 'SliverChildListDelegate',

View File

@ -150,7 +150,6 @@ Future<T> asyncGuard<T>(
// ignore: avoid_catches_without_on_clauses, forwards to Future // ignore: avoid_catches_without_on_clauses, forwards to Future
handleError(e, s); handleError(e, s);
} }
// ignore: deprecated_member_use
}, onError: (Object e, StackTrace s) { }, onError: (Object e, StackTrace s) {
handleError(e, s); handleError(e, s);
}); });

View File

@ -10,18 +10,12 @@ import 'package:flutter_migrate/src/base/file_system.dart';
import 'package:flutter_migrate/src/base/io.dart'; import 'package:flutter_migrate/src/base/io.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:path/path.dart' as path; // flutter_ignore: package_path_import import 'package:path/path.dart' as path; // flutter_ignore: package_path_import
import 'package:test_api/test_api.dart' // ignore: deprecated_member_use import 'package:test_api/test_api.dart' as test_package show test;
as test_package show test; import 'package:test_api/test_api.dart' hide test;
import 'package:test_api/test_api.dart' // ignore: deprecated_member_use
hide
test;
import 'test_utils.dart'; import 'test_utils.dart';
export 'package:test_api/test_api.dart' // ignore: deprecated_member_use export 'package:test_api/test_api.dart' hide isInstanceOf, test;
hide
isInstanceOf,
test;
bool tryToDelete(FileSystemEntity fileEntity) { bool tryToDelete(FileSystemEntity fileEntity) {
// This should not be necessary, but it turns out that // This should not be necessary, but it turns out that

View File

@ -5,10 +5,7 @@
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:flutter_migrate/src/base/command.dart'; import 'package:flutter_migrate/src/base/command.dart';
export 'package:test_api/test_api.dart' // ignore: deprecated_member_use export 'package:test_api/test_api.dart' hide isInstanceOf, test;
hide
isInstanceOf,
test;
CommandRunner<void> createTestCommandRunner([MigrateCommand? command]) { CommandRunner<void> createTestCommandRunner([MigrateCommand? command]) {
final CommandRunner<void> runner = TestCommandRunner(); final CommandRunner<void> runner = TestCommandRunner();

View File

@ -1,3 +1,7 @@
## NEXT
* Updates dependencies to require `analyzer` 5.2.0 or later.
## 2.4.1 ## 2.4.1
* Fixes new lint warnings. * Fixes new lint warnings.

View File

@ -447,9 +447,6 @@ abstract class RouteBaseConfig {
) { ) {
assert(!reader.isNull, 'reader should not be null'); assert(!reader.isNull, 'reader should not be null');
final InterfaceType type = reader.objectValue.type! as InterfaceType; final InterfaceType type = reader.objectValue.type! as InterfaceType;
// TODO(stuartmorgan): Remove this ignore once 'analyze' can be set to
// 5.2+ (when Flutter 3.4+ is on stable).
// ignore: deprecated_member_use
final String typeName = type.element.name; final String typeName = type.element.name;
final DartType typeParamType = type.typeArguments.single; final DartType typeParamType = type.typeArguments.single;
if (typeParamType is! InterfaceType) { if (typeParamType is! InterfaceType) {
@ -461,9 +458,6 @@ abstract class RouteBaseConfig {
} }
// TODO(kevmoo): validate that this MUST be a subtype of `GoRouteData` // TODO(kevmoo): validate that this MUST be a subtype of `GoRouteData`
// TODO(stuartmorgan): Remove this ignore once 'analyze' can be set to
// 5.2+ (when Flutter 3.4+ is on stable).
// ignore: deprecated_member_use
final InterfaceElement classElement = typeParamType.element; final InterfaceElement classElement = typeParamType.element;
final RouteBaseConfig value; final RouteBaseConfig value;
@ -701,16 +695,10 @@ $routeDataClassName.$dataConvertionFunctionName(
String _enumMapConst(InterfaceType type) { String _enumMapConst(InterfaceType type) {
assert(type.isEnum); assert(type.isEnum);
// TODO(stuartmorgan): Remove this ignore once 'analyze' can be set to
// 5.2+ (when Flutter 3.4+ is on stable).
// ignore: deprecated_member_use
final String enumName = type.element.name; final String enumName = type.element.name;
final StringBuffer buffer = StringBuffer('const ${enumMapName(type)} = {'); final StringBuffer buffer = StringBuffer('const ${enumMapName(type)} = {');
// TODO(stuartmorgan): Remove this ignore once 'analyze' can be set to
// 5.2+ (when Flutter 3.4+ is on stable).
// ignore: deprecated_member_use
for (final FieldElement enumField in type.element.fields for (final FieldElement enumField in type.element.fields
.where((FieldElement element) => element.isEnumConstant)) { .where((FieldElement element) => element.isEnumConstant)) {
buffer.writeln( buffer.writeln(

View File

@ -87,9 +87,6 @@ String encodeField(PropertyAccessorElement element) {
} }
/// Gets the name of the `const` map generated to help encode [Enum] types. /// Gets the name of the `const` map generated to help encode [Enum] types.
// TODO(stuartmorgan): Remove this ignore once 'analyze' can be set to
// 5.2+ (when Flutter 3.4+ is on stable).
// ignore: deprecated_member_use
String enumMapName(InterfaceType type) => '_\$${type.element.name}EnumMap'; String enumMapName(InterfaceType type) => '_\$${type.element.name}EnumMap';
String _stateValueAccess(ParameterElement element, Set<String> pathParameters) { String _stateValueAccess(ParameterElement element, Set<String> pathParameters) {

View File

@ -10,7 +10,7 @@ environment:
sdk: ">=3.0.0 <4.0.0" sdk: ">=3.0.0 <4.0.0"
dependencies: dependencies:
analyzer: ">=4.4.0 <7.0.0" analyzer: ">=5.2.0 <7.0.0"
async: ^2.8.0 async: ^2.8.0
build: ^2.0.0 build: ^2.0.0
build_config: ^1.0.0 build_config: ^1.0.0

View File

@ -17,7 +17,6 @@ void main() {
final Object json = descriptor.toJson(); final Object json = descriptor.toJson();
// Rehydrate a new bitmap descriptor... // Rehydrate a new bitmap descriptor...
// ignore: deprecated_member_use_from_same_package
final BitmapDescriptor descriptorFromJson = final BitmapDescriptor descriptorFromJson =
BitmapDescriptor.fromJson(json); BitmapDescriptor.fromJson(json);

View File

@ -27,8 +27,6 @@ class PickedFile extends PickedFileBase {
Future<Uint8List> get _bytes async { Future<Uint8List> get _bytes async {
if (_initBytes != null) { if (_initBytes != null) {
// TODO(stuartmorgan): Remove this directive, https://github.com/flutter/flutter/issues/143113
// ignore: deprecated_member_use
return Future<Uint8List>.value(UnmodifiableUint8ListView(_initBytes!)); return Future<Uint8List>.value(UnmodifiableUint8ListView(_initBytes!));
} }
return http.readBytes(Uri.parse(path)); return http.readBytes(Uri.parse(path));

View File

@ -71,7 +71,7 @@ class _FutureMemoryImage extends ImageProvider<_FutureMemoryImage> {
@override @override
ImageStreamCompleter loadBuffer( ImageStreamCompleter loadBuffer(
_FutureMemoryImage key, _FutureMemoryImage key,
DecoderBufferCallback decode, // ignore: deprecated_member_use DecoderBufferCallback decode,
) { ) {
return _FutureImageStreamCompleter( return _FutureImageStreamCompleter(
codec: _loadAsync(key, decode), codec: _loadAsync(key, decode),
@ -81,7 +81,7 @@ class _FutureMemoryImage extends ImageProvider<_FutureMemoryImage> {
Future<ui.Codec> _loadAsync( Future<ui.Codec> _loadAsync(
_FutureMemoryImage key, _FutureMemoryImage key,
DecoderBufferCallback decode, // ignore: deprecated_member_use DecoderBufferCallback decode,
) { ) {
assert(key == this); assert(key == this);
return _futureBytes.then(ui.ImmutableBuffer.fromUint8List).then(decode); return _futureBytes.then(ui.ImmutableBuffer.fromUint8List).then(decode);

View File

@ -658,7 +658,7 @@ Map<String, LocalWidgetBuilder> get _coreWidgetsDefinitions => <String, LocalWid
locale: ArgumentDecoders.locale(source, ['locale']), locale: ArgumentDecoders.locale(source, ['locale']),
softWrap: source.v<bool>(['softWrap']), softWrap: source.v<bool>(['softWrap']),
overflow: ArgumentDecoders.enumValue<TextOverflow>(TextOverflow.values, source, ['overflow']), overflow: ArgumentDecoders.enumValue<TextOverflow>(TextOverflow.values, source, ['overflow']),
textScaleFactor: source.v<double>(['textScaleFactor']), // ignore: deprecated_member_use textScaleFactor: source.v<double>(['textScaleFactor']),
maxLines: source.v<int>(['maxLines']), maxLines: source.v<int>(['maxLines']),
semanticsLabel: source.v<String>(['semanticsLabel']), semanticsLabel: source.v<String>(['semanticsLabel']),
textWidthBasis: ArgumentDecoders.enumValue<TextWidthBasis>(TextWidthBasis.values, source, ['textWidthBasis']), textWidthBasis: ArgumentDecoders.enumValue<TextWidthBasis>(TextWidthBasis.values, source, ['textWidthBasis']),

View File

@ -238,9 +238,7 @@ void main() {
_anonymize(TestWidgetsFlutterBinding.ensureInitialized())! _anonymize(TestWidgetsFlutterBinding.ensureInitialized())!
as TestWidgetsFlutterBinding; as TestWidgetsFlutterBinding;
debugDefaultTargetPlatformOverride = TargetPlatform.iOS; debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
// TODO(goderbauer): Migrate to binding.renderViews when that is available in the oldest supported stable. final RenderView renderView = binding.renderView;
final RenderView renderView =
binding.renderView; // ignore: deprecated_member_use
renderView.automaticSystemUiAdjustment = true; renderView.automaticSystemUiAdjustment = true;
final Future<bool> launchResult = final Future<bool> launchResult =
launch('http://flutter.dev/', statusBarBrightness: Brightness.dark); launch('http://flutter.dev/', statusBarBrightness: Brightness.dark);
@ -270,9 +268,7 @@ void main() {
_anonymize(TestWidgetsFlutterBinding.ensureInitialized())! _anonymize(TestWidgetsFlutterBinding.ensureInitialized())!
as TestWidgetsFlutterBinding; as TestWidgetsFlutterBinding;
debugDefaultTargetPlatformOverride = TargetPlatform.android; debugDefaultTargetPlatformOverride = TargetPlatform.android;
// TODO(goderbauer): Migrate to binding.renderViews when that is available in the oldest supported stable. final RenderView renderView = binding.renderView;
final RenderView renderView =
binding.renderView; // ignore: deprecated_member_use
expect(renderView.automaticSystemUiAdjustment, true); expect(renderView.automaticSystemUiAdjustment, true);
final Future<bool> launchResult = final Future<bool> launchResult =
launch('http://flutter.dev/', statusBarBrightness: Brightness.dark); launch('http://flutter.dev/', statusBarBrightness: Brightness.dark);

View File

@ -86,9 +86,6 @@ abstract class LinkInfo {
// TODO(ianh): Remove the first argument. // TODO(ianh): Remove the first argument.
Future<ByteData> pushRouteNameToFramework(Object? _, String routeName) { Future<ByteData> pushRouteNameToFramework(Object? _, String routeName) {
final Completer<ByteData> completer = Completer<ByteData>(); final Completer<ByteData> completer = Completer<ByteData>();
// TODO(chunhtai): remove this ignore and migrate the code
// https://github.com/flutter/flutter/issues/124045.
// ignore: deprecated_member_use
SystemNavigator.routeInformationUpdated(location: routeName); SystemNavigator.routeInformationUpdated(location: routeName);
ui.channelBuffers.push( ui.channelBuffers.push(
'flutter/navigation', 'flutter/navigation',

View File

@ -83,9 +83,7 @@ class _RouteDelegate extends RouterDelegate<RouteInformation>
if (_history.isEmpty) { if (_history.isEmpty) {
return const Placeholder(key: Key('empty')); return const Placeholder(key: Key('empty'));
} }
// TODO(chunhtai): remove this ignore and migrate the code // ignore: unnecessary_string_interpolations
// https://github.com/flutter/flutter/issues/124045.
// ignore: unnecessary_string_interpolations, deprecated_member_use
return Placeholder(key: Key('${_history.last.location}')); return Placeholder(key: Key('${_history.last.location}'));
} }
} }

View File

@ -255,8 +255,7 @@ abstract class SceneBuilderRecorder extends Recorder {
_profile.record('sceneBuildDuration', () { _profile.record('sceneBuildDuration', () {
final Scene scene = sceneBuilder.build(); final Scene scene = sceneBuilder.build();
_profile.record('windowRenderDuration', () { _profile.record('windowRenderDuration', () {
// TODO(goderbauer): Migrate to PlatformDispatcher.implicitView once v3.9.0 is the oldest supported Flutter version. window.render(scene);
window.render(scene); // ignore: deprecated_member_use
}, reported: false); }, reported: false);
}, reported: false); }, reported: false);
}, reported: true); }, reported: true);

View File

@ -720,7 +720,6 @@ class WebViewClientFlutterApiImpl extends WebViewClientFlutterApi {
webViewInstance != null, webViewInstance != null,
'InstanceManager does not contain a WebView with instanceId: $webViewInstanceId', 'InstanceManager does not contain a WebView with instanceId: $webViewInstanceId',
); );
// ignore: deprecated_member_use_from_same_package
if (instance!.onReceivedError != null) { if (instance!.onReceivedError != null) {
instance.onReceivedError!( instance.onReceivedError!(
webViewInstance!, webViewInstance!,