Enable avoid_setters_without_getters (#91067)
diff --git a/analysis_options.yaml b/analysis_options.yaml
index fbafb20..cf2ef0a 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -81,11 +81,11 @@
- avoid_relative_lib_imports
- avoid_renaming_method_parameters
- avoid_return_types_on_setters
- # - avoid_returning_null # there are plenty of valid reasons to return null
- # - avoid_returning_null_for_future # not yet tested
+ # - avoid_returning_null # still violated by some pre-nnbd code that we haven't yet migrated
+ - avoid_returning_null_for_future
- avoid_returning_null_for_void
# - avoid_returning_this # there are plenty of valid reasons to return this
- # - avoid_setters_without_getters # not yet tested
+ - avoid_setters_without_getters
- avoid_shadowing_type_parameters
- avoid_single_cascade_in_expression_statements
- avoid_slow_async_io
diff --git a/packages/flutter/lib/src/cupertino/dialog.dart b/packages/flutter/lib/src/cupertino/dialog.dart
index b17f465..e1b051d 100644
--- a/packages/flutter/lib/src/cupertino/dialog.dart
+++ b/packages/flutter/lib/src/cupertino/dialog.dart
@@ -2012,6 +2012,7 @@
markNeedsLayout();
}
+ Color get dialogColor => _buttonBackgroundPaint.color;
final Paint _buttonBackgroundPaint;
set dialogColor(Color value) {
if (value == _buttonBackgroundPaint.color)
@@ -2021,6 +2022,7 @@
markNeedsPaint();
}
+ Color get dialogPressedColor => _pressedButtonBackgroundPaint.color;
final Paint _pressedButtonBackgroundPaint;
set dialogPressedColor(Color value) {
if (value == _pressedButtonBackgroundPaint.color)
@@ -2030,6 +2032,7 @@
markNeedsPaint();
}
+ Color get dividerColor => _dividerPaint.color;
final Paint _dividerPaint;
set dividerColor(Color value) {
if (value == _dividerPaint.color)
@@ -2039,8 +2042,8 @@
markNeedsPaint();
}
- bool _isActionSheet;
bool get isActionSheet => _isActionSheet;
+ bool _isActionSheet;
set isActionSheet(bool value) {
if (value == _isActionSheet)
return;
diff --git a/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart b/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart
index 42873fd..fe3486c 100644
--- a/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart
+++ b/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart
@@ -196,6 +196,7 @@
@override
bool get isRepaintBoundary => true;
+ Offset get anchor => _anchor;
Offset _anchor;
set anchor(Offset value) {
if (value == _anchor) {
@@ -205,6 +206,7 @@
markNeedsLayout();
}
+ bool get isAbove => _isAbove;
bool _isAbove;
set isAbove(bool value) {
if (_isAbove == value) {
diff --git a/packages/flutter/lib/src/rendering/platform_view.dart b/packages/flutter/lib/src/rendering/platform_view.dart
index 32df660..b2ba746 100644
--- a/packages/flutter/lib/src/rendering/platform_view.dart
+++ b/packages/flutter/lib/src/rendering/platform_view.dart
@@ -13,7 +13,6 @@
import 'layer.dart';
import 'object.dart';
-
/// How an embedded platform view behave during hit tests.
enum PlatformViewHitTestBehavior {
/// Opaque targets can be hit by hit tests, causing them to both receive
@@ -75,7 +74,6 @@
/// * [AndroidView] which is a widget that is used to show an Android view.
/// * [PlatformViewsService] which is a service for controlling platform views.
class RenderAndroidView extends RenderBox with _PlatformViewGestureMixin {
-
/// Creates a render object for an Android view.
RenderAndroidView({
required AndroidViewController viewController,
@@ -97,7 +95,7 @@
_PlatformViewState _state = _PlatformViewState.uninitialized;
/// The Android view controller for the Android view associated with this render object.
- AndroidViewController get viewcontroller => _viewController;
+ AndroidViewController get viewController => _viewController;
AndroidViewController _viewController;
/// Sets a new Android view controller.
///
@@ -451,7 +449,6 @@
).toSet();
}
-
// We use OneSequenceGestureRecognizers as they support gesture arena teams.
// TODO(amirh): get a list of GestureRecognizers here.
// https://github.com/flutter/flutter/issues/20953
@@ -615,7 +612,6 @@
/// [PlatformViewRenderBox] presents a platform view by adding a [PlatformViewLayer] layer,
/// integrates it with the gesture arenas system and adds relevant semantic nodes to the semantics tree.
class PlatformViewRenderBox extends RenderBox with _PlatformViewGestureMixin {
-
/// Creating a render object for a [PlatformViewSurface].
///
/// The `controller` parameter must not be null.
@@ -631,8 +627,9 @@
updateGestureRecognizers(gestureRecognizers);
}
- /// Sets the [controller] for this render object.
- ///
+ /// The controller for this render object.
+ PlatformViewController get controller => _controller;
+ PlatformViewController _controller;
/// This value must not be null, and setting it to a new value will result in a repaint.
set controller(PlatformViewController controller) {
assert(controller != null);
@@ -657,8 +654,6 @@
_updateGestureRecognizersWithCallBack(gestureRecognizers, _controller.dispatchPointerEvent);
}
- PlatformViewController _controller;
-
@override
bool get sizedByParent => true;
diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart
index cf28cdb..8df38b0 100644
--- a/packages/flutter/lib/src/rendering/proxy_box.dart
+++ b/packages/flutter/lib/src/rendering/proxy_box.dart
@@ -2265,11 +2265,14 @@
/// always honor the transformation, regardless of the value of this property.
bool transformHitTests;
- // Note the lack of a getter for transform because Matrix4 is not immutable
Matrix4? _transform;
-
- /// The matrix to transform the child by during painting.
- set transform(Matrix4 value) {
+ /// The matrix to transform the child by during painting. The provided value
+ /// is copied on assignment.
+ ///
+ /// There is no getter for [transform], because [Matrix4] is mutable, and
+ /// mutations outside of the control of the render object could not reliably
+ /// be reflected in the rendering.
+ set transform(Matrix4 value) { // ignore: avoid_setters_without_getters
assert(value != null);
if (_transform == value)
return;
diff --git a/packages/flutter/lib/src/services/platform_views.dart b/packages/flutter/lib/src/services/platform_views.dart
index ef7dfba..2a3bf8c 100644
--- a/packages/flutter/lib/src/services/platform_views.dart
+++ b/packages/flutter/lib/src/services/platform_views.dart
@@ -522,8 +522,8 @@
<int, AndroidPointerProperties>{};
final Set<int> usedAndroidPointerIds = <int>{};
+ PointTransformer get pointTransformer => _pointTransformer;
late PointTransformer _pointTransformer;
-
set pointTransformer(PointTransformer transformer) {
assert(transformer != null);
_pointTransformer = transformer;
@@ -813,10 +813,12 @@
);
}
- /// Converts a given point from the global coordinate system in logical pixels to the local coordinate system for this box.
+ /// Converts a given point from the global coordinate system in logical pixels
+ /// to the local coordinate system for this box.
///
/// This is required to convert a [PointerEvent] to an [AndroidMotionEvent].
/// It is typically provided by using [RenderBox.globalToLocal].
+ PointTransformer get pointTransformer => _motionEventConverter._pointTransformer;
set pointTransformer(PointTransformer transformer) {
assert(transformer != null);
_motionEventConverter._pointTransformer = transformer;
@@ -1146,18 +1148,17 @@
}
}
-/// An interface for a controlling a single platform view.
+/// An interface for controlling a single platform view.
///
/// Used by [PlatformViewSurface] to interface with the platform view it embeds.
abstract class PlatformViewController {
-
/// The viewId associated with this controller.
///
- /// The viewId should always be unique and non-negative. And it must not be null.
+ /// The viewId should always be unique and non-negative.
///
/// See also:
///
- /// * [PlatformViewsRegistry], which is a helper for managing platform view ids.
+ /// * [PlatformViewsRegistry], which is a helper for managing platform view IDs.
int get viewId;
/// Dispatches the `event` to the platform view.
diff --git a/packages/flutter/lib/src/widgets/actions.dart b/packages/flutter/lib/src/widgets/actions.dart
index 2061123..002b9c3 100644
--- a/packages/flutter/lib/src/widgets/actions.dart
+++ b/packages/flutter/lib/src/widgets/actions.dart
@@ -160,13 +160,10 @@
final ObserverList<ActionListenerCallback> _listeners = ObserverList<ActionListenerCallback>();
Action<T>? _currentCallingAction;
- set _callingAction(Action<T>? newAction) {
- if (newAction == _currentCallingAction) {
- return;
- }
- assert(newAction == null || _currentCallingAction == null);
- _currentCallingAction = newAction;
+ void _updateCallingAction(Action<T>? value) {
+ _currentCallingAction = value;
}
+
/// The [Action] overridden by this [Action].
///
/// The [Action.overridable] constructor creates an overridable [Action] that
@@ -1526,9 +1523,9 @@
}
@override
- set _callingAction(Action<T>? newAction) {
- super._callingAction = newAction;
- defaultAction._callingAction = newAction;
+ void _updateCallingAction(Action<T>? value) {
+ super._updateCallingAction(value);
+ defaultAction._updateCallingAction(value);
}
Object? _invokeOverride(Action<T> overrideAction, T intent, BuildContext? context) {
@@ -1537,11 +1534,11 @@
debugAssertMutuallyRecursive = true;
return true;
}());
- overrideAction._callingAction = defaultAction;
+ overrideAction._updateCallingAction(defaultAction);
final Object? returnValue = overrideAction is ContextAction<T>
? overrideAction.invoke(intent, context)
: overrideAction.invoke(intent);
- overrideAction._callingAction = null;
+ overrideAction._updateCallingAction(null);
assert(() {
debugAssertMutuallyRecursive = false;
return true;
@@ -1564,9 +1561,9 @@
debugAssertIsActionEnabledMutuallyRecursive = true;
return true;
}());
- overrideAction._callingAction = defaultAction;
+ overrideAction._updateCallingAction(defaultAction);
final bool isOverrideEnabled = overrideAction.isActionEnabled;
- overrideAction._callingAction = null;
+ overrideAction._updateCallingAction(null);
assert(() {
debugAssertIsActionEnabledMutuallyRecursive = false;
return true;
@@ -1592,9 +1589,9 @@
}());
final Action<T>? overrideAction = getOverrideAction();
- overrideAction?._callingAction = defaultAction;
+ overrideAction?._updateCallingAction(defaultAction);
final bool returnValue = (overrideAction ?? defaultAction).isEnabled(intent);
- overrideAction?._callingAction = null;
+ overrideAction?._updateCallingAction(null);
assert(() {
debugAssertIsEnabledMutuallyRecursive = false;
return true;
@@ -1610,9 +1607,9 @@
return true;
}());
final Action<T>? overrideAction = getOverrideAction();
- overrideAction?._callingAction = defaultAction;
+ overrideAction?._updateCallingAction(defaultAction);
final bool isEnabled = (overrideAction ?? defaultAction).consumesKey(intent);
- overrideAction?._callingAction = null;
+ overrideAction?._updateCallingAction(null);
assert(() {
debugAssertConsumeKeyMutuallyRecursive = false;
return true;
@@ -1674,11 +1671,11 @@
// overrideAction is not a ContextAction and thus have no access to the
// calling BuildContext.
final Action<T> wrappedDefault = _ContextActionToActionAdapter<T>(invokeContext: context!, action: defaultAction);
- overrideAction._callingAction = wrappedDefault;
+ overrideAction._updateCallingAction(wrappedDefault);
final Object? returnValue = overrideAction is ContextAction<T>
? overrideAction.invoke(intent, context)
: overrideAction.invoke(intent);
- overrideAction._callingAction = null;
+ overrideAction._updateCallingAction(null);
assert(() {
debugAssertMutuallyRecursive = false;
@@ -1710,8 +1707,8 @@
final ContextAction<T> action;
@override
- set _callingAction(Action<T>? newAction) {
- action._callingAction = newAction;
+ void _updateCallingAction(Action<T>? value) {
+ action._updateCallingAction(value);
}
@override
diff --git a/packages/flutter/test/services/fake_platform_views.dart b/packages/flutter/test/services/fake_platform_views.dart
index dec83b3..bdd1876 100644
--- a/packages/flutter/test/services/fake_platform_views.dart
+++ b/packages/flutter/test/services/fake_platform_views.dart
@@ -59,7 +59,7 @@
final int viewId;
@override
- Offset Function(Offset position)? pointTransformer;
+ late PointTransformer pointTransformer;
@override
Future<void> dispatchPointerEvent(PointerEvent event) async {
diff --git a/packages/flutter/test/widgets/semantics_10_test.dart b/packages/flutter/test/widgets/semantics_10_test.dart
index def948a..61b4983 100644
--- a/packages/flutter/test/widgets/semantics_10_test.dart
+++ b/packages/flutter/test/widgets/semantics_10_test.dart
@@ -92,7 +92,6 @@
}
class RenderTest extends RenderProxyBox {
-
@override
void describeSemanticsConfiguration(SemanticsConfiguration config) {
super.describeSemanticsConfiguration(config);
@@ -107,6 +106,7 @@
}
+ String get label => _label;
String _label = '<>';
set label(String value) {
if (value == _label)
@@ -116,6 +116,7 @@
}
+ bool get isSemanticBoundary => _isSemanticBoundary;
bool _isSemanticBoundary = false;
set isSemanticBoundary(bool value) {
if (_isSemanticBoundary == value)
diff --git a/packages/flutter_test/lib/src/_binding_io.dart b/packages/flutter_test/lib/src/_binding_io.dart
index f09b3e1..1a0f5c6 100644
--- a/packages/flutter_test/lib/src/_binding_io.dart
+++ b/packages/flutter_test/lib/src/_binding_io.dart
@@ -120,13 +120,13 @@
void addProxyCredentials(String host, int port, String realm, HttpClientCredentials credentials) { }
@override
- set authenticate(Future<bool> Function(Uri url, String scheme, String realm)? f) { }
+ Future<bool> Function(Uri url, String scheme, String realm)? authenticate;
@override
- set authenticateProxy(Future<bool> Function(String host, int port, String scheme, String realm)? f) { }
+ Future<bool> Function(String host, int port, String scheme, String realm)? authenticateProxy;
@override
- set badCertificateCallback(bool Function(X509Certificate cert, String host, int port)? callback) { }
+ bool Function(X509Certificate cert, String host, int port)? badCertificateCallback;
@override
void close({ bool force = false }) { }
@@ -142,7 +142,7 @@
}
@override
- set findProxy(String Function(Uri url)? f) { }
+ String Function(Uri url)? findProxy;
@override
Future<HttpClientRequest> get(String host, int port, String path) {
diff --git a/packages/flutter_test/lib/src/window.dart b/packages/flutter_test/lib/src/window.dart
index 82bc78e..c1e7067 100644
--- a/packages/flutter_test/lib/src/window.dart
+++ b/packages/flutter_test/lib/src/window.dart
@@ -59,7 +59,7 @@
double? _devicePixelRatio;
/// Hides the real device pixel ratio and reports the given [devicePixelRatio]
/// instead.
- set devicePixelRatioTestValue(double devicePixelRatio) {
+ set devicePixelRatioTestValue(double devicePixelRatio) { // ignore: avoid_setters_without_getters
_devicePixelRatio = devicePixelRatio;
onMetricsChanged?.call();
}
@@ -75,7 +75,7 @@
ui.Size? _physicalSizeTestValue;
/// Hides the real physical size and reports the given [physicalSizeTestValue]
/// instead.
- set physicalSizeTestValue (ui.Size physicalSizeTestValue) {
+ set physicalSizeTestValue (ui.Size physicalSizeTestValue) { // ignore: avoid_setters_without_getters
_physicalSizeTestValue = physicalSizeTestValue;
onMetricsChanged?.call();
}
@@ -91,7 +91,7 @@
ui.WindowPadding? _viewInsetsTestValue;
/// Hides the real view insets and reports the given [viewInsetsTestValue]
/// instead.
- set viewInsetsTestValue(ui.WindowPadding viewInsetsTestValue) {
+ set viewInsetsTestValue(ui.WindowPadding viewInsetsTestValue) { // ignore: avoid_setters_without_getters
_viewInsetsTestValue = viewInsetsTestValue;
onMetricsChanged?.call();
}
@@ -107,7 +107,7 @@
ui.WindowPadding? _viewPaddingTestValue;
/// Hides the real view padding and reports the given [paddingTestValue]
/// instead.
- set viewPaddingTestValue(ui.WindowPadding viewPaddingTestValue) {
+ set viewPaddingTestValue(ui.WindowPadding viewPaddingTestValue) { // ignore: avoid_setters_without_getters
_viewPaddingTestValue = viewPaddingTestValue;
onMetricsChanged?.call();
}
@@ -122,7 +122,7 @@
ui.WindowPadding get padding => _paddingTestValue ?? _window.padding;
ui.WindowPadding? _paddingTestValue;
/// Hides the real padding and reports the given [paddingTestValue] instead.
- set paddingTestValue(ui.WindowPadding paddingTestValue) {
+ set paddingTestValue(ui.WindowPadding paddingTestValue) { // ignore: avoid_setters_without_getters
_paddingTestValue = paddingTestValue;
onMetricsChanged?.call();
}
@@ -136,7 +136,7 @@
ui.WindowPadding get systemGestureInsets => _systemGestureInsetsTestValue ?? _window.systemGestureInsets;
ui.WindowPadding? _systemGestureInsetsTestValue;
/// Hides the real system gesture insets and reports the given [systemGestureInsetsTestValue] instead.
- set systemGestureInsetsTestValue(ui.WindowPadding systemGestureInsetsTestValue) {
+ set systemGestureInsetsTestValue(ui.WindowPadding systemGestureInsetsTestValue) { // ignore: avoid_setters_without_getters
_systemGestureInsetsTestValue = systemGestureInsetsTestValue;
onMetricsChanged?.call();
}
@@ -157,7 +157,7 @@
ui.Locale get locale => _localeTestValue ?? platformDispatcher.locale;
ui.Locale? _localeTestValue;
/// Hides the real locale and reports the given [localeTestValue] instead.
- set localeTestValue(ui.Locale localeTestValue) {
+ set localeTestValue(ui.Locale localeTestValue) { // ignore: avoid_setters_without_getters
_localeTestValue = localeTestValue;
onLocaleChanged?.call();
}
@@ -171,7 +171,7 @@
List<ui.Locale> get locales => _localesTestValue ?? platformDispatcher.locales;
List<ui.Locale>? _localesTestValue;
/// Hides the real locales and reports the given [localesTestValue] instead.
- set localesTestValue(List<ui.Locale> localesTestValue) {
+ set localesTestValue(List<ui.Locale> localesTestValue) { // ignore: avoid_setters_without_getters
_localesTestValue = localesTestValue;
onLocaleChanged?.call();
}
@@ -192,7 +192,7 @@
String get initialLifecycleState => _initialLifecycleStateTestValue;
String _initialLifecycleStateTestValue = '';
/// Sets a faked initialLifecycleState for testing.
- set initialLifecycleStateTestValue(String state) {
+ set initialLifecycleStateTestValue(String state) { // ignore: avoid_setters_without_getters
_initialLifecycleStateTestValue = state;
}
@@ -201,7 +201,7 @@
double? _textScaleFactorTestValue;
/// Hides the real text scale factor and reports the given
/// [textScaleFactorTestValue] instead.
- set textScaleFactorTestValue(double textScaleFactorTestValue) {
+ set textScaleFactorTestValue(double textScaleFactorTestValue) { // ignore: avoid_setters_without_getters
_textScaleFactorTestValue = textScaleFactorTestValue;
onTextScaleFactorChanged?.call();
}
@@ -223,7 +223,7 @@
}
/// Hides the real text scale factor and reports the given
/// [platformBrightnessTestValue] instead.
- set platformBrightnessTestValue(ui.Brightness platformBrightnessTestValue) {
+ set platformBrightnessTestValue(ui.Brightness platformBrightnessTestValue) { // ignore: avoid_setters_without_getters
_platformBrightnessTestValue = platformBrightnessTestValue;
onPlatformBrightnessChanged?.call();
}
@@ -239,7 +239,7 @@
bool? _alwaysUse24HourFormatTestValue;
/// Hides the real clock format and reports the given
/// [alwaysUse24HourFormatTestValue] instead.
- set alwaysUse24HourFormatTestValue(bool alwaysUse24HourFormatTestValue) {
+ set alwaysUse24HourFormatTestValue(bool alwaysUse24HourFormatTestValue) { // ignore: avoid_setters_without_getters
_alwaysUse24HourFormatTestValue = alwaysUse24HourFormatTestValue;
}
/// Deletes any existing test clock format and returns to using the real clock
@@ -288,7 +288,7 @@
String? _defaultRouteNameTestValue;
/// Hides the real default route name and reports the given
/// [defaultRouteNameTestValue] instead.
- set defaultRouteNameTestValue(String defaultRouteNameTestValue) {
+ set defaultRouteNameTestValue(String defaultRouteNameTestValue) { // ignore: avoid_setters_without_getters
_defaultRouteNameTestValue = defaultRouteNameTestValue;
}
/// Deletes any existing test default route name and returns to using the real
@@ -312,7 +312,7 @@
bool? _semanticsEnabledTestValue;
/// Hides the real semantics enabled and reports the given
/// [semanticsEnabledTestValue] instead.
- set semanticsEnabledTestValue(bool semanticsEnabledTestValue) {
+ set semanticsEnabledTestValue(bool semanticsEnabledTestValue) { // ignore: avoid_setters_without_getters
_semanticsEnabledTestValue = semanticsEnabledTestValue;
onSemanticsEnabledChanged?.call();
}
@@ -342,7 +342,7 @@
ui.AccessibilityFeatures? _accessibilityFeaturesTestValue;
/// Hides the real accessibility features and reports the given
/// [accessibilityFeaturesTestValue] instead.
- set accessibilityFeaturesTestValue(ui.AccessibilityFeatures accessibilityFeaturesTestValue) {
+ set accessibilityFeaturesTestValue(ui.AccessibilityFeatures accessibilityFeaturesTestValue) { // ignore: avoid_setters_without_getters
_accessibilityFeaturesTestValue = accessibilityFeaturesTestValue;
onAccessibilityFeaturesChanged?.call();
}
@@ -358,7 +358,7 @@
ui.ViewConfiguration? _viewConfiguration;
/// Hide the real view configuration and report the provided [value] instead.
- set viewConfigurationTestValue(ui.ViewConfiguration? value) {
+ set viewConfigurationTestValue(ui.ViewConfiguration? value) { // ignore: avoid_setters_without_getters
_viewConfiguration = value;
onMetricsChanged?.call();
}
diff --git a/packages/flutter_tools/lib/src/base/bot_detector.dart b/packages/flutter_tools/lib/src/base/bot_detector.dart
index ddd797d..50bb84e 100644
--- a/packages/flutter_tools/lib/src/base/bot_detector.dart
+++ b/packages/flutter_tools/lib/src/base/bot_detector.dart
@@ -37,14 +37,15 @@
// When set, GA logs to a local file (normally for tests) so we don't need to filter.
|| _platform.environment.containsKey('FLUTTER_ANALYTICS_LOG_FILE')
) {
- return _persistentToolState.runningOnBot = false;
+ _persistentToolState.setIsRunningOnBot(false);
+ return false;
}
if (_persistentToolState.isRunningOnBot != null) {
return _persistentToolState.isRunningOnBot!;
}
- return _persistentToolState.runningOnBot = _platform.environment['BOT'] == 'true'
+ final bool result = _platform.environment['BOT'] == 'true'
// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
|| _platform.environment['TRAVIS'] == 'true'
@@ -77,6 +78,9 @@
// Property when running on Azure.
|| await _azureDetector.isRunningOnAzure;
+
+ _persistentToolState.setIsRunningOnBot(result);
+ return result;
}
}
diff --git a/packages/flutter_tools/lib/src/base/terminal.dart b/packages/flutter_tools/lib/src/base/terminal.dart
index d95c5ff..6589b24 100644
--- a/packages/flutter_tools/lib/src/base/terminal.dart
+++ b/packages/flutter_tools/lib/src/base/terminal.dart
@@ -111,6 +111,7 @@
String clearScreen();
+ bool get singleCharMode;
set singleCharMode(bool value);
/// Return keystrokes from the console.
@@ -270,6 +271,14 @@
String clearScreen() => supportsColor ? clear : '\n\n';
@override
+ bool get singleCharMode {
+ if (!_stdio.stdinHasTerminal) {
+ return false;
+ }
+ final io.Stdin stdin = _stdio.stdin as io.Stdin;
+ return stdin.lineMode && stdin.echoMode;
+ }
+ @override
set singleCharMode(bool value) {
if (!_stdio.stdinHasTerminal) {
return;
@@ -366,6 +375,8 @@
}
@override
+ bool get singleCharMode => false;
+ @override
set singleCharMode(bool value) { }
@override
diff --git a/packages/flutter_tools/lib/src/commands/upgrade.dart b/packages/flutter_tools/lib/src/commands/upgrade.dart
index 421b902..9b5c6d0 100644
--- a/packages/flutter_tools/lib/src/commands/upgrade.dart
+++ b/packages/flutter_tools/lib/src/commands/upgrade.dart
@@ -198,12 +198,12 @@
// re-entrantly with the `--continue` flag
Future<void> runCommandSecondHalf(FlutterVersion flutterVersion) async {
// Make sure the welcome message re-display is delayed until the end.
- globals.persistentToolState.redisplayWelcomeMessage = false;
+ globals.persistentToolState.setShouldRedisplayWelcomeMessage(false);
await precacheArtifacts();
await updatePackages(flutterVersion);
await runDoctor();
// Force the welcome message to re-display following the upgrade.
- globals.persistentToolState.redisplayWelcomeMessage = true;
+ globals.persistentToolState.setShouldRedisplayWelcomeMessage(true);
}
Future<bool> hasUncommittedChanges() async {
diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart
index 3b5a0af..a86b1cd 100644
--- a/packages/flutter_tools/lib/src/ios/devices.dart
+++ b/packages/flutter_tools/lib/src/ios/devices.dart
@@ -704,6 +704,7 @@
}
/// Log reader will listen to [debugger.logLines] and will detach debugger on dispose.
+ IOSDeployDebugger get debuggerStream => _iosDeployDebugger;
set debuggerStream(IOSDeployDebugger debugger) {
// Logging is gathered from syslog on iOS 13 and earlier.
if (_majorSdkVersion < minimumUniversalLoggingSdkVersion) {
@@ -736,14 +737,13 @@
_linesController.close();
}
});
- assert(_idevicesyslogProcess == null);
- _idevicesyslogProcess = process;
+ assert(idevicesyslogProcess == null);
+ idevicesyslogProcess = process;
});
}
@visibleForTesting
- set idevicesyslogProcess(Process process) => _idevicesyslogProcess = process;
- Process _idevicesyslogProcess;
+ Process idevicesyslogProcess;
// Returns a stateful line handler to properly capture multiline output.
//
@@ -781,7 +781,7 @@
for (final StreamSubscription<void> loggingSubscription in _loggingSubscriptions) {
loggingSubscription.cancel();
}
- _idevicesyslogProcess?.kill();
+ idevicesyslogProcess?.kill();
_iosDeployDebugger?.detach();
}
}
diff --git a/packages/flutter_tools/lib/src/persistent_tool_state.dart b/packages/flutter_tools/lib/src/persistent_tool_state.dart
index e3b021c..cdccc3b 100644
--- a/packages/flutter_tools/lib/src/persistent_tool_state.dart
+++ b/packages/flutter_tools/lib/src/persistent_tool_state.dart
@@ -38,7 +38,7 @@
///
/// May give null if the value has not been set.
bool? get shouldRedisplayWelcomeMessage;
- set redisplayWelcomeMessage(bool value); // Enforced nonnull setter.
+ void setShouldRedisplayWelcomeMessage(bool value); // Enforced nonnull setter.
/// Returns the last active version for a given [channel].
///
@@ -50,11 +50,11 @@
/// Return the hash of the last active license terms.
String? get lastActiveLicenseTermsHash;
- set lastActiveLicenseTerms(String value); // Enforced nonnull setter.
+ void setLastActiveLicenseTermsHash(String value); // Enforced nonnull setter.
/// Whether this client was already determined to be or not be a bot.
bool? get isRunningOnBot;
- set runningOnBot(bool value); // Enforced nonnull setter.
+ void setIsRunningOnBot(bool value); // Enforced nonnull setter.
}
class _DefaultPersistentToolState implements PersistentToolState {
@@ -98,7 +98,7 @@
}
@override
- set redisplayWelcomeMessage(bool value) {
+ void setShouldRedisplayWelcomeMessage(bool value) {
_config.setValue(_kRedisplayWelcomeMessage, value);
}
@@ -120,7 +120,7 @@
String? get lastActiveLicenseTermsHash => _config.getValue(_kLicenseHash) as String?;
@override
- set lastActiveLicenseTerms(String value) {
+ void setLastActiveLicenseTermsHash(String value) {
_config.setValue(_kLicenseHash, value);
}
@@ -132,7 +132,7 @@
bool? get isRunningOnBot => _config.getValue(_kBotKey) as bool?;
@override
- set runningOnBot(bool value) {
+ void setIsRunningOnBot(bool value) {
_config.setValue(_kBotKey, value);
}
}
diff --git a/packages/flutter_tools/lib/src/reporting/first_run.dart b/packages/flutter_tools/lib/src/reporting/first_run.dart
index a962a1f..2d39fe3 100644
--- a/packages/flutter_tools/lib/src/reporting/first_run.dart
+++ b/packages/flutter_tools/lib/src/reporting/first_run.dart
@@ -67,7 +67,7 @@
/// Update the cached license terms hash once the new terms have been displayed.
void confirmLicenseTermsDisplayed() {
- _persistentToolState.lastActiveLicenseTerms = _currentHash;
+ _persistentToolState.setLastActiveLicenseTermsHash(_currentHash);
}
/// The hash of the current license representation.
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart
index 17a9c42..cc42503 100644
--- a/packages/flutter_tools/lib/src/runner/flutter_command.dart
+++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart
@@ -188,8 +188,6 @@
bool _excludeDebug = false;
bool _excludeRelease = false;
- BuildMode _defaultBuildMode;
-
void requiresPubspecYaml() {
_requiresPubspecYaml = true;
}
@@ -833,9 +831,11 @@
usesTrackWidgetCreation(verboseHelp: verboseHelp);
}
- set defaultBuildMode(BuildMode value) {
- _defaultBuildMode = value;
- }
+ /// The build mode that this command will use if no build mode is
+ /// explicitly specified.
+ ///
+ /// Use [getBuildMode] to obtain the actual effective build mode.
+ BuildMode defaultBuildMode;
BuildMode getBuildMode() {
// No debug when _excludeDebug is true.
@@ -865,7 +865,7 @@
if (jitReleaseResult) {
return BuildMode.jitRelease;
}
- return _defaultBuildMode;
+ return defaultBuildMode;
}
void usesFlavorOption() {
diff --git a/packages/flutter_tools/lib/src/test/test_compiler.dart b/packages/flutter_tools/lib/src/test/test_compiler.dart
index 107d0ba..ec90fa9 100644
--- a/packages/flutter_tools/lib/src/test/test_compiler.dart
+++ b/packages/flutter_tools/lib/src/test/test_compiler.dart
@@ -81,7 +81,7 @@
Future<String> compile(Uri mainDart) {
final Completer<String> completer = Completer<String>();
if (compilerController.isClosed) {
- return null;
+ return Future<String>.value(null);
}
compilerController.add(CompilationRequest(mainDart, completer));
return completer.future;
diff --git a/packages/flutter_tools/lib/src/web/web_device.dart b/packages/flutter_tools/lib/src/web/web_device.dart
index a6237e2..2a56825 100644
--- a/packages/flutter_tools/lib/src/web/web_device.dart
+++ b/packages/flutter_tools/lib/src/web/web_device.dart
@@ -394,7 +394,7 @@
void clearLogs() { }
@override
- Future<String> get emulatorId => null;
+ Future<String> get emulatorId async => null;
DeviceLogReader _logReader;
diff --git a/packages/flutter_tools/lib/src/windows/windows_device.dart b/packages/flutter_tools/lib/src/windows/windows_device.dart
index 4aaa77a..c2e2d4e 100644
--- a/packages/flutter_tools/lib/src/windows/windows_device.dart
+++ b/packages/flutter_tools/lib/src/windows/windows_device.dart
@@ -125,7 +125,7 @@
Future<void> dispose() async { }
@override
- Future<String> get emulatorId => null;
+ Future<String> get emulatorId async => null;
@override
FutureOr<DeviceLogReader> getLogReader({covariant BuildableUwpApp app, bool includePastLogs = false}) {
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/custom_devices.dart b/packages/flutter_tools/test/commands.shard/hermetic/custom_devices.dart
index 5fa2a77..b9b0a3f 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/custom_devices.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/custom_devices.dart
@@ -234,6 +234,8 @@
);
@override
+ bool get singleCharMode => terminal.singleCharMode;
+ @override
set singleCharMode(bool value) => terminal.singleCharMode = value;
@override
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart
index ec4ce07..a6224f2 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart
@@ -672,7 +672,7 @@
List<ValidatorTask> startValidatorTasks() => <ValidatorTask>[];
@override
- Future<void> summary() => null;
+ Future<void> summary() async { }
@override
List<DoctorValidator> get validators => <DoctorValidator>[];
diff --git a/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart b/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart
index 5bb7f92..16bdda9 100644
--- a/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/error_handling_io_test.dart
@@ -1265,5 +1265,9 @@
p.Context get path => p.Context();
@override
+ Directory get currentDirectory {
+ throw UnimplementedError();
+ }
+ @override
set currentDirectory(dynamic path) { }
}
diff --git a/packages/flutter_tools/test/general.shard/base/terminal_test.dart b/packages/flutter_tools/test/general.shard/base/terminal_test.dart
index 7ba6d4a..4458c6f 100644
--- a/packages/flutter_tools/test/general.shard/base/terminal_test.dart
+++ b/packages/flutter_tools/test/general.shard/base/terminal_test.dart
@@ -236,6 +236,7 @@
return mockStdInStream;
}
+ @override
bool singleCharMode = false;
@override
diff --git a/packages/flutter_tools/test/general.shard/persistent_tool_state_test.dart b/packages/flutter_tools/test/general.shard/persistent_tool_state_test.dart
index 4f7b109..7f55b63 100644
--- a/packages/flutter_tools/test/general.shard/persistent_tool_state_test.dart
+++ b/packages/flutter_tools/test/general.shard/persistent_tool_state_test.dart
@@ -21,10 +21,10 @@
logger: BufferLogger.test(),
);
expect(state1.shouldRedisplayWelcomeMessage, null);
- state1.redisplayWelcomeMessage = true;
+ state1.setShouldRedisplayWelcomeMessage(true);
expect(stateFile.existsSync(), true);
expect(state1.shouldRedisplayWelcomeMessage, true);
- state1.redisplayWelcomeMessage = false;
+ state1.setShouldRedisplayWelcomeMessage(false);
expect(state1.shouldRedisplayWelcomeMessage, false);
final PersistentToolState state2 = PersistentToolState.test(
diff --git a/packages/flutter_tools/test/general.shard/reporting/first_run_test.dart b/packages/flutter_tools/test/general.shard/reporting/first_run_test.dart
index 2e1b449..4fd04e8 100644
--- a/packages/flutter_tools/test/general.shard/reporting/first_run_test.dart
+++ b/packages/flutter_tools/test/general.shard/reporting/first_run_test.dart
@@ -50,7 +50,7 @@
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
final PersistentToolState state = PersistentToolState.test(directory: fileSystem.currentDirectory, logger: BufferLogger.test());
if (redisplayWelcomeMessage != null) {
- state.redisplayWelcomeMessage = redisplayWelcomeMessage;
+ state.setShouldRedisplayWelcomeMessage(redisplayWelcomeMessage);
}
if (test) {
return TestFirstRunMessenger(state);
diff --git a/packages/flutter_tools/test/general.shard/resident_devtools_handler_test.dart b/packages/flutter_tools/test/general.shard/resident_devtools_handler_test.dart
index 1d4dab7..4099d29 100644
--- a/packages/flutter_tools/test/general.shard/resident_devtools_handler_test.dart
+++ b/packages/flutter_tools/test/general.shard/resident_devtools_handler_test.dart
@@ -444,9 +444,7 @@
Uri devToolsUrl;
@override
- Future<DevToolsServerAddress> serve() {
- return null;
- }
+ Future<DevToolsServerAddress> serve() async => null;
@override
Future<void> get ready => readyCompleter.future;
diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
index b732d60..04014ce 100644
--- a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
+++ b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
@@ -494,7 +494,7 @@
_setupMocks();
final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher();
final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher);
- chromiumLauncher.instance = chrome;
+ chromiumLauncher.setInstance(chrome);
flutterDevice.device = GoogleChromeDevice(
fileSystem: fileSystem,
@@ -551,7 +551,7 @@
_setupMocks();
final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher();
final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher);
- chromiumLauncher.instance = chrome;
+ chromiumLauncher.setInstance(chrome);
flutterDevice.device = GoogleChromeDevice(
fileSystem: fileSystem,
@@ -848,7 +848,7 @@
final FakeChromeConnection chromeConnection = FakeChromeConnection();
final TestChromiumLauncher chromiumLauncher = TestChromiumLauncher();
final Chromium chrome = Chromium(1, chromeConnection, chromiumLauncher: chromiumLauncher);
- chromiumLauncher.instance = chrome;
+ chromiumLauncher.setInstance(chrome);
flutterDevice.device = GoogleChromeDevice(
fileSystem: fileSystem,
@@ -1220,11 +1220,11 @@
class TestChromiumLauncher implements ChromiumLauncher {
TestChromiumLauncher();
- set instance(Chromium chromium) {
+ bool _hasInstance = false;
+ void setInstance(Chromium chromium) {
_hasInstance = true;
currentCompleter.complete(chromium);
}
- bool _hasInstance = false;
@override
Completer<Chromium> currentCompleter = Completer<Chromium>();
diff --git a/packages/flutter_tools/test/src/context.dart b/packages/flutter_tools/test/src/context.dart
index 4176e8e..c224a27 100644
--- a/packages/flutter_tools/test/src/context.dart
+++ b/packages/flutter_tools/test/src/context.dart
@@ -312,9 +312,7 @@
}
@override
- Future<void> cleanWorkspace(String workspacePath, String scheme, { bool verbose = false }) {
- return null;
- }
+ Future<void> cleanWorkspace(String workspacePath, String scheme, { bool verbose = false }) async { }
@override
Future<XcodeProjectInfo> getInfo(String projectPath, {String projectFilename}) async {
diff --git a/packages/flutter_tools/test/src/fake_http_client.dart b/packages/flutter_tools/test/src/fake_http_client.dart
index 707f607..f17327d 100644
--- a/packages/flutter_tools/test/src/fake_http_client.dart
+++ b/packages/flutter_tools/test/src/fake_http_client.dart
@@ -161,19 +161,13 @@
}
@override
- set authenticate(Future<bool> Function(Uri url, String scheme, String realm)? f) {
- throw UnimplementedError();
- }
+ Future<bool> Function(Uri url, String scheme, String realm)? authenticate;
@override
- set authenticateProxy(Future<bool> Function(String host, int port, String scheme, String realm)? f) {
- throw UnimplementedError();
- }
+ Future<bool> Function(String host, int port, String scheme, String realm)? authenticateProxy;
@override
- set badCertificateCallback(bool Function(X509Certificate cert, String host, int port)? callback) {
- throw UnimplementedError();
- }
+ bool Function(X509Certificate cert, String host, int port)? badCertificateCallback;
@override
void close({bool force = false}) { }
@@ -190,7 +184,7 @@
}
@override
- set findProxy(String Function(Uri url)? f) { }
+ String Function(Uri url)? findProxy;
@override
Future<HttpClientRequest> get(String host, int port, String path) {
diff --git a/packages/flutter_web_plugins/lib/src/plugin_event_channel.dart b/packages/flutter_web_plugins/lib/src/plugin_event_channel.dart
index b26f1c3..e0ccdd7 100644
--- a/packages/flutter_web_plugins/lib/src/plugin_event_channel.dart
+++ b/packages/flutter_web_plugins/lib/src/plugin_event_channel.dart
@@ -71,7 +71,7 @@
'Replace calls to the "controller" setter with calls to the "setController" method. '
'This feature was deprecated after v1.23.0-7.0.pre.'
)
- set controller(StreamController<T> controller) {
+ set controller(StreamController<T> controller) { // ignore: avoid_setters_without_getters
setController(controller);
}