Enable unreachable_from_main lint - it is stable now!!1 (#129854)

PLUS: clean-up of all the unreachable stuff.
This commit is contained in:
Michael Goderbauer 2023-07-05 17:09:01 -07:00 committed by GitHub
parent 99cb18b1a8
commit 55b6f049a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 66 additions and 419 deletions

View File

@ -223,7 +223,7 @@ linter:
- unnecessary_string_interpolations - unnecessary_string_interpolations
- unnecessary_this - unnecessary_this
- unnecessary_to_list_in_spreads - unnecessary_to_list_in_spreads
# - unreachable_from_main # Do not enable this rule until it is un-marked as "experimental" and carefully re-evaluated. - unreachable_from_main
- unrelated_type_equality_checks - unrelated_type_equality_checks
- unsafe_html - unsafe_html
- use_build_context_synchronously - use_build_context_synchronously

View File

@ -12,9 +12,10 @@ const int _kNumWarmUp = 100;
class Data { class Data {
Data(this.value); Data(this.value);
Map<String, dynamic> toJson() => <String, dynamic>{ 'value': value };
final int value; final int value;
@override
String toString() => 'Data($value)';
} }
List<Data> test(int length) { List<Data> test(int length) {

View File

@ -5,7 +5,6 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show timeDilation;
void main() { void main() {
runApp( runApp(
@ -31,12 +30,6 @@ class PlatformViewAppState extends State<PlatformViewApp> {
home: const PlatformViewLayout(), home: const PlatformViewLayout(),
); );
} }
void toggleAnimationSpeed() {
setState(() {
timeDilation = (timeDilation != 1.0) ? 1.0 : 5.0;
});
}
} }
class PlatformViewLayout extends StatelessWidget { class PlatformViewLayout extends StatelessWidget {

View File

@ -5,7 +5,6 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show timeDilation;
void main() { void main() {
runApp( runApp(
@ -31,12 +30,6 @@ class PlatformViewAppState extends State<PlatformViewApp> {
home: const PlatformViewLayout(), home: const PlatformViewLayout(),
); );
} }
void toggleAnimationSpeed() {
setState(() {
timeDilation = (timeDilation != 1.0) ? 1.0 : 5.0;
});
}
} }
class PlatformViewLayout extends StatelessWidget { class PlatformViewLayout extends StatelessWidget {

View File

@ -5,7 +5,6 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show timeDilation;
import 'package:flutter_driver/driver_extension.dart'; import 'package:flutter_driver/driver_extension.dart';
import 'android_platform_view.dart'; import 'android_platform_view.dart';
@ -35,12 +34,6 @@ class PlatformViewAppState extends State<PlatformViewApp> {
home: const PlatformViewLayout(), home: const PlatformViewLayout(),
); );
} }
void toggleAnimationSpeed() {
setState(() {
timeDilation = (timeDilation != 1.0) ? 1.0 : 5.0;
});
}
} }
class PlatformViewLayout extends StatelessWidget { class PlatformViewLayout extends StatelessWidget {

View File

@ -46,11 +46,6 @@ void main() {
/// It keeps a list of history entries and event listeners in memory and /// It keeps a list of history entries and event listeners in memory and
/// manipulates them in order to achieve the desired functionality. /// manipulates them in order to achieve the desired functionality.
class TestUrlStrategy extends UrlStrategy { class TestUrlStrategy extends UrlStrategy {
/// Creates a instance of [TestUrlStrategy] with an empty string as the
/// path.
factory TestUrlStrategy() =>
TestUrlStrategy.fromEntry(const TestHistoryEntry(null, null, ''));
/// Creates an instance of [TestUrlStrategy] and populates it with a list /// Creates an instance of [TestUrlStrategy] and populates it with a list
/// that has [initialEntry] as the only item. /// that has [initialEntry] as the only item.
TestUrlStrategy.fromEntry(TestHistoryEntry initialEntry) TestUrlStrategy.fromEntry(TestHistoryEntry initialEntry)
@ -64,8 +59,6 @@ class TestUrlStrategy extends UrlStrategy {
dynamic getState() => currentEntry.state; dynamic getState() => currentEntry.state;
int _currentEntryIndex; int _currentEntryIndex;
int get currentEntryIndex => _currentEntryIndex;
final List<TestHistoryEntry> history; final List<TestHistoryEntry> history;
TestHistoryEntry get currentEntry { TestHistoryEntry get currentEntry {
@ -105,16 +98,6 @@ class TestUrlStrategy extends UrlStrategy {
currentEntry = TestHistoryEntry(state, title, url); currentEntry = TestHistoryEntry(state, title, url);
} }
/// This simulates the case where a user types in a url manually. It causes
/// a new state to be pushed, and all event listeners will be invoked.
Future<void> simulateUserTypingUrl(String url) {
assert(withinAppHistory);
return _nextEventLoop(() {
pushState(null, '', url);
_firePopStateEvent();
});
}
@override @override
Future<void> go(int count) { Future<void> go(int count) {
assert(withinAppHistory); assert(withinAppHistory);

View File

@ -56,13 +56,6 @@ class Memento extends Object with Diagnosticable {
/// An [ActionDispatcher] subclass that manages the invocation of undoable /// An [ActionDispatcher] subclass that manages the invocation of undoable
/// actions. /// actions.
class UndoableActionDispatcher extends ActionDispatcher implements Listenable { class UndoableActionDispatcher extends ActionDispatcher implements Listenable {
/// Constructs a new [UndoableActionDispatcher].
///
/// The [maxUndoLevels] argument must not be null.
UndoableActionDispatcher({
int maxUndoLevels = _defaultMaxUndoLevels,
}) : _maxUndoLevels = maxUndoLevels;
// A stack of actions that have been performed. The most recent action // A stack of actions that have been performed. The most recent action
// performed is at the end of the list. // performed is at the end of the list.
final DoubleLinkedQueue<Memento> _completedActions = DoubleLinkedQueue<Memento>(); final DoubleLinkedQueue<Memento> _completedActions = DoubleLinkedQueue<Memento>();
@ -70,19 +63,12 @@ class UndoableActionDispatcher extends ActionDispatcher implements Listenable {
// at the end of the list. // at the end of the list.
final List<Memento> _undoneActions = <Memento>[]; final List<Memento> _undoneActions = <Memento>[];
static const int _defaultMaxUndoLevels = 1000;
/// The maximum number of undo levels allowed. /// The maximum number of undo levels allowed.
/// ///
/// If this value is set to a value smaller than the number of completed /// If this value is set to a value smaller than the number of completed
/// actions, then the stack of completed actions is truncated to only include /// actions, then the stack of completed actions is truncated to only include
/// the last [maxUndoLevels] actions. /// the last [maxUndoLevels] actions.
int get maxUndoLevels => _maxUndoLevels; int get maxUndoLevels => 1000;
int _maxUndoLevels;
set maxUndoLevels(int value) {
_maxUndoLevels = value;
_pruneActions();
}
final Set<VoidCallback> _listeners = <VoidCallback>{}; final Set<VoidCallback> _listeners = <VoidCallback>{};
@ -121,7 +107,7 @@ class UndoableActionDispatcher extends ActionDispatcher implements Listenable {
// Enforces undo level limit. // Enforces undo level limit.
void _pruneActions() { void _pruneActions() {
while (_completedActions.length > _maxUndoLevels) { while (_completedActions.length > maxUndoLevels) {
_completedActions.removeFirst(); _completedActions.removeFirst();
} }
} }
@ -237,26 +223,12 @@ class RedoAction extends Action<RedoIntent> {
} }
/// An action that can be undone. /// An action that can be undone.
abstract class UndoableAction<T extends Intent> extends Action<T> { abstract class UndoableAction<T extends Intent> extends Action<T> { }
/// The [Intent] this action was originally invoked with.
Intent? get invocationIntent => _invocationTag;
Intent? _invocationTag;
@protected
set invocationIntent(Intent? value) => _invocationTag = value;
@override
@mustCallSuper
void invoke(T intent) {
invocationIntent = intent;
}
}
class UndoableFocusActionBase<T extends Intent> extends UndoableAction<T> { class UndoableFocusActionBase<T extends Intent> extends UndoableAction<T> {
@override @override
@mustCallSuper @mustCallSuper
Memento invoke(T intent) { Memento invoke(T intent) {
super.invoke(intent);
final FocusNode? previousFocus = primaryFocus; final FocusNode? previousFocus = primaryFocus;
return Memento(name: previousFocus!.debugLabel!, undo: () { return Memento(name: previousFocus!.debugLabel!, undo: () {
previousFocus.requestFocus(); previousFocus.requestFocus();
@ -295,8 +267,6 @@ class UndoablePreviousFocusAction extends UndoableFocusActionBase<PreviousFocusI
} }
class UndoableDirectionalFocusAction extends UndoableFocusActionBase<DirectionalFocusIntent> { class UndoableDirectionalFocusAction extends UndoableFocusActionBase<DirectionalFocusIntent> {
TraversalDirection? direction;
@override @override
Memento invoke(DirectionalFocusIntent intent) { Memento invoke(DirectionalFocusIntent intent) {
final Memento memento = super.invoke(intent); final Memento memento = super.invoke(intent);

View File

@ -30,15 +30,13 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return const MaterialApp( return const MaterialApp(
title: _title, title: _title,
home: MyHomePage(title: _title), home: MyHomePage(),
); );
} }
} }
class MyHomePage extends StatefulWidget { class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title}); const MyHomePage({super.key});
final String title;
@override @override
State<MyHomePage> createState() => _MyHomePageState(); State<MyHomePage> createState() => _MyHomePageState();
@ -92,12 +90,6 @@ class OptionModel extends ChangeNotifier {
bool get longText => _longText; bool get longText => _longText;
bool _longText = false; bool _longText = false;
set longText(bool longText) {
if (longText != _longText) {
_longText = longText;
notifyListeners();
}
}
void reset() { void reset() {
final OptionModel defaultModel = OptionModel(); final OptionModel defaultModel = OptionModel();

View File

@ -778,9 +778,4 @@ enum TestMenu {
final String acceleratorLabel; final String acceleratorLabel;
// Strip the accelerator markers. // Strip the accelerator markers.
String get label => MenuAcceleratorLabel.stripAcceleratorMarkers(acceleratorLabel); String get label => MenuAcceleratorLabel.stripAcceleratorMarkers(acceleratorLabel);
int get acceleratorIndex {
int index = -1;
MenuAcceleratorLabel.stripAcceleratorMarkers(acceleratorLabel, setIndex: (int i) => index = i);
return index;
}
} }

View File

@ -81,13 +81,12 @@ Future<void> runSmokeTests({
// A class to hold information related to an example, used to generate names // A class to hold information related to an example, used to generate names
// from for the tests. // from for the tests.
class ExampleInfo { class ExampleInfo {
ExampleInfo(this.file, Directory examplesLibDir) ExampleInfo(File file, Directory examplesLibDir)
: importPath = _getImportPath(file, examplesLibDir), : importPath = _getImportPath(file, examplesLibDir),
importName = '' { importName = '' {
importName = importPath.replaceAll(RegExp(r'\.dart$'), '').replaceAll(RegExp(r'\W'), '_'); importName = importPath.replaceAll(RegExp(r'\.dart$'), '').replaceAll(RegExp(r'\W'), '_');
} }
final File file;
final String importPath; final String importPath;
String importName; String importName;

View File

@ -6,3 +6,5 @@ linter:
rules: rules:
# Samples want to print things pretty often. # Samples want to print things pretty often.
avoid_print: false avoid_print: false
# Samples are sometimes incomplete and don't show usage of everything.
unreachable_from_main: false

View File

@ -139,6 +139,7 @@ Future<int> computeInstanceMethod(int square) {
Future<int> computeInvalidInstanceMethod(int square) { Future<int> computeInvalidInstanceMethod(int square) {
final ComputeTestSubject subject = ComputeTestSubject(square, ReceivePort()); final ComputeTestSubject subject = ComputeTestSubject(square, ReceivePort());
expect(subject.additional, isA<ReceivePort>());
return compute(subject.method, square); return compute(subject.method, square);
} }

View File

@ -3256,9 +3256,4 @@ enum TestMenu {
final String acceleratorLabel; final String acceleratorLabel;
// Strip the accelerator markers. // Strip the accelerator markers.
String get label => MenuAcceleratorLabel.stripAcceleratorMarkers(acceleratorLabel); String get label => MenuAcceleratorLabel.stripAcceleratorMarkers(acceleratorLabel);
int get acceleratorIndex {
int index = -1;
MenuAcceleratorLabel.stripAcceleratorMarkers(acceleratorLabel, setIndex: (int i) => index = i);
return index;
}
} }

View File

@ -26,8 +26,6 @@ class FakeFrameInfo implements FrameInfo {
@override @override
Image get image => _image; Image get image => _image;
int get imageHandleCount => image.debugGetOpenHandleStackTraces()!.length;
FakeFrameInfo clone() { FakeFrameInfo clone() {
return FakeFrameInfo( return FakeFrameInfo(
_duration, _duration,

View File

@ -218,37 +218,13 @@ class SemanticsUpdateBuilderSpy extends Fake implements ui.SemanticsUpdateBuilde
// Makes sure we don't send the same id twice. // Makes sure we don't send the same id twice.
assert(!observations.containsKey(id)); assert(!observations.containsKey(id));
observations[id] = SemanticsNodeUpdateObservation( observations[id] = SemanticsNodeUpdateObservation(
id: id,
flags: flags,
actions: actions,
maxValueLength: maxValueLength,
currentValueLength: currentValueLength,
textSelectionBase: textSelectionBase,
textSelectionExtent: textSelectionExtent,
platformViewId: platformViewId,
scrollChildren: scrollChildren,
scrollIndex: scrollIndex,
scrollPosition: scrollPosition,
scrollExtentMax: scrollExtentMax,
scrollExtentMin: scrollExtentMin,
elevation: elevation,
thickness: thickness,
rect: rect,
label: label, label: label,
labelAttributes: labelAttributes, labelAttributes: labelAttributes,
hint: hint, hint: hint,
hintAttributes: hintAttributes, hintAttributes: hintAttributes,
value: value, value: value,
valueAttributes: valueAttributes, valueAttributes: valueAttributes,
increasedValue: increasedValue,
increasedValueAttributes: increasedValueAttributes,
decreasedValue: decreasedValue,
decreasedValueAttributes: decreasedValueAttributes,
textDirection: textDirection,
transform: transform,
childrenInTraversalOrder: childrenInTraversalOrder, childrenInTraversalOrder: childrenInTraversalOrder,
childrenInHitTestOrder: childrenInHitTestOrder,
additionalActions: additionalActions,
); );
} }
@ -262,68 +238,20 @@ class SemanticsUpdateBuilderSpy extends Fake implements ui.SemanticsUpdateBuilde
class SemanticsNodeUpdateObservation { class SemanticsNodeUpdateObservation {
const SemanticsNodeUpdateObservation({ const SemanticsNodeUpdateObservation({
required this.id,
required this.flags,
required this.actions,
required this.maxValueLength,
required this.currentValueLength,
required this.textSelectionBase,
required this.textSelectionExtent,
required this.platformViewId,
required this.scrollChildren,
required this.scrollIndex,
required this.scrollPosition,
required this.scrollExtentMax,
required this.scrollExtentMin,
required this.elevation,
required this.thickness,
required this.rect,
required this.label, required this.label,
this.labelAttributes, this.labelAttributes,
required this.value, required this.value,
this.valueAttributes, this.valueAttributes,
required this.increasedValue,
this.increasedValueAttributes,
required this.decreasedValue,
this.decreasedValueAttributes,
required this.hint, required this.hint,
this.hintAttributes, this.hintAttributes,
this.textDirection,
required this.transform,
required this.childrenInTraversalOrder, required this.childrenInTraversalOrder,
required this.childrenInHitTestOrder,
required this.additionalActions,
}); });
final int id;
final int flags;
final int actions;
final int maxValueLength;
final int currentValueLength;
final int textSelectionBase;
final int textSelectionExtent;
final int platformViewId;
final int scrollChildren;
final int scrollIndex;
final double scrollPosition;
final double scrollExtentMax;
final double scrollExtentMin;
final double elevation;
final double thickness;
final Rect rect;
final String label; final String label;
final List<StringAttribute>? labelAttributes; final List<StringAttribute>? labelAttributes;
final String value; final String value;
final List<StringAttribute>? valueAttributes; final List<StringAttribute>? valueAttributes;
final String increasedValue;
final List<StringAttribute>? increasedValueAttributes;
final String decreasedValue;
final List<StringAttribute>? decreasedValueAttributes;
final String hint; final String hint;
final List<StringAttribute>? hintAttributes; final List<StringAttribute>? hintAttributes;
final TextDirection? textDirection;
final Float64List transform;
final Int32List childrenInTraversalOrder; final Int32List childrenInTraversalOrder;
final Int32List childrenInHitTestOrder;
final Int32List additionalActions;
} }

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:convert';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
@ -73,29 +71,3 @@ void main() {
expect(manifest.getAssetVariants('invalid asset key'), isNull); expect(manifest.getAssetVariants('invalid asset key'), isNull);
}); });
} }
String createAssetManifestJson(Map<String, List<AssetMetadata>> manifest) {
final Map<Object, Object> jsonObject = manifest.map(
(String key, List<AssetMetadata> value) {
final List<String> variants = value.map((AssetMetadata e) => e.key).toList();
return MapEntry<String, List<String>>(key, variants);
}
);
return json.encode(jsonObject);
}
ByteData createAssetManifestSmcBin(Map<String, List<AssetMetadata>> manifest) {
final Map<Object, Object> smcObject = manifest.map(
(String key, List<AssetMetadata> value) {
final List<Object> variants = value.map((AssetMetadata variant) => <String, Object?>{
'asset': variant.key,
'dpr': variant.targetDevicePixelRatio,
}).toList();
return MapEntry<String, List<Object>>(key, variants);
}
);
return const StandardMessageCodec().encodeMessage(smcObject)!;
}

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter/widgets.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
class InvalidOnInitLifecycleWidget extends StatefulWidget { class InvalidOnInitLifecycleWidget extends StatefulWidget {
@ -25,9 +25,9 @@ class InvalidOnInitLifecycleWidgetState extends State<InvalidOnInitLifecycleWidg
} }
class InvalidDidUpdateWidgetLifecycleWidget extends StatefulWidget { class InvalidDidUpdateWidgetLifecycleWidget extends StatefulWidget {
const InvalidDidUpdateWidgetLifecycleWidget({super.key, required this.id}); const InvalidDidUpdateWidgetLifecycleWidget({super.key, required this.color});
final int id; final Color color;
@override @override
InvalidDidUpdateWidgetLifecycleWidgetState createState() => InvalidDidUpdateWidgetLifecycleWidgetState(); InvalidDidUpdateWidgetLifecycleWidgetState createState() => InvalidDidUpdateWidgetLifecycleWidgetState();
@ -41,7 +41,7 @@ class InvalidDidUpdateWidgetLifecycleWidgetState extends State<InvalidDidUpdateW
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container(); return ColoredBox(color: widget.color);
} }
} }
@ -53,8 +53,8 @@ void main() {
}); });
testWidgets('async didUpdateWidget throws FlutterError', (WidgetTester tester) async { testWidgets('async didUpdateWidget throws FlutterError', (WidgetTester tester) async {
await tester.pumpWidget(const InvalidDidUpdateWidgetLifecycleWidget(id: 1)); await tester.pumpWidget(const InvalidDidUpdateWidgetLifecycleWidget(color: Colors.green));
await tester.pumpWidget(const InvalidDidUpdateWidgetLifecycleWidget(id: 2)); await tester.pumpWidget(const InvalidDidUpdateWidgetLifecycleWidget(color: Colors.red));
expect(tester.takeException(), isFlutterError); expect(tester.takeException(), isFlutterError);
}); });

View File

@ -600,23 +600,7 @@ class _AlwaysKeepAliveState extends State<_AlwaysKeepAlive> with AutomaticKeepAl
} }
} }
class RenderBoxKeepAlive extends RenderBox { class RenderBoxKeepAlive extends RenderBox { }
State<StatefulWidget> createState() => AlwaysKeepAliveRenderBoxState();
}
class AlwaysKeepAliveRenderBoxState extends State<_AlwaysKeepAlive> with AutomaticKeepAliveClientMixin<_AlwaysKeepAlive> {
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
super.build(context);
return const SizedBox(
height: 48.0,
child: Text('keep me alive'),
);
}
}
mixin KeepAliveParentDataMixinAlt implements KeepAliveParentDataMixin { mixin KeepAliveParentDataMixinAlt implements KeepAliveParentDataMixin {
@override @override
@ -631,14 +615,6 @@ class RenderSliverMultiBoxAdaptorAlt extends RenderSliver with
RenderSliverHelpers, RenderSliverHelpers,
RenderSliverWithKeepAliveMixin { RenderSliverWithKeepAliveMixin {
RenderSliverMultiBoxAdaptorAlt({
RenderSliverBoxChildManager? childManager,
}) : _childManager = childManager;
@protected
RenderSliverBoxChildManager? get childManager => _childManager;
final RenderSliverBoxChildManager? _childManager;
final List<RenderBox> children = <RenderBox>[]; final List<RenderBox> children = <RenderBox>[];
void insert(RenderBox child, { RenderBox? after }) { void insert(RenderBox child, { RenderBox? after }) {

View File

@ -30,16 +30,6 @@ class FadeInImageParts {
expect(animatedFadeOutFadeInElement, isNotNull); expect(animatedFadeOutFadeInElement, isNotNull);
return animatedFadeOutFadeInElement!.state; return animatedFadeOutFadeInElement!.state;
} }
Element? get semanticsElement {
Element? result;
fadeInImageElement.visitChildren((Element child) {
if (child.widget is Semantics) {
result = child;
}
});
return result;
}
} }
class FadeInImageElements { class FadeInImageElements {

View File

@ -106,7 +106,7 @@ class _TestWidgetState extends State<TestWidget> {
calledDuringBuild++; calledDuringBuild++;
}); });
return SizedBox.expand( return SizedBox.expand(
child: Text(Directionality.of(context).toString()), child: Text('${widget.value}: ${Directionality.of(context)}'),
); );
} }
} }

View File

@ -137,8 +137,8 @@ class SwapperElementWithProperOverrides extends SwapperElement {
} }
class RenderSwapper extends RenderBox { class RenderSwapper extends RenderBox {
RenderBox? _stable;
RenderBox? get stable => _stable; RenderBox? get stable => _stable;
RenderBox? _stable;
set stable(RenderBox? child) { set stable(RenderBox? child) {
if (child == _stable) { if (child == _stable) {
return; return;
@ -153,8 +153,8 @@ class RenderSwapper extends RenderBox {
} }
bool? _swapperIsOnTop; bool? _swapperIsOnTop;
RenderBox? _swapper;
RenderBox? get swapper => _swapper; RenderBox? get swapper => _swapper;
RenderBox? _swapper;
void setSwapper(RenderBox? child, bool isOnTop) { void setSwapper(RenderBox? child, bool isOnTop) {
if (isOnTop != _swapperIsOnTop) { if (isOnTop != _swapperIsOnTop) {
_swapperIsOnTop = isOnTop; _swapperIsOnTop = isOnTop;
@ -174,11 +174,11 @@ class RenderSwapper extends RenderBox {
@override @override
void visitChildren(RenderObjectVisitor visitor) { void visitChildren(RenderObjectVisitor visitor) {
if (_stable != null) { if (stable != null) {
visitor(_stable!); visitor(stable!);
} }
if (_swapper != null) { if (swapper != null) {
visitor(_swapper!); visitor(swapper!);
} }
} }
@ -210,14 +210,14 @@ class RenderSwapper extends RenderBox {
minHeight: constraints.minHeight / 2, minHeight: constraints.minHeight / 2,
maxHeight: constraints.maxHeight / 2, maxHeight: constraints.maxHeight / 2,
); );
if (_stable != null) { if (stable != null) {
final BoxParentData stableParentData = _stable!.parentData! as BoxParentData; final BoxParentData stableParentData = stable!.parentData! as BoxParentData;
_stable!.layout(childConstraints); stable!.layout(childConstraints);
stableParentData.offset = _swapperIsOnTop! ? bottomOffset : topOffset; stableParentData.offset = _swapperIsOnTop! ? bottomOffset : topOffset;
} }
if (_swapper != null) { if (swapper != null) {
final BoxParentData swapperParentData = _swapper!.parentData! as BoxParentData; final BoxParentData swapperParentData = swapper!.parentData! as BoxParentData;
_swapper!.layout(childConstraints); swapper!.layout(childConstraints);
swapperParentData.offset = _swapperIsOnTop! ? topOffset : bottomOffset; swapperParentData.offset = _swapperIsOnTop! ? topOffset : bottomOffset;
} }
} }

View File

@ -63,10 +63,8 @@ class DummyStatefulWidgetState extends State<DummyStatefulWidget> {
class RekeyableDummyStatefulWidgetWrapper extends StatefulWidget { class RekeyableDummyStatefulWidgetWrapper extends StatefulWidget {
const RekeyableDummyStatefulWidgetWrapper({ const RekeyableDummyStatefulWidgetWrapper({
super.key, super.key,
this.child,
required this.initialKey, required this.initialKey,
}); });
final Widget? child;
final GlobalKey initialKey; final GlobalKey initialKey;
@override @override
RekeyableDummyStatefulWidgetWrapperState createState() => RekeyableDummyStatefulWidgetWrapperState(); RekeyableDummyStatefulWidgetWrapperState createState() => RekeyableDummyStatefulWidgetWrapperState();

View File

@ -1610,10 +1610,6 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit
RouteInformation get routeInformation => _routeInformation; RouteInformation get routeInformation => _routeInformation;
late RouteInformation _routeInformation; late RouteInformation _routeInformation;
set routeInformation(RouteInformation newValue) {
_routeInformation = newValue;
notifyListeners();
}
SimpleRouterDelegateBuilder builder; SimpleRouterDelegateBuilder builder;
SimpleNavigatorRouterDelegatePopPage<void> onPopPage; SimpleNavigatorRouterDelegatePopPage<void> onPopPage;
@ -1711,10 +1707,6 @@ class SimpleAsyncRouterDelegate extends RouterDelegate<RouteInformation> with Ch
RouteInformation? get routeInformation => _routeInformation; RouteInformation? get routeInformation => _routeInformation;
RouteInformation? _routeInformation; RouteInformation? _routeInformation;
set routeInformation(RouteInformation? newValue) {
_routeInformation = newValue;
notifyListeners();
}
SimpleRouterDelegateBuilder builder; SimpleRouterDelegateBuilder builder;
late Future<void> setNewRouteFuture; late Future<void> setNewRouteFuture;

View File

@ -18,7 +18,6 @@ extension on web.CSSRuleList {
Iterable<web.CSSRule> get iterable => _genIterable(this); Iterable<web.CSSRule> get iterable => _genIterable(this);
} }
typedef ItemGetter<T> = T? Function(int index);
Iterable<T> _genIterable<T>(dynamic jsCollection) { Iterable<T> _genIterable<T>(dynamic jsCollection) {
// ignore: avoid_dynamic_calls // ignore: avoid_dynamic_calls
return Iterable<T>.generate(jsCollection.length as int, (int index) => jsCollection.item(index) as T,); return Iterable<T>.generate(jsCollection.length as int, (int index) => jsCollection.item(index) as T,);
@ -159,8 +158,7 @@ class RenderSelectionSpy extends RenderProxyBox
} }
@override @override
SelectionGeometry get value => _value; final SelectionGeometry value = const SelectionGeometry(
SelectionGeometry _value = const SelectionGeometry(
hasContent: true, hasContent: true,
status: SelectionStatus.uncollapsed, status: SelectionStatus.uncollapsed,
startSelectionPoint: SelectionPoint( startSelectionPoint: SelectionPoint(
@ -174,15 +172,6 @@ class RenderSelectionSpy extends RenderProxyBox
handleType: TextSelectionHandleType.left, handleType: TextSelectionHandleType.left,
), ),
); );
set value(SelectionGeometry other) {
if (other == _value) {
return;
}
_value = other;
for (final VoidCallback callback in listeners) {
callback();
}
}
@override @override
void pushHandleLayers(LayerLink? startHandle, LayerLink? endHandle) { } void pushHandleLayers(LayerLink? startHandle, LayerLink? endHandle) { }

View File

@ -2526,8 +2526,7 @@ class RenderSelectionSpy extends RenderProxyBox
} }
@override @override
SelectionGeometry get value => _value; final SelectionGeometry value = const SelectionGeometry(
SelectionGeometry _value = const SelectionGeometry(
hasContent: true, hasContent: true,
status: SelectionStatus.uncollapsed, status: SelectionStatus.uncollapsed,
startSelectionPoint: SelectionPoint( startSelectionPoint: SelectionPoint(
@ -2541,15 +2540,6 @@ class RenderSelectionSpy extends RenderProxyBox
handleType: TextSelectionHandleType.left, handleType: TextSelectionHandleType.left,
), ),
); );
set value(SelectionGeometry other) {
if (other == _value) {
return;
}
_value = other;
for (final VoidCallback callback in listeners) {
callback();
}
}
@override @override
void pushHandleLayers(LayerLink? startHandle, LayerLink? endHandle) { } void pushHandleLayers(LayerLink? startHandle, LayerLink? endHandle) { }

View File

@ -96,13 +96,13 @@ class RenderTest extends RenderProxyBox {
void describeSemanticsConfiguration(SemanticsConfiguration config) { void describeSemanticsConfiguration(SemanticsConfiguration config) {
super.describeSemanticsConfiguration(config); super.describeSemanticsConfiguration(config);
if (!_isSemanticBoundary) { if (!isSemanticBoundary) {
return; return;
} }
config config
..isSemanticBoundary = _isSemanticBoundary ..isSemanticBoundary = isSemanticBoundary
..label = _label ..label = label
..textDirection = TextDirection.ltr; ..textDirection = TextDirection.ltr;
} }

View File

@ -357,6 +357,6 @@ class RenderTestConfigDelegate extends RenderProxyBox {
@override @override
void describeSemanticsConfiguration(SemanticsConfiguration config) { void describeSemanticsConfiguration(SemanticsConfiguration config) {
config.childConfigurationsDelegate = _delegate; config.childConfigurationsDelegate = delegate;
} }
} }

View File

@ -601,18 +601,12 @@ void main() {
testWidgets('Shortcuts.manager lets manager handle shortcuts', (WidgetTester tester) async { testWidgets('Shortcuts.manager lets manager handle shortcuts', (WidgetTester tester) async {
final GlobalKey containerKey = GlobalKey(); final GlobalKey containerKey = GlobalKey();
final List<LogicalKeyboardKey> pressedKeys = <LogicalKeyboardKey>[]; final List<LogicalKeyboardKey> pressedKeys = <LogicalKeyboardKey>[];
bool shortcutsSet = false;
void onShortcutsSet() {
shortcutsSet = true;
}
final TestShortcutManager testManager = TestShortcutManager( final TestShortcutManager testManager = TestShortcutManager(
pressedKeys, pressedKeys,
onShortcutsSet: onShortcutsSet,
shortcuts: <LogicalKeySet, Intent>{ shortcuts: <LogicalKeySet, Intent>{
LogicalKeySet(LogicalKeyboardKey.shift): const TestIntent(), LogicalKeySet(LogicalKeyboardKey.shift): const TestIntent(),
}, },
); );
shortcutsSet = false;
bool invoked = false; bool invoked = false;
await tester.pumpWidget( await tester.pumpWidget(
Actions( Actions(
@ -636,7 +630,6 @@ void main() {
await tester.pump(); await tester.pump();
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft); await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
expect(invoked, isTrue); expect(invoked, isTrue);
expect(shortcutsSet, isFalse);
expect(pressedKeys, equals(<LogicalKeyboardKey>[LogicalKeyboardKey.shiftLeft])); expect(pressedKeys, equals(<LogicalKeyboardKey>[LogicalKeyboardKey.shiftLeft]));
}); });
@ -1953,10 +1946,9 @@ class TestIntent2 extends Intent {
} }
class TestShortcutManager extends ShortcutManager { class TestShortcutManager extends ShortcutManager {
TestShortcutManager(this.keys, { super.shortcuts, this.onShortcutsSet }); TestShortcutManager(this.keys, { super.shortcuts });
List<LogicalKeyboardKey> keys; List<LogicalKeyboardKey> keys;
VoidCallback? onShortcutsSet;
@override @override
KeyEventResult handleKeypress(BuildContext context, RawKeyEvent event) { KeyEventResult handleKeypress(BuildContext context, RawKeyEvent event) {

View File

@ -319,7 +319,7 @@ void main() {
WidgetTest2(text: 'child 2', key: UniqueKey()), WidgetTest2(text: 'child 2', key: UniqueKey()),
]; ];
await tester.pumpWidget( await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList), SwitchingSliverListTest(children: childList),
); );
final _WidgetTest0State state0 = tester.state(find.byType(WidgetTest0)); final _WidgetTest0State state0 = tester.state(find.byType(WidgetTest0));
final _WidgetTest1State state1 = tester.state(find.byType(WidgetTest1)); final _WidgetTest1State state1 = tester.state(find.byType(WidgetTest1));
@ -330,32 +330,32 @@ void main() {
childList = createSwitchedChildList(childList, 0, 2); childList = createSwitchedChildList(childList, 0, 2);
await tester.pumpWidget( await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList), SwitchingSliverListTest(children: childList),
); );
childList = createSwitchedChildList(childList, 1, 2); childList = createSwitchedChildList(childList, 1, 2);
await tester.pumpWidget( await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList), SwitchingSliverListTest(children: childList),
); );
childList = createSwitchedChildList(childList, 1, 2); childList = createSwitchedChildList(childList, 1, 2);
await tester.pumpWidget( await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList), SwitchingSliverListTest(children: childList),
); );
childList = createSwitchedChildList(childList, 0, 1); childList = createSwitchedChildList(childList, 0, 1);
await tester.pumpWidget( await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList), SwitchingSliverListTest(children: childList),
); );
childList = createSwitchedChildList(childList, 0, 2); childList = createSwitchedChildList(childList, 0, 2);
await tester.pumpWidget( await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList), SwitchingSliverListTest(children: childList),
); );
childList = createSwitchedChildList(childList, 0, 1); childList = createSwitchedChildList(childList, 0, 1);
await tester.pumpWidget( await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList), SwitchingSliverListTest(children: childList),
); );
expect(state0.hasBeenDisposed, false); expect(state0.hasBeenDisposed, false);
expect(state1.hasBeenDisposed, true); expect(state1.hasBeenDisposed, true);
@ -369,7 +369,7 @@ void main() {
WidgetTest2(text: 'child 2', key: UniqueKey()), WidgetTest2(text: 'child 2', key: UniqueKey()),
]; ];
await tester.pumpWidget( await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList), SwitchingSliverListTest(children: childList),
); );
final _WidgetTest0State state0 = tester.state(find.byType(WidgetTest0)); final _WidgetTest0State state0 = tester.state(find.byType(WidgetTest0));
final _WidgetTest1State state1 = tester.state(find.byType(WidgetTest1)); final _WidgetTest1State state1 = tester.state(find.byType(WidgetTest1));
@ -381,7 +381,7 @@ void main() {
childList = createSwitchedChildList(childList, 0, 1); childList = createSwitchedChildList(childList, 0, 1);
childList.removeAt(2); childList.removeAt(2);
await tester.pumpWidget( await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList), SwitchingSliverListTest(children: childList),
); );
expect(find.text('child 0'), findsOneWidget); expect(find.text('child 0'), findsOneWidget);
expect(find.text('child 1'), findsOneWidget); expect(find.text('child 1'), findsOneWidget);
@ -505,12 +505,10 @@ class SwitchingChildListTest extends StatelessWidget {
class SwitchingSliverListTest extends StatelessWidget { class SwitchingSliverListTest extends StatelessWidget {
const SwitchingSliverListTest({ const SwitchingSliverListTest({
required this.children, required this.children,
this.viewportFraction = 1.0,
super.key, super.key,
}); });
final List<Widget> children; final List<Widget> children;
final double viewportFraction;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -335,10 +335,6 @@ class TestPainter extends SnapshotPainter {
super.removeListener(listener); super.removeListener(listener);
} }
void notify() {
notifyListeners();
}
@override @override
void paintSnapshot(PaintingContext context, Offset offset, Size size, ui.Image image, Size sourceSize, double pixelRatio) { void paintSnapshot(PaintingContext context, Offset offset, Size size, ui.Image image, Size sourceSize, double pixelRatio) {
count += 1; count += 1;

View File

@ -195,7 +195,13 @@ class TestCase {
// Use Flutter's analysis_options.yaml file from packages/flutter. // Use Flutter's analysis_options.yaml file from packages/flutter.
File(path.join(tmpdir.absolute.path, 'analysis_options.yaml')) File(path.join(tmpdir.absolute.path, 'analysis_options.yaml'))
.writeAsStringSync('include: ${path.toUri(path.join(flutterRoot.path, 'packages', 'flutter', 'analysis_options.yaml'))}'); .writeAsStringSync(
'include: ${path.toUri(path.join(flutterRoot.path, 'packages', 'flutter', 'analysis_options.yaml'))}\n'
'linter:\n'
' rules:\n'
// The code does wonky things with the part-of directive that cause false positives.
' unreachable_from_main: false'
);
return true; return true;
} }

View File

@ -243,7 +243,6 @@ void main() {
class TestObserver with WidgetsBindingObserver { class TestObserver with WidgetsBindingObserver {
List<Locale>? locales; List<Locale>? locales;
Locale? locale;
@override @override
void didChangeLocales(List<Locale>? locales) { void didChangeLocales(List<Locale>? locales) {

View File

@ -63,11 +63,6 @@ class Context {
} }
} }
bool existsDir(String path) {
final Directory dir = Directory(path);
return dir.existsSync();
}
bool existsFile(String path) { bool existsFile(String path) {
final File file = File(path); final File file = File(path);
return file.existsSync(); return file.existsSync();

View File

@ -105,7 +105,6 @@ void main() {
testUsingContext('succeeds with iOS device with protocol discovery', () async { testUsingContext('succeeds with iOS device with protocol discovery', () async {
final FakeIOSDevice device = FakeIOSDevice( final FakeIOSDevice device = FakeIOSDevice(
logReader: fakeLogReader,
portForwarder: portForwarder, portForwarder: portForwarder,
majorSdkVersion: 12, majorSdkVersion: 12,
onGetLogReader: () { onGetLogReader: () {
@ -167,7 +166,6 @@ void main() {
testUsingContext('succeeds with iOS device with mDNS', () async { testUsingContext('succeeds with iOS device with mDNS', () async {
final FakeIOSDevice device = FakeIOSDevice( final FakeIOSDevice device = FakeIOSDevice(
logReader: fakeLogReader,
portForwarder: portForwarder, portForwarder: portForwarder,
majorSdkVersion: 16, majorSdkVersion: 16,
onGetLogReader: () { onGetLogReader: () {
@ -237,7 +235,6 @@ void main() {
testUsingContext('succeeds with iOS device with mDNS wireless device', () async { testUsingContext('succeeds with iOS device with mDNS wireless device', () async {
final FakeIOSDevice device = FakeIOSDevice( final FakeIOSDevice device = FakeIOSDevice(
logReader: fakeLogReader,
portForwarder: portForwarder, portForwarder: portForwarder,
majorSdkVersion: 16, majorSdkVersion: 16,
connectionInterface: DeviceConnectionInterface.wireless, connectionInterface: DeviceConnectionInterface.wireless,
@ -309,7 +306,6 @@ void main() {
testUsingContext('succeeds with iOS device with mDNS wireless device with debug-port', () async { testUsingContext('succeeds with iOS device with mDNS wireless device with debug-port', () async {
final FakeIOSDevice device = FakeIOSDevice( final FakeIOSDevice device = FakeIOSDevice(
logReader: fakeLogReader,
portForwarder: portForwarder, portForwarder: portForwarder,
majorSdkVersion: 16, majorSdkVersion: 16,
connectionInterface: DeviceConnectionInterface.wireless, connectionInterface: DeviceConnectionInterface.wireless,
@ -385,7 +381,6 @@ void main() {
testUsingContext('succeeds with iOS device with mDNS wireless device with debug-url', () async { testUsingContext('succeeds with iOS device with mDNS wireless device with debug-url', () async {
final FakeIOSDevice device = FakeIOSDevice( final FakeIOSDevice device = FakeIOSDevice(
logReader: fakeLogReader,
portForwarder: portForwarder, portForwarder: portForwarder,
majorSdkVersion: 16, majorSdkVersion: 16,
connectionInterface: DeviceConnectionInterface.wireless, connectionInterface: DeviceConnectionInterface.wireless,
@ -619,7 +614,6 @@ void main() {
testUsingContext('succeeds when ipv6 is specified and debug-port is not on iOS device', () async { testUsingContext('succeeds when ipv6 is specified and debug-port is not on iOS device', () async {
final FakeIOSDevice device = FakeIOSDevice( final FakeIOSDevice device = FakeIOSDevice(
logReader: fakeLogReader,
portForwarder: portForwarder, portForwarder: portForwarder,
majorSdkVersion: 12, majorSdkVersion: 12,
onGetLogReader: () { onGetLogReader: () {
@ -1350,11 +1344,10 @@ class FakeAndroidDevice extends Fake implements AndroidDevice {
class FakeIOSDevice extends Fake implements IOSDevice { class FakeIOSDevice extends Fake implements IOSDevice {
FakeIOSDevice({ FakeIOSDevice({
DevicePortForwarder? portForwarder, DevicePortForwarder? portForwarder,
DeviceLogReader? logReader,
this.onGetLogReader, this.onGetLogReader,
this.connectionInterface = DeviceConnectionInterface.attached, this.connectionInterface = DeviceConnectionInterface.attached,
this.majorSdkVersion = 0, this.majorSdkVersion = 0,
}) : _portForwarder = portForwarder, _logReader = logReader; }) : _portForwarder = portForwarder;
final DevicePortForwarder? _portForwarder; final DevicePortForwarder? _portForwarder;
@override @override
@ -1373,9 +1366,6 @@ class FakeIOSDevice extends Fake implements IOSDevice {
@override @override
DartDevelopmentService get dds => throw UnimplementedError('getter dds not implemented'); DartDevelopmentService get dds => throw UnimplementedError('getter dds not implemented');
final DeviceLogReader? _logReader;
DeviceLogReader get logReader => _logReader!;
final DeviceLogReader Function()? onGetLogReader; final DeviceLogReader Function()? onGetLogReader;
@override @override
@ -1470,11 +1460,9 @@ class FakeMDnsClient extends Fake implements MDnsClient {
} }
class TestDeviceManager extends DeviceManager { class TestDeviceManager extends DeviceManager {
TestDeviceManager({required this.logger}) : super(logger: logger); TestDeviceManager({required super.logger});
List<Device> devices = <Device>[]; List<Device> devices = <Device>[];
final BufferLogger logger;
@override @override
List<DeviceDiscovery> get deviceDiscoverers { List<DeviceDiscovery> get deviceDiscoverers {
final FakePollingDeviceDiscovery discoverer = FakePollingDeviceDiscovery(); final FakePollingDeviceDiscovery discoverer = FakePollingDeviceDiscovery();

View File

@ -19,9 +19,7 @@ import '../../src/test_flutter_command_runner.dart';
import '../../src/testbed.dart'; import '../../src/testbed.dart';
class FakePub extends Fake implements Pub { class FakePub extends Fake implements Pub {
FakePub(this.fs);
final FileSystem fs;
int calledGetOffline = 0; int calledGetOffline = 0;
int calledOnline = 0; int calledOnline = 0;
@ -59,7 +57,7 @@ void main() {
setUp(() { setUp(() {
testbed = Testbed(setup: () { testbed = Testbed(setup: () {
fakePub = FakePub(globals.fs); fakePub = FakePub();
Cache.flutterRoot = 'flutter'; Cache.flutterRoot = 'flutter';
final List<String> filePaths = <String>[ final List<String> filePaths = <String>[
globals.fs.path.join('flutter', 'packages', 'flutter', 'pubspec.yaml'), globals.fs.path.join('flutter', 'packages', 'flutter', 'pubspec.yaml'),

View File

@ -831,41 +831,6 @@ class FakeAndroidWorkflow extends Fake implements AndroidWorkflow {
final bool appliesToHostPlatform; final bool appliesToHostPlatform;
} }
class NoOpDoctor implements Doctor {
@override
bool get canLaunchAnything => true;
@override
bool get canListAnything => true;
@override
Future<bool> checkRemoteArtifacts(String engineRevision) async => true;
@override
Future<bool> diagnose({
bool androidLicenses = false,
bool verbose = true,
bool showColor = true,
AndroidLicenseValidator? androidLicenseValidator,
bool showPii = true,
List<ValidatorTask>? startedValidatorTasks,
bool sendEvent = true,
FlutterVersion? version,
}) async => true;
@override
List<ValidatorTask> startValidatorTasks() => <ValidatorTask>[];
@override
Future<void> summary() async { }
@override
List<DoctorValidator> get validators => <DoctorValidator>[];
@override
List<Workflow> get workflows => <Workflow>[];
}
class PassingValidator extends DoctorValidator { class PassingValidator extends DoctorValidator {
PassingValidator(super.title); PassingValidator(super.title);

View File

@ -1148,11 +1148,9 @@ void main() {
} }
class TestDeviceManager extends DeviceManager { class TestDeviceManager extends DeviceManager {
TestDeviceManager({required this.logger}) : super(logger: logger); TestDeviceManager({required super.logger});
List<Device> devices = <Device>[]; List<Device> devices = <Device>[];
final Logger logger;
@override @override
List<DeviceDiscovery> get deviceDiscoverers { List<DeviceDiscovery> get deviceDiscoverers {
final FakePollingDeviceDiscovery discoverer = FakePollingDeviceDiscovery(); final FakePollingDeviceDiscovery discoverer = FakePollingDeviceDiscovery();

View File

@ -9,9 +9,6 @@ import 'package:flutter_tools/src/android/gradle_utils.dart';
import 'package:flutter_tools/src/android/migrations/android_studio_java_gradle_conflict_migration.dart'; import 'package:flutter_tools/src/android/migrations/android_studio_java_gradle_conflict_migration.dart';
import 'package:flutter_tools/src/android/migrations/top_level_gradle_build_file_migration.dart'; import 'package:flutter_tools/src/android/migrations/top_level_gradle_build_file_migration.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/base/version.dart'; import 'package:flutter_tools/src/base/version.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
@ -287,8 +284,3 @@ class FakeErroringJava extends FakeJava {
throw Exception('How did this happen?'); throw Exception('How did this happen?');
} }
} }
class FakeFileSystem extends Fake implements FileSystem {}
class FakeProcessUtils extends Fake implements ProcessUtils {}
class FakePlatform extends Fake implements Platform {}
class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {}

View File

@ -4,12 +4,10 @@
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/android_sdk.dart'; import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/android/android_studio.dart';
import 'package:flutter_tools/src/base/config.dart'; import 'package:flutter_tools/src/base/config.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:test/fake.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/context.dart';
@ -424,13 +422,3 @@ ro.build.version.incremental=1624448
ro.build.version.sdk=24 ro.build.version.sdk=24
ro.build.version.codename=REL ro.build.version.codename=REL
'''; ''';
class FakeAndroidStudioWithJdk extends Fake implements AndroidStudio {
@override
String? get javaPath => '/fake/android_studio/java/path/';
}
class FakeAndroidStudioWithoutJdk extends Fake implements AndroidStudio {
@override
String? get javaPath => null;
}

View File

@ -371,7 +371,7 @@ void main() {
}); });
testWithoutContext('ArtifactUpdater will de-download a file if unzipping fails on windows', () async { testWithoutContext('ArtifactUpdater will de-download a file if unzipping fails on windows', () async {
final FakeOperatingSystemUtils operatingSystemUtils = FakeOperatingSystemUtils(windows: true); final FakeOperatingSystemUtils operatingSystemUtils = FakeOperatingSystemUtils();
final MemoryFileSystem fileSystem = MemoryFileSystem.test(); final MemoryFileSystem fileSystem = MemoryFileSystem.test();
final BufferLogger logger = BufferLogger.test(); final BufferLogger logger = BufferLogger.test();
final ArtifactUpdater artifactUpdater = ArtifactUpdater( final ArtifactUpdater artifactUpdater = ArtifactUpdater(
@ -421,7 +421,7 @@ void main() {
}); });
testWithoutContext('ArtifactUpdater will bail if unzipping fails more than twice on Windows', () async { testWithoutContext('ArtifactUpdater will bail if unzipping fails more than twice on Windows', () async {
final FakeOperatingSystemUtils operatingSystemUtils = FakeOperatingSystemUtils(windows: true); final FakeOperatingSystemUtils operatingSystemUtils = FakeOperatingSystemUtils();
final MemoryFileSystem fileSystem = MemoryFileSystem.test(); final MemoryFileSystem fileSystem = MemoryFileSystem.test();
final BufferLogger logger = BufferLogger.test(); final BufferLogger logger = BufferLogger.test();
final ArtifactUpdater artifactUpdater = ArtifactUpdater( final ArtifactUpdater artifactUpdater = ArtifactUpdater(
@ -529,10 +529,7 @@ void main() {
} }
class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils { class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
FakeOperatingSystemUtils({this.windows = false});
int failures = 0; int failures = 0;
final bool windows;
/// A mapping of zip [file] paths to callbacks that receive the [targetDirectory]. /// A mapping of zip [file] paths to callbacks that receive the [targetDirectory].
/// ///

View File

@ -1204,7 +1204,7 @@ class FakeSimControl extends Fake implements SimControl {
@override @override
Future<RunResult> launch(String deviceId, String appIdentifier, [ List<String>? launchArgs ]) async { Future<RunResult> launch(String deviceId, String appIdentifier, [ List<String>? launchArgs ]) async {
requests.add(LaunchRequest(deviceId, appIdentifier, launchArgs)); requests.add(LaunchRequest(appIdentifier, launchArgs));
return RunResult(ProcessResult(0, 0, '', ''), <String>['test']); return RunResult(ProcessResult(0, 0, '', ''), <String>['test']);
} }
@ -1215,9 +1215,8 @@ class FakeSimControl extends Fake implements SimControl {
} }
class LaunchRequest { class LaunchRequest {
const LaunchRequest(this.deviceId, this.appIdentifier, this.launchArgs); const LaunchRequest(this.appIdentifier, this.launchArgs);
final String deviceId;
final String appIdentifier; final String appIdentifier;
final List<String>? launchArgs; final List<String>? launchArgs;
} }

View File

@ -1496,7 +1496,6 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { }
class TestRunner extends Fake implements ResidentRunner { class TestRunner extends Fake implements ResidentRunner {
bool hasHelpBeenPrinted = false; bool hasHelpBeenPrinted = false;
String? receivedCommand;
@override @override
Future<void> cleanupAfterSignal() async { } Future<void> cleanupAfterSignal() async { }

View File

@ -1211,11 +1211,9 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
} }
class FakeDwds extends Fake implements Dwds { class FakeDwds extends Fake implements Dwds {
FakeDwds(this.connectedAppsIterable) : FakeDwds(Iterable<AppConnection> connectedAppsIterable) :
connectedApps = Stream<AppConnection>.fromIterable(connectedAppsIterable); connectedApps = Stream<AppConnection>.fromIterable(connectedAppsIterable);
final Iterable<AppConnection> connectedAppsIterable;
@override @override
final Stream<AppConnection> connectedApps; final Stream<AppConnection> connectedApps;

View File

@ -394,12 +394,6 @@ void main() {
class TestChromiumLauncher implements ChromiumLauncher { class TestChromiumLauncher implements ChromiumLauncher {
TestChromiumLauncher(); TestChromiumLauncher();
bool _hasInstance = false;
void setInstance(Chromium chromium) {
_hasInstance = true;
currentCompleter.complete(chromium);
}
@override @override
Completer<Chromium> currentCompleter = Completer<Chromium>(); Completer<Chromium> currentCompleter = Completer<Chromium>();
@ -417,7 +411,7 @@ class TestChromiumLauncher implements ChromiumLauncher {
} }
@override @override
bool get hasChromeInstance => _hasInstance; bool get hasChromeInstance => false;
@override @override
Future<Chromium> launch( Future<Chromium> launch(

View File

@ -234,11 +234,6 @@ class TestContext extends Context {
String stdout = ''; String stdout = '';
String stderr = ''; String stderr = '';
@override
bool existsDir(String path) {
return fileSystem.directory(path).existsSync();
}
@override @override
bool existsFile(String path) { bool existsFile(String path) {
return fileSystem.file(path).existsSync(); return fileSystem.file(path).existsSync();