Unverified Commit 55b6f049 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

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

PLUS: clean-up of all the unreachable stuff.
parent 99cb18b1
......@@ -223,7 +223,7 @@ linter:
- unnecessary_string_interpolations
- unnecessary_this
- 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
- unsafe_html
- use_build_context_synchronously
......
......@@ -12,9 +12,10 @@ const int _kNumWarmUp = 100;
class Data {
Data(this.value);
Map<String, dynamic> toJson() => <String, dynamic>{ 'value': value };
final int value;
@override
String toString() => 'Data($value)';
}
List<Data> test(int length) {
......
......@@ -5,7 +5,6 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show timeDilation;
void main() {
runApp(
......@@ -31,12 +30,6 @@ class PlatformViewAppState extends State<PlatformViewApp> {
home: const PlatformViewLayout(),
);
}
void toggleAnimationSpeed() {
setState(() {
timeDilation = (timeDilation != 1.0) ? 1.0 : 5.0;
});
}
}
class PlatformViewLayout extends StatelessWidget {
......
......@@ -5,7 +5,6 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show timeDilation;
void main() {
runApp(
......@@ -31,12 +30,6 @@ class PlatformViewAppState extends State<PlatformViewApp> {
home: const PlatformViewLayout(),
);
}
void toggleAnimationSpeed() {
setState(() {
timeDilation = (timeDilation != 1.0) ? 1.0 : 5.0;
});
}
}
class PlatformViewLayout extends StatelessWidget {
......
......@@ -5,7 +5,6 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart' show timeDilation;
import 'package:flutter_driver/driver_extension.dart';
import 'android_platform_view.dart';
......@@ -35,12 +34,6 @@ class PlatformViewAppState extends State<PlatformViewApp> {
home: const PlatformViewLayout(),
);
}
void toggleAnimationSpeed() {
setState(() {
timeDilation = (timeDilation != 1.0) ? 1.0 : 5.0;
});
}
}
class PlatformViewLayout extends StatelessWidget {
......
......@@ -46,11 +46,6 @@ void main() {
/// It keeps a list of history entries and event listeners in memory and
/// manipulates them in order to achieve the desired functionality.
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
/// that has [initialEntry] as the only item.
TestUrlStrategy.fromEntry(TestHistoryEntry initialEntry)
......@@ -64,8 +59,6 @@ class TestUrlStrategy extends UrlStrategy {
dynamic getState() => currentEntry.state;
int _currentEntryIndex;
int get currentEntryIndex => _currentEntryIndex;
final List<TestHistoryEntry> history;
TestHistoryEntry get currentEntry {
......@@ -105,16 +98,6 @@ class TestUrlStrategy extends UrlStrategy {
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
Future<void> go(int count) {
assert(withinAppHistory);
......
......@@ -56,13 +56,6 @@ class Memento extends Object with Diagnosticable {
/// An [ActionDispatcher] subclass that manages the invocation of undoable
/// actions.
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
// performed is at the end of the list.
final DoubleLinkedQueue<Memento> _completedActions = DoubleLinkedQueue<Memento>();
......@@ -70,19 +63,12 @@ class UndoableActionDispatcher extends ActionDispatcher implements Listenable {
// at the end of the list.
final List<Memento> _undoneActions = <Memento>[];
static const int _defaultMaxUndoLevels = 1000;
/// The maximum number of undo levels allowed.
///
/// 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
/// the last [maxUndoLevels] actions.
int get maxUndoLevels => _maxUndoLevels;
int _maxUndoLevels;
set maxUndoLevels(int value) {
_maxUndoLevels = value;
_pruneActions();
}
int get maxUndoLevels => 1000;
final Set<VoidCallback> _listeners = <VoidCallback>{};
......@@ -121,7 +107,7 @@ class UndoableActionDispatcher extends ActionDispatcher implements Listenable {
// Enforces undo level limit.
void _pruneActions() {
while (_completedActions.length > _maxUndoLevels) {
while (_completedActions.length > maxUndoLevels) {
_completedActions.removeFirst();
}
}
......@@ -237,26 +223,12 @@ class RedoAction extends Action<RedoIntent> {
}
/// An action that can be undone.
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;
}
}
abstract class UndoableAction<T extends Intent> extends Action<T> { }
class UndoableFocusActionBase<T extends Intent> extends UndoableAction<T> {
@override
@mustCallSuper
Memento invoke(T intent) {
super.invoke(intent);
final FocusNode? previousFocus = primaryFocus;
return Memento(name: previousFocus!.debugLabel!, undo: () {
previousFocus.requestFocus();
......@@ -295,8 +267,6 @@ class UndoablePreviousFocusAction extends UndoableFocusActionBase<PreviousFocusI
}
class UndoableDirectionalFocusAction extends UndoableFocusActionBase<DirectionalFocusIntent> {
TraversalDirection? direction;
@override
Memento invoke(DirectionalFocusIntent intent) {
final Memento memento = super.invoke(intent);
......
......@@ -30,15 +30,13 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return const MaterialApp(
title: _title,
home: MyHomePage(title: _title),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
......@@ -92,12 +90,6 @@ class OptionModel extends ChangeNotifier {
bool get longText => _longText;
bool _longText = false;
set longText(bool longText) {
if (longText != _longText) {
_longText = longText;
notifyListeners();
}
}
void reset() {
final OptionModel defaultModel = OptionModel();
......
......@@ -778,9 +778,4 @@ enum TestMenu {
final String acceleratorLabel;
// Strip the accelerator markers.
String get label => MenuAcceleratorLabel.stripAcceleratorMarkers(acceleratorLabel);
int get acceleratorIndex {
int index = -1;
MenuAcceleratorLabel.stripAcceleratorMarkers(acceleratorLabel, setIndex: (int i) => index = i);
return index;
}
}
......@@ -81,13 +81,12 @@ Future<void> runSmokeTests({
// A class to hold information related to an example, used to generate names
// from for the tests.
class ExampleInfo {
ExampleInfo(this.file, Directory examplesLibDir)
ExampleInfo(File file, Directory examplesLibDir)
: importPath = _getImportPath(file, examplesLibDir),
importName = '' {
importName = importPath.replaceAll(RegExp(r'\.dart$'), '').replaceAll(RegExp(r'\W'), '_');
}
final File file;
final String importPath;
String importName;
......
......@@ -6,3 +6,5 @@ linter:
rules:
# Samples want to print things pretty often.
avoid_print: false
# Samples are sometimes incomplete and don't show usage of everything.
unreachable_from_main: false
......@@ -139,6 +139,7 @@ Future<int> computeInstanceMethod(int square) {
Future<int> computeInvalidInstanceMethod(int square) {
final ComputeTestSubject subject = ComputeTestSubject(square, ReceivePort());
expect(subject.additional, isA<ReceivePort>());
return compute(subject.method, square);
}
......
......@@ -3256,9 +3256,4 @@ enum TestMenu {
final String acceleratorLabel;
// Strip the accelerator markers.
String get label => MenuAcceleratorLabel.stripAcceleratorMarkers(acceleratorLabel);
int get acceleratorIndex {
int index = -1;
MenuAcceleratorLabel.stripAcceleratorMarkers(acceleratorLabel, setIndex: (int i) => index = i);
return index;
}
}
......@@ -26,8 +26,6 @@ class FakeFrameInfo implements FrameInfo {
@override
Image get image => _image;
int get imageHandleCount => image.debugGetOpenHandleStackTraces()!.length;
FakeFrameInfo clone() {
return FakeFrameInfo(
_duration,
......
......@@ -218,37 +218,13 @@ class SemanticsUpdateBuilderSpy extends Fake implements ui.SemanticsUpdateBuilde
// Makes sure we don't send the same id twice.
assert(!observations.containsKey(id));
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,
labelAttributes: labelAttributes,
hint: hint,
hintAttributes: hintAttributes,
value: value,
valueAttributes: valueAttributes,
increasedValue: increasedValue,
increasedValueAttributes: increasedValueAttributes,
decreasedValue: decreasedValue,
decreasedValueAttributes: decreasedValueAttributes,
textDirection: textDirection,
transform: transform,
childrenInTraversalOrder: childrenInTraversalOrder,
childrenInHitTestOrder: childrenInHitTestOrder,
additionalActions: additionalActions,
);
}
......@@ -262,68 +238,20 @@ class SemanticsUpdateBuilderSpy extends Fake implements ui.SemanticsUpdateBuilde
class 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,
this.labelAttributes,
required this.value,
this.valueAttributes,
required this.increasedValue,
this.increasedValueAttributes,
required this.decreasedValue,
this.decreasedValueAttributes,
required this.hint,
this.hintAttributes,
this.textDirection,
required this.transform,
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 List<StringAttribute>? labelAttributes;
final String value;
final List<StringAttribute>? valueAttributes;
final String increasedValue;
final List<StringAttribute>? increasedValueAttributes;
final String decreasedValue;
final List<StringAttribute>? decreasedValueAttributes;
final String hint;
final List<StringAttribute>? hintAttributes;
final TextDirection? textDirection;
final Float64List transform;
final Int32List childrenInTraversalOrder;
final Int32List childrenInHitTestOrder;
final Int32List additionalActions;
}
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
......@@ -73,29 +71,3 @@ void main() {
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)!;
}
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
class InvalidOnInitLifecycleWidget extends StatefulWidget {
......@@ -25,9 +25,9 @@ class InvalidOnInitLifecycleWidgetState extends State<InvalidOnInitLifecycleWidg
}
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
InvalidDidUpdateWidgetLifecycleWidgetState createState() => InvalidDidUpdateWidgetLifecycleWidgetState();
......@@ -41,7 +41,7 @@ class InvalidDidUpdateWidgetLifecycleWidgetState extends State<InvalidDidUpdateW
@override
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 {
await tester.pumpWidget(const InvalidDidUpdateWidgetLifecycleWidget(id: 1));
await tester.pumpWidget(const InvalidDidUpdateWidgetLifecycleWidget(id: 2));
await tester.pumpWidget(const InvalidDidUpdateWidgetLifecycleWidget(color: Colors.green));
await tester.pumpWidget(const InvalidDidUpdateWidgetLifecycleWidget(color: Colors.red));
expect(tester.takeException(), isFlutterError);
});
......
......@@ -600,23 +600,7 @@ class _AlwaysKeepAliveState extends State<_AlwaysKeepAlive> with AutomaticKeepAl
}
}
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'),
);
}
}
class RenderBoxKeepAlive extends RenderBox { }
mixin KeepAliveParentDataMixinAlt implements KeepAliveParentDataMixin {
@override
......@@ -631,14 +615,6 @@ class RenderSliverMultiBoxAdaptorAlt extends RenderSliver with
RenderSliverHelpers,
RenderSliverWithKeepAliveMixin {
RenderSliverMultiBoxAdaptorAlt({
RenderSliverBoxChildManager? childManager,
}) : _childManager = childManager;
@protected
RenderSliverBoxChildManager? get childManager => _childManager;
final RenderSliverBoxChildManager? _childManager;
final List<RenderBox> children = <RenderBox>[];
void insert(RenderBox child, { RenderBox? after }) {
......
......@@ -30,16 +30,6 @@ class FadeInImageParts {
expect(animatedFadeOutFadeInElement, isNotNull);
return animatedFadeOutFadeInElement!.state;
}
Element? get semanticsElement {
Element? result;
fadeInImageElement.visitChildren((Element child) {
if (child.widget is Semantics) {
result = child;
}
});
return result;
}
}
class FadeInImageElements {
......
......@@ -106,7 +106,7 @@ class _TestWidgetState extends State<TestWidget> {
calledDuringBuild++;
});
return SizedBox.expand(
child: Text(Directionality.of(context).toString()),
child: Text('${widget.value}: ${Directionality.of(context)}'),
);
}
}
......@@ -137,8 +137,8 @@ class SwapperElementWithProperOverrides extends SwapperElement {
}
class RenderSwapper extends RenderBox {
RenderBox? _stable;
RenderBox? get stable => _stable;
RenderBox? _stable;
set stable(RenderBox? child) {
if (child == _stable) {
return;
......@@ -153,8 +153,8 @@ class RenderSwapper extends RenderBox {
}
bool? _swapperIsOnTop;
RenderBox? _swapper;
RenderBox? get swapper => _swapper;
RenderBox? _swapper;
void setSwapper(RenderBox? child, bool isOnTop) {
if (isOnTop != _swapperIsOnTop) {
_swapperIsOnTop = isOnTop;
......@@ -174,11 +174,11 @@ class RenderSwapper extends RenderBox {
@override
void visitChildren(RenderObjectVisitor visitor) {
if (_stable != null) {
visitor(_stable!);
if (stable != null) {
visitor(stable!);
}
if (_swapper != null) {
visitor(_swapper!);
if (swapper != null) {
visitor(swapper!);
}
}
......@@ -210,14 +210,14 @@ class RenderSwapper extends RenderBox {
minHeight: constraints.minHeight / 2,
maxHeight: constraints.maxHeight / 2,
);
if (_stable != null) {
final BoxParentData stableParentData = _stable!.parentData! as BoxParentData;
_stable!.layout(childConstraints);
if (stable != null) {
final BoxParentData stableParentData = stable!.parentData! as BoxParentData;
stable!.layout(childConstraints);
stableParentData.offset = _swapperIsOnTop! ? bottomOffset : topOffset;
}
if (_swapper != null) {
final BoxParentData swapperParentData = _swapper!.parentData! as BoxParentData;
_swapper!.layout(childConstraints);
if (swapper != null) {
final BoxParentData swapperParentData = swapper!.parentData! as BoxParentData;
swapper!.layout(childConstraints);
swapperParentData.offset = _swapperIsOnTop! ? topOffset : bottomOffset;
}
}
......
......@@ -63,10 +63,8 @@ class DummyStatefulWidgetState extends State<DummyStatefulWidget> {
class RekeyableDummyStatefulWidgetWrapper extends StatefulWidget {
const RekeyableDummyStatefulWidgetWrapper({
super.key,
this.child,
required this.initialKey,
});
final Widget? child;
final GlobalKey initialKey;
@override
RekeyableDummyStatefulWidgetWrapperState createState() => RekeyableDummyStatefulWidgetWrapperState();
......
......@@ -1610,10 +1610,6 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit
RouteInformation get routeInformation => _routeInformation;
late RouteInformation _routeInformation;
set routeInformation(RouteInformation newValue) {
_routeInformation = newValue;
notifyListeners();
}
SimpleRouterDelegateBuilder builder;
SimpleNavigatorRouterDelegatePopPage<void> onPopPage;
......@@ -1711,10 +1707,6 @@ class SimpleAsyncRouterDelegate extends RouterDelegate<RouteInformation> with Ch
RouteInformation? get routeInformation => _routeInformation;
RouteInformation? _routeInformation;
set routeInformation(RouteInformation? newValue) {
_routeInformation = newValue;
notifyListeners();
}
SimpleRouterDelegateBuilder builder;
late Future<void> setNewRouteFuture;
......
......@@ -18,7 +18,6 @@ extension on web.CSSRuleList {
Iterable<web.CSSRule> get iterable => _genIterable(this);
}
typedef ItemGetter<T> = T? Function(int index);
Iterable<T> _genIterable<T>(dynamic jsCollection) {
// ignore: avoid_dynamic_calls
return Iterable<T>.generate(jsCollection.length as int, (int index) => jsCollection.item(index) as T,);
......@@ -159,8 +158,7 @@ class RenderSelectionSpy extends RenderProxyBox
}
@override
SelectionGeometry get value => _value;
SelectionGeometry _value = const SelectionGeometry(
final SelectionGeometry value = const SelectionGeometry(
hasContent: true,
status: SelectionStatus.uncollapsed,
startSelectionPoint: SelectionPoint(
......@@ -174,15 +172,6 @@ class RenderSelectionSpy extends RenderProxyBox
handleType: TextSelectionHandleType.left,
),
);
set value(SelectionGeometry other) {
if (other == _value) {
return;
}
_value = other;
for (final VoidCallback callback in listeners) {
callback();
}
}
@override
void pushHandleLayers(LayerLink? startHandle, LayerLink? endHandle) { }
......
......@@ -2526,8 +2526,7 @@ class RenderSelectionSpy extends RenderProxyBox
}
@override
SelectionGeometry get value => _value;
SelectionGeometry _value = const SelectionGeometry(
final SelectionGeometry value = const SelectionGeometry(
hasContent: true,
status: SelectionStatus.uncollapsed,
startSelectionPoint: SelectionPoint(
......@@ -2541,15 +2540,6 @@ class RenderSelectionSpy extends RenderProxyBox
handleType: TextSelectionHandleType.left,
),
);
set value(SelectionGeometry other) {
if (other == _value) {
return;
}
_value = other;
for (final VoidCallback callback in listeners) {
callback();
}
}
@override
void pushHandleLayers(LayerLink? startHandle, LayerLink? endHandle) { }
......
......@@ -96,13 +96,13 @@ class RenderTest extends RenderProxyBox {
void describeSemanticsConfiguration(SemanticsConfiguration config) {
super.describeSemanticsConfiguration(config);
if (!_isSemanticBoundary) {
if (!isSemanticBoundary) {
return;
}
config
..isSemanticBoundary = _isSemanticBoundary
..label = _label
..isSemanticBoundary = isSemanticBoundary
..label = label
..textDirection = TextDirection.ltr;
}
......
......@@ -357,6 +357,6 @@ class RenderTestConfigDelegate extends RenderProxyBox {
@override
void describeSemanticsConfiguration(SemanticsConfiguration config) {
config.childConfigurationsDelegate = _delegate;
config.childConfigurationsDelegate = delegate;
}
}
......@@ -601,18 +601,12 @@ void main() {
testWidgets('Shortcuts.manager lets manager handle shortcuts', (WidgetTester tester) async {
final GlobalKey containerKey = GlobalKey();
final List<LogicalKeyboardKey> pressedKeys = <LogicalKeyboardKey>[];
bool shortcutsSet = false;
void onShortcutsSet() {
shortcutsSet = true;
}
final TestShortcutManager testManager = TestShortcutManager(
pressedKeys,
onShortcutsSet: onShortcutsSet,
shortcuts: <LogicalKeySet, Intent>{
LogicalKeySet(LogicalKeyboardKey.shift): const TestIntent(),
},
);
shortcutsSet = false;
bool invoked = false;
await tester.pumpWidget(
Actions(
......@@ -636,7 +630,6 @@ void main() {
await tester.pump();
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
expect(invoked, isTrue);
expect(shortcutsSet, isFalse);
expect(pressedKeys, equals(<LogicalKeyboardKey>[LogicalKeyboardKey.shiftLeft]));
});
......@@ -1953,10 +1946,9 @@ class TestIntent2 extends Intent {
}
class TestShortcutManager extends ShortcutManager {
TestShortcutManager(this.keys, { super.shortcuts, this.onShortcutsSet });
TestShortcutManager(this.keys, { super.shortcuts });
List<LogicalKeyboardKey> keys;
VoidCallback? onShortcutsSet;
@override
KeyEventResult handleKeypress(BuildContext context, RawKeyEvent event) {
......
......@@ -319,7 +319,7 @@ void main() {
WidgetTest2(text: 'child 2', key: UniqueKey()),
];
await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList),
SwitchingSliverListTest(children: childList),
);
final _WidgetTest0State state0 = tester.state(find.byType(WidgetTest0));
final _WidgetTest1State state1 = tester.state(find.byType(WidgetTest1));
......@@ -330,32 +330,32 @@ void main() {
childList = createSwitchedChildList(childList, 0, 2);
await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList),
SwitchingSliverListTest(children: childList),
);
childList = createSwitchedChildList(childList, 1, 2);
await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList),
SwitchingSliverListTest(children: childList),
);
childList = createSwitchedChildList(childList, 1, 2);
await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList),
SwitchingSliverListTest(children: childList),
);
childList = createSwitchedChildList(childList, 0, 1);
await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList),
SwitchingSliverListTest(children: childList),
);
childList = createSwitchedChildList(childList, 0, 2);
await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList),
SwitchingSliverListTest(children: childList),
);
childList = createSwitchedChildList(childList, 0, 1);
await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList),
SwitchingSliverListTest(children: childList),
);
expect(state0.hasBeenDisposed, false);
expect(state1.hasBeenDisposed, true);
......@@ -369,7 +369,7 @@ void main() {
WidgetTest2(text: 'child 2', key: UniqueKey()),
];
await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList),
SwitchingSliverListTest(children: childList),
);
final _WidgetTest0State state0 = tester.state(find.byType(WidgetTest0));
final _WidgetTest1State state1 = tester.state(find.byType(WidgetTest1));
......@@ -381,7 +381,7 @@ void main() {
childList = createSwitchedChildList(childList, 0, 1);
childList.removeAt(2);
await tester.pumpWidget(
SwitchingSliverListTest(viewportFraction: 0.1, children: childList),
SwitchingSliverListTest(children: childList),
);
expect(find.text('child 0'), findsOneWidget);
expect(find.text('child 1'), findsOneWidget);
......@@ -505,12 +505,10 @@ class SwitchingChildListTest extends StatelessWidget {
class SwitchingSliverListTest extends StatelessWidget {
const SwitchingSliverListTest({
required this.children,
this.viewportFraction = 1.0,
super.key,
});
final List<Widget> children;
final double viewportFraction;
@override
Widget build(BuildContext context) {
......
......@@ -335,10 +335,6 @@ class TestPainter extends SnapshotPainter {
super.removeListener(listener);
}
void notify() {
notifyListeners();
}
@override
void paintSnapshot(PaintingContext context, Offset offset, Size size, ui.Image image, Size sourceSize, double pixelRatio) {
count += 1;
......
......@@ -195,7 +195,13 @@ class TestCase {
// Use Flutter's analysis_options.yaml file from packages/flutter.
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;
}
......
......@@ -243,7 +243,6 @@ void main() {
class TestObserver with WidgetsBindingObserver {
List<Locale>? locales;
Locale? locale;
@override
void didChangeLocales(List<Locale>? locales) {
......
......@@ -63,11 +63,6 @@ class Context {
}
}
bool existsDir(String path) {
final Directory dir = Directory(path);
return dir.existsSync();
}
bool existsFile(String path) {
final File file = File(path);
return file.existsSync();
......
......@@ -105,7 +105,6 @@ void main() {
testUsingContext('succeeds with iOS device with protocol discovery', () async {
final FakeIOSDevice device = FakeIOSDevice(
logReader: fakeLogReader,
portForwarder: portForwarder,
majorSdkVersion: 12,
onGetLogReader: () {
......@@ -167,7 +166,6 @@ void main() {
testUsingContext('succeeds with iOS device with mDNS', () async {
final FakeIOSDevice device = FakeIOSDevice(
logReader: fakeLogReader,
portForwarder: portForwarder,
majorSdkVersion: 16,
onGetLogReader: () {
......@@ -237,7 +235,6 @@ void main() {
testUsingContext('succeeds with iOS device with mDNS wireless device', () async {
final FakeIOSDevice device = FakeIOSDevice(
logReader: fakeLogReader,
portForwarder: portForwarder,
majorSdkVersion: 16,
connectionInterface: DeviceConnectionInterface.wireless,
......@@ -309,7 +306,6 @@ void main() {
testUsingContext('succeeds with iOS device with mDNS wireless device with debug-port', () async {
final FakeIOSDevice device = FakeIOSDevice(
logReader: fakeLogReader,
portForwarder: portForwarder,
majorSdkVersion: 16,
connectionInterface: DeviceConnectionInterface.wireless,
......@@ -385,7 +381,6 @@ void main() {
testUsingContext('succeeds with iOS device with mDNS wireless device with debug-url', () async {
final FakeIOSDevice device = FakeIOSDevice(
logReader: fakeLogReader,
portForwarder: portForwarder,
majorSdkVersion: 16,
connectionInterface: DeviceConnectionInterface.wireless,
......@@ -619,7 +614,6 @@ void main() {
testUsingContext('succeeds when ipv6 is specified and debug-port is not on iOS device', () async {
final FakeIOSDevice device = FakeIOSDevice(
logReader: fakeLogReader,
portForwarder: portForwarder,
majorSdkVersion: 12,
onGetLogReader: () {
......@@ -1350,11 +1344,10 @@ class FakeAndroidDevice extends Fake implements AndroidDevice {
class FakeIOSDevice extends Fake implements IOSDevice {
FakeIOSDevice({
DevicePortForwarder? portForwarder,
DeviceLogReader? logReader,
this.onGetLogReader,
this.connectionInterface = DeviceConnectionInterface.attached,
this.majorSdkVersion = 0,
}) : _portForwarder = portForwarder, _logReader = logReader;
}) : _portForwarder = portForwarder;
final DevicePortForwarder? _portForwarder;
@override
......@@ -1373,9 +1366,6 @@ class FakeIOSDevice extends Fake implements IOSDevice {
@override
DartDevelopmentService get dds => throw UnimplementedError('getter dds not implemented');
final DeviceLogReader? _logReader;
DeviceLogReader get logReader => _logReader!;
final DeviceLogReader Function()? onGetLogReader;
@override
......@@ -1470,11 +1460,9 @@ class FakeMDnsClient extends Fake implements MDnsClient {
}
class TestDeviceManager extends DeviceManager {
TestDeviceManager({required this.logger}) : super(logger: logger);
TestDeviceManager({required super.logger});
List<Device> devices = <Device>[];
final BufferLogger logger;
@override
List<DeviceDiscovery> get deviceDiscoverers {
final FakePollingDeviceDiscovery discoverer = FakePollingDeviceDiscovery();
......
......@@ -19,9 +19,7 @@ import '../../src/test_flutter_command_runner.dart';
import '../../src/testbed.dart';
class FakePub extends Fake implements Pub {
FakePub(this.fs);
final FileSystem fs;
int calledGetOffline = 0;
int calledOnline = 0;
......@@ -59,7 +57,7 @@ void main() {
setUp(() {
testbed = Testbed(setup: () {
fakePub = FakePub(globals.fs);
fakePub = FakePub();
Cache.flutterRoot = 'flutter';
final List<String> filePaths = <String>[
globals.fs.path.join('flutter', 'packages', 'flutter', 'pubspec.yaml'),
......
......@@ -831,41 +831,6 @@ class FakeAndroidWorkflow extends Fake implements AndroidWorkflow {
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 {
PassingValidator(super.title);
......
......@@ -1148,11 +1148,9 @@ void main() {
}
class TestDeviceManager extends DeviceManager {
TestDeviceManager({required this.logger}) : super(logger: logger);
TestDeviceManager({required super.logger});
List<Device> devices = <Device>[];
final Logger logger;
@override
List<DeviceDiscovery> get deviceDiscoverers {
final FakePollingDeviceDiscovery discoverer = FakePollingDeviceDiscovery();
......
......@@ -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/top_level_gradle_build_file_migration.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/project.dart';
import 'package:test/fake.dart';
......@@ -287,8 +284,3 @@ class FakeErroringJava extends FakeJava {
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 {}
......@@ -4,12 +4,10 @@
import 'package:file/memory.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/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:test/fake.dart';
import '../../src/common.dart';
import '../../src/context.dart';
......@@ -424,13 +422,3 @@ ro.build.version.incremental=1624448
ro.build.version.sdk=24
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;
}
......@@ -371,7 +371,7 @@ void main() {
});
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 BufferLogger logger = BufferLogger.test();
final ArtifactUpdater artifactUpdater = ArtifactUpdater(
......@@ -421,7 +421,7 @@ void main() {
});
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 BufferLogger logger = BufferLogger.test();
final ArtifactUpdater artifactUpdater = ArtifactUpdater(
......@@ -529,10 +529,7 @@ void main() {
}
class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
FakeOperatingSystemUtils({this.windows = false});
int failures = 0;
final bool windows;
/// A mapping of zip [file] paths to callbacks that receive the [targetDirectory].
///
......
......@@ -1204,7 +1204,7 @@ class FakeSimControl extends Fake implements SimControl {
@override
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']);
}
......@@ -1215,9 +1215,8 @@ class FakeSimControl extends Fake implements SimControl {
}
class LaunchRequest {
const LaunchRequest(this.deviceId, this.appIdentifier, this.launchArgs);
const LaunchRequest(this.appIdentifier, this.launchArgs);
final String deviceId;
final String appIdentifier;
final List<String>? launchArgs;
}
......@@ -1496,7 +1496,6 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler { }
class TestRunner extends Fake implements ResidentRunner {
bool hasHelpBeenPrinted = false;
String? receivedCommand;
@override
Future<void> cleanupAfterSignal() async { }
......
......@@ -1211,11 +1211,9 @@ class FakeShaderCompiler implements DevelopmentShaderCompiler {
}
class FakeDwds extends Fake implements Dwds {
FakeDwds(this.connectedAppsIterable) :
FakeDwds(Iterable<AppConnection> connectedAppsIterable) :
connectedApps = Stream<AppConnection>.fromIterable(connectedAppsIterable);
final Iterable<AppConnection> connectedAppsIterable;
@override
final Stream<AppConnection> connectedApps;
......
......@@ -394,12 +394,6 @@ void main() {
class TestChromiumLauncher implements ChromiumLauncher {
TestChromiumLauncher();
bool _hasInstance = false;
void setInstance(Chromium chromium) {
_hasInstance = true;
currentCompleter.complete(chromium);
}
@override
Completer<Chromium> currentCompleter = Completer<Chromium>();
......@@ -417,7 +411,7 @@ class TestChromiumLauncher implements ChromiumLauncher {
}
@override
bool get hasChromeInstance => _hasInstance;
bool get hasChromeInstance => false;
@override
Future<Chromium> launch(
......
......@@ -234,11 +234,6 @@ class TestContext extends Context {
String stdout = '';
String stderr = '';
@override
bool existsDir(String path) {
return fileSystem.directory(path).existsSync();
}
@override
bool existsFile(String path) {
return fileSystem.file(path).existsSync();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment