Skip to content

[various] Clean up deprecated_member_use ignores #6123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ void main() {
(WidgetTester tester) async {
MediaQuery slot(double width) {
return MediaQuery(
// TODO(stuartmorgan): Replace with .fromView once this package requires
// Flutter 3.8+.
// ignore: deprecated_member_use
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window)
.copyWith(size: Size(width, 800)),
child: Directionality(
Expand Down Expand Up @@ -420,9 +417,6 @@ AnimatedWidget leftInOut(Widget child, Animation<double> animation) {

MediaQuery slot(double width) {
return MediaQuery(
// TODO(stuartmorgan): Replace with .fromView once this package requires
// Flutter 3.8+.
// ignore: deprecated_member_use
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window)
.copyWith(size: Size(width, 800)),
child: Directionality(
Expand Down
3 changes: 0 additions & 3 deletions packages/flutter_adaptive_scaffold/test/simulated_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ enum SimulatedLayout {

MediaQuery get slot {
return MediaQuery(
// TODO(stuartmorgan): Replace with .fromView once this package requires
// Flutter 3.8+.
// ignore: deprecated_member_use
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window)
.copyWith(size: Size(_width, _height)),
child: Theme(
Expand Down
3 changes: 0 additions & 3 deletions packages/flutter_image/lib/network.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ class NetworkImageWithRetry extends ImageProvider<NetworkImageWithRetry> {
@override
ImageStreamCompleter loadBuffer(
NetworkImageWithRetry key,
// TODO(LongCatIsLooong): migrate to use new `loadImage` API.
// https://github.com/flutter/flutter/issues/132856
// ignore: deprecated_member_use
DecoderBufferCallback decode,
) {
return OneFrameImageStreamCompleter(_loadWithRetry(key, decode),
Expand Down
6 changes: 0 additions & 6 deletions packages/flutter_image/test/network_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ void assertThatImageLoadingFails(
) {
final ImageStreamCompleter completer = subject.loadBuffer(
subject,
// TODO(LongCatIsLooong): migrate to use new `instantiateImageCodecWithSize` API.
// https://github.com/flutter/flutter/issues/132856
// ignore: deprecated_member_use
PaintingBinding.instance.instantiateImageCodecFromBuffer,
);
completer.addListener(ImageStreamListener(
Expand All @@ -162,9 +159,6 @@ void assertThatImageLoadingSucceeds(
) {
final ImageStreamCompleter completer = subject.loadBuffer(
subject,
// TODO(LongCatIsLooong): migrate to use new `instantiateImageCodecWithSize` API.
// https://github.com/flutter/flutter/issues/132856
// ignore: deprecated_member_use
PaintingBinding.instance.instantiateImageCodecFromBuffer,
);
completer.addListener(ImageStreamListener(
Expand Down
3 changes: 1 addition & 2 deletions packages/flutter_markdown/lib/src/_functions_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ final MarkdownStyleSheet Function(BuildContext, MarkdownStyleSheetBaseTheme?)
}

return result.copyWith(
textScaleFactor:
MediaQuery.textScaleFactorOf(context), // ignore: deprecated_member_use
textScaleFactor: MediaQuery.textScaleFactorOf(context),
);
};

Expand Down
3 changes: 1 addition & 2 deletions packages/flutter_markdown/lib/src/_functions_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ final MarkdownStyleSheet Function(BuildContext, MarkdownStyleSheetBaseTheme?)
}

return result.copyWith(
textScaleFactor:
MediaQuery.textScaleFactorOf(context), // ignore: deprecated_member_use
textScaleFactor: MediaQuery.textScaleFactorOf(context),
);
};

Expand Down
2 changes: 0 additions & 2 deletions packages/flutter_markdown/lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,6 @@ class MarkdownBuilder implements md.NodeVisitor {
if (selectable) {
return SelectableText.rich(
text!,
// ignore: deprecated_member_use
textScaleFactor: styleSheet.textScaleFactor,
textAlign: textAlign ?? TextAlign.start,
onTap: onTapText,
Expand All @@ -876,7 +875,6 @@ class MarkdownBuilder implements md.NodeVisitor {
} else {
return Text.rich(
text!,
// ignore: deprecated_member_use
textScaleFactor: styleSheet.textScaleFactor,
textAlign: textAlign ?? TextAlign.start,
key: k,
Expand Down
7 changes: 2 additions & 5 deletions packages/flutter_markdown/test/text_scale_factor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void defineTests() {
);

final RichText richText = tester.widget(find.byType(RichText));
expect(richText.textScaleFactor, 2.0); // ignore: deprecated_member_use
expect(richText.textScaleFactor, 2.0);
},
);

Expand All @@ -36,7 +36,6 @@ void defineTests() {
await tester.pumpWidget(
boilerplate(
const MediaQuery(
// ignore: deprecated_member_use
data: MediaQueryData(textScaleFactor: 2.0),
child: MarkdownBody(
data: data,
Expand All @@ -46,7 +45,7 @@ void defineTests() {
);

final RichText richText = tester.widget(find.byType(RichText));
expect(richText.textScaleFactor, 2.0); // ignore: deprecated_member_use
expect(richText.textScaleFactor, 2.0);
},
);

Expand All @@ -57,7 +56,6 @@ void defineTests() {
await tester.pumpWidget(
boilerplate(
const MediaQuery(
// ignore: deprecated_member_use
data: MediaQueryData(textScaleFactor: 2.0),
child: MarkdownBody(
data: data,
Expand All @@ -69,7 +67,6 @@ void defineTests() {

final SelectableText selectableText =
tester.widget(find.byType(SelectableText));
// ignore: deprecated_member_use
expect(selectableText.textScaleFactor, 2.0);
},
);
Expand Down
2 changes: 0 additions & 2 deletions packages/flutter_markdown/test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ void expectLinkTap(MarkdownLink? actual, MarkdownLink expected) {
}

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(
RegExp(r'SliverChildListDelegate#\d+', multiLine: true),
'SliverChildListDelegate',
Expand Down
1 change: 0 additions & 1 deletion packages/flutter_migrate/lib/src/base/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ Future<T> asyncGuard<T>(
// ignore: avoid_catches_without_on_clauses, forwards to Future
handleError(e, s);
}
// ignore: deprecated_member_use
}, onError: (Object e, StackTrace s) {
handleError(e, s);
});
Expand Down
12 changes: 3 additions & 9 deletions packages/flutter_migrate/test/src/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@ import 'package:flutter_migrate/src/base/file_system.dart';
import 'package:flutter_migrate/src/base/io.dart';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path; // flutter_ignore: package_path_import
import 'package:test_api/test_api.dart' // ignore: deprecated_member_use
as test_package show test;
import 'package:test_api/test_api.dart' // ignore: deprecated_member_use
hide
test;
import 'package:test_api/test_api.dart' as test_package show test;
import 'package:test_api/test_api.dart' hide test;

import 'test_utils.dart';

export 'package:test_api/test_api.dart' // ignore: deprecated_member_use
hide
isInstanceOf,
test;
export 'package:test_api/test_api.dart' hide isInstanceOf, test;

bool tryToDelete(FileSystemEntity fileEntity) {
// This should not be necessary, but it turns out that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import 'package:args/command_runner.dart';
import 'package:flutter_migrate/src/base/command.dart';

export 'package:test_api/test_api.dart' // ignore: deprecated_member_use
hide
isInstanceOf,
test;
export 'package:test_api/test_api.dart' hide isInstanceOf, test;

CommandRunner<void> createTestCommandRunner([MigrateCommand? command]) {
final CommandRunner<void> runner = TestCommandRunner();
Expand Down
4 changes: 4 additions & 0 deletions packages/go_router_builder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## NEXT

* Updates dependencies to require `analyzer` 5.2.0 or later.

## 2.4.1

* Fixes new lint warnings.
Expand Down
12 changes: 0 additions & 12 deletions packages/go_router_builder/lib/src/route_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,6 @@ abstract class RouteBaseConfig {
) {
assert(!reader.isNull, 'reader should not be null');
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 DartType typeParamType = type.typeArguments.single;
if (typeParamType is! InterfaceType) {
Expand All @@ -461,9 +458,6 @@ abstract class RouteBaseConfig {
}

// 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 RouteBaseConfig value;
Expand Down Expand Up @@ -701,16 +695,10 @@ $routeDataClassName.$dataConvertionFunctionName(
String _enumMapConst(InterfaceType type) {
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 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
.where((FieldElement element) => element.isEnumConstant)) {
buffer.writeln(
Expand Down
3 changes: 0 additions & 3 deletions packages/go_router_builder/lib/src/type_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ String encodeField(PropertyAccessorElement element) {
}

/// 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 _stateValueAccess(ParameterElement element, Set<String> pathParameters) {
Expand Down
2 changes: 1 addition & 1 deletion packages/go_router_builder/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
sdk: ">=3.0.0 <4.0.0"

dependencies:
analyzer: ">=4.4.0 <7.0.0"
analyzer: ">=5.2.0 <7.0.0"
async: ^2.8.0
build: ^2.0.0
build_config: ^1.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ void main() {
final Object json = descriptor.toJson();

// Rehydrate a new bitmap descriptor...
// ignore: deprecated_member_use_from_same_package
final BitmapDescriptor descriptorFromJson =
BitmapDescriptor.fromJson(json);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class PickedFile extends PickedFileBase {

Future<Uint8List> get _bytes async {
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 http.readBytes(Uri.parse(path));
Expand Down
4 changes: 2 additions & 2 deletions packages/ios_platform_images/lib/ios_platform_images.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class _FutureMemoryImage extends ImageProvider<_FutureMemoryImage> {
@override
ImageStreamCompleter loadBuffer(
_FutureMemoryImage key,
DecoderBufferCallback decode, // ignore: deprecated_member_use
DecoderBufferCallback decode,
) {
return _FutureImageStreamCompleter(
codec: _loadAsync(key, decode),
Expand All @@ -81,7 +81,7 @@ class _FutureMemoryImage extends ImageProvider<_FutureMemoryImage> {

Future<ui.Codec> _loadAsync(
_FutureMemoryImage key,
DecoderBufferCallback decode, // ignore: deprecated_member_use
DecoderBufferCallback decode,
) {
assert(key == this);
return _futureBytes.then(ui.ImmutableBuffer.fromUint8List).then(decode);
Expand Down
2 changes: 1 addition & 1 deletion packages/rfw/lib/src/flutter/core_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ Map<String, LocalWidgetBuilder> get _coreWidgetsDefinitions => <String, LocalWid
locale: ArgumentDecoders.locale(source, ['locale']),
softWrap: source.v<bool>(['softWrap']),
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']),
semanticsLabel: source.v<String>(['semanticsLabel']),
textWidthBasis: ArgumentDecoders.enumValue<TextWidthBasis>(TextWidthBasis.values, source, ['textWidthBasis']),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,7 @@ void main() {
_anonymize(TestWidgetsFlutterBinding.ensureInitialized())!
as TestWidgetsFlutterBinding;
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
// TODO(goderbauer): Migrate to binding.renderViews when that is available in the oldest supported stable.
final RenderView renderView =
binding.renderView; // ignore: deprecated_member_use
final RenderView renderView = binding.renderView;
renderView.automaticSystemUiAdjustment = true;
final Future<bool> launchResult =
launch('http://flutter.dev/', statusBarBrightness: Brightness.dark);
Expand Down Expand Up @@ -270,9 +268,7 @@ void main() {
_anonymize(TestWidgetsFlutterBinding.ensureInitialized())!
as TestWidgetsFlutterBinding;
debugDefaultTargetPlatformOverride = TargetPlatform.android;
// TODO(goderbauer): Migrate to binding.renderViews when that is available in the oldest supported stable.
final RenderView renderView =
binding.renderView; // ignore: deprecated_member_use
final RenderView renderView = binding.renderView;
expect(renderView.automaticSystemUiAdjustment, true);
final Future<bool> launchResult =
launch('http://flutter.dev/', statusBarBrightness: Brightness.dark);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ abstract class LinkInfo {
// TODO(ianh): Remove the first argument.
Future<ByteData> pushRouteNameToFramework(Object? _, String routeName) {
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);
ui.channelBuffers.push(
'flutter/navigation',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ class _RouteDelegate extends RouterDelegate<RouteInformation>
if (_history.isEmpty) {
return const Placeholder(key: Key('empty'));
}
// TODO(chunhtai): remove this ignore and migrate the code
// https://github.com/flutter/flutter/issues/124045.
// ignore: unnecessary_string_interpolations, deprecated_member_use
// ignore: unnecessary_string_interpolations
return Placeholder(key: Key('${_history.last.location}'));
}
}
3 changes: 1 addition & 2 deletions packages/web_benchmarks/lib/src/recorder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ abstract class SceneBuilderRecorder extends Recorder {
_profile.record('sceneBuildDuration', () {
final Scene scene = sceneBuilder.build();
_profile.record('windowRenderDuration', () {
// TODO(goderbauer): Migrate to PlatformDispatcher.implicitView once v3.9.0 is the oldest supported Flutter version.
window.render(scene); // ignore: deprecated_member_use
window.render(scene);
}, reported: false);
}, reported: false);
}, reported: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,6 @@ class WebViewClientFlutterApiImpl extends WebViewClientFlutterApi {
webViewInstance != null,
'InstanceManager does not contain a WebView with instanceId: $webViewInstanceId',
);
// ignore: deprecated_member_use_from_same_package
if (instance!.onReceivedError != null) {
instance.onReceivedError!(
webViewInstance!,
Expand Down