Enable avoid_setters_without_getters (#91067)

This commit is contained in:
Ian Hickson 2021-10-01 00:58:05 -07:00 committed by GitHub
parent 50604c614e
commit 989f864497
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 131 additions and 117 deletions

View file

@ -81,11 +81,11 @@ linter:
- 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

View file

@ -2012,6 +2012,7 @@ class _RenderCupertinoDialogActions extends RenderBox
markNeedsLayout();
}
Color get dialogColor => _buttonBackgroundPaint.color;
final Paint _buttonBackgroundPaint;
set dialogColor(Color value) {
if (value == _buttonBackgroundPaint.color)
@ -2021,6 +2022,7 @@ class _RenderCupertinoDialogActions extends RenderBox
markNeedsPaint();
}
Color get dialogPressedColor => _pressedButtonBackgroundPaint.color;
final Paint _pressedButtonBackgroundPaint;
set dialogPressedColor(Color value) {
if (value == _pressedButtonBackgroundPaint.color)
@ -2030,6 +2032,7 @@ class _RenderCupertinoDialogActions extends RenderBox
markNeedsPaint();
}
Color get dividerColor => _dividerPaint.color;
final Paint _dividerPaint;
set dividerColor(Color value) {
if (value == _dividerPaint.color)
@ -2039,8 +2042,8 @@ class _RenderCupertinoDialogActions extends RenderBox
markNeedsPaint();
}
bool _isActionSheet;
bool get isActionSheet => _isActionSheet;
bool _isActionSheet;
set isActionSheet(bool value) {
if (value == _isActionSheet)
return;

View file

@ -196,6 +196,7 @@ class _RenderCupertinoTextSelectionToolbarShape extends RenderShiftedBox {
@override
bool get isRepaintBoundary => true;
Offset get anchor => _anchor;
Offset _anchor;
set anchor(Offset value) {
if (value == _anchor) {
@ -205,6 +206,7 @@ class _RenderCupertinoTextSelectionToolbarShape extends RenderShiftedBox {
markNeedsLayout();
}
bool get isAbove => _isAbove;
bool _isAbove;
set isAbove(bool value) {
if (_isAbove == value) {

View file

@ -13,7 +13,6 @@ import 'box.dart';
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 @@ Set<Type> _factoriesTypeSet<T>(Set<Factory<T>> factories) {
/// * [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 @@ class RenderAndroidView extends RenderBox with _PlatformViewGestureMixin {
_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 @@ class _UiKitViewGestureRecognizer extends OneSequenceGestureRecognizer {
).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 @@ class _PlatformViewGestureRecognizer extends OneSequenceGestureRecognizer {
/// [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 @@ class PlatformViewRenderBox extends RenderBox with _PlatformViewGestureMixin {
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 @@ class PlatformViewRenderBox extends RenderBox with _PlatformViewGestureMixin {
_updateGestureRecognizersWithCallBack(gestureRecognizers, _controller.dispatchPointerEvent);
}
PlatformViewController _controller;
@override
bool get sizedByParent => true;

View file

@ -2265,11 +2265,14 @@ class RenderTransform extends RenderProxyBox {
/// 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;

View file

@ -522,8 +522,8 @@ class _AndroidMotionEventConverter {
<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 @@ abstract class AndroidViewController extends PlatformViewController {
);
}
/// 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 @@ class UiKitViewController {
}
}
/// 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.

View file

@ -160,13 +160,10 @@ abstract class Action<T extends Intent> with Diagnosticable {
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 @@ mixin _OverridableActionMixin<T extends Intent> on Action<T> {
}
@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 @@ mixin _OverridableActionMixin<T extends Intent> on Action<T> {
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 @@ mixin _OverridableActionMixin<T extends Intent> on Action<T> {
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 @@ mixin _OverridableActionMixin<T extends Intent> on Action<T> {
}());
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 @@ mixin _OverridableActionMixin<T extends Intent> on Action<T> {
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 @@ class _OverridableContextAction<T extends Intent> extends ContextAction<T> with
// 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 @@ class _ContextActionToActionAdapter<T extends Intent> extends Action<T> {
final ContextAction<T> action;
@override
set _callingAction(Action<T>? newAction) {
action._callingAction = newAction;
void _updateCallingAction(Action<T>? value) {
action._updateCallingAction(value);
}
@override

View file

@ -59,7 +59,7 @@ class FakeAndroidViewController implements AndroidViewController {
final int viewId;
@override
Offset Function(Offset position)? pointTransformer;
late PointTransformer pointTransformer;
@override
Future<void> dispatchPointerEvent(PointerEvent event) async {

View file

@ -92,7 +92,6 @@ class TestWidget extends SingleChildRenderObjectWidget {
}
class RenderTest extends RenderProxyBox {
@override
void describeSemanticsConfiguration(SemanticsConfiguration config) {
super.describeSemanticsConfiguration(config);
@ -107,6 +106,7 @@ class RenderTest extends RenderProxyBox {
}
String get label => _label;
String _label = '<>';
set label(String value) {
if (value == _label)
@ -116,6 +116,7 @@ class RenderTest extends RenderProxyBox {
}
bool get isSemanticBoundary => _isSemanticBoundary;
bool _isSemanticBoundary = false;
set isSemanticBoundary(bool value) {
if (_isSemanticBoundary == value)

View file

@ -120,13 +120,13 @@ class _MockHttpClient implements HttpClient {
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 @@ class _MockHttpClient implements HttpClient {
}
@override
set findProxy(String Function(Uri url)? f) { }
String Function(Uri url)? findProxy;
@override
Future<HttpClientRequest> get(String host, int port, String path) {

View file

@ -59,7 +59,7 @@ class TestWindow implements ui.SingletonFlutterWindow {
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 @@ class TestWindow implements ui.SingletonFlutterWindow {
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 @@ class TestWindow implements ui.SingletonFlutterWindow {
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 @@ class TestWindow implements ui.SingletonFlutterWindow {
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 @@ class TestWindow implements ui.SingletonFlutterWindow {
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 @@ class TestWindow implements ui.SingletonFlutterWindow {
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 @@ class TestWindow implements ui.SingletonFlutterWindow {
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 @@ class TestWindow implements ui.SingletonFlutterWindow {
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 @@ class TestWindow implements ui.SingletonFlutterWindow {
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 @@ class TestWindow implements ui.SingletonFlutterWindow {
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 @@ class TestWindow implements ui.SingletonFlutterWindow {
}
/// 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 @@ class TestWindow implements ui.SingletonFlutterWindow {
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 @@ class TestWindow implements ui.SingletonFlutterWindow {
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 @@ class TestWindow implements ui.SingletonFlutterWindow {
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 @@ class TestWindow implements ui.SingletonFlutterWindow {
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 @@ class TestWindow implements ui.SingletonFlutterWindow {
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();
}

View file

@ -37,14 +37,15 @@ class BotDetector {
// 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 @@ class BotDetector {
// Property when running on Azure.
|| await _azureDetector.isRunningOnAzure;
_persistentToolState.setIsRunningOnBot(result);
return result;
}
}

View file

@ -111,6 +111,7 @@ abstract class Terminal {
String clearScreen();
bool get singleCharMode;
set singleCharMode(bool value);
/// Return keystrokes from the console.
@ -269,6 +270,14 @@ class AnsiTerminal implements Terminal {
@override
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) {
@ -365,6 +374,8 @@ class _TestTerminal implements Terminal {
throw UnsupportedError('promptForCharInput not supported in the test terminal.');
}
@override
bool get singleCharMode => false;
@override
set singleCharMode(bool value) { }

View file

@ -198,12 +198,12 @@ class UpgradeCommandRunner {
// 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 {

View file

@ -704,6 +704,7 @@ class IOSDeviceLogReader extends DeviceLogReader {
}
/// 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 @@ class IOSDeviceLogReader extends DeviceLogReader {
_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 @@ class IOSDeviceLogReader extends DeviceLogReader {
for (final StreamSubscription<void> loggingSubscription in _loggingSubscriptions) {
loggingSubscription.cancel();
}
_idevicesyslogProcess?.kill();
idevicesyslogProcess?.kill();
_iosDeployDebugger?.detach();
}
}

View file

@ -38,7 +38,7 @@ abstract class PersistentToolState {
///
/// 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 @@ abstract class PersistentToolState {
/// 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 @@ class _DefaultPersistentToolState implements PersistentToolState {
}
@override
set redisplayWelcomeMessage(bool value) {
void setShouldRedisplayWelcomeMessage(bool value) {
_config.setValue(_kRedisplayWelcomeMessage, value);
}
@ -120,7 +120,7 @@ class _DefaultPersistentToolState implements PersistentToolState {
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 @@ class _DefaultPersistentToolState implements PersistentToolState {
bool? get isRunningOnBot => _config.getValue(_kBotKey) as bool?;
@override
set runningOnBot(bool value) {
void setIsRunningOnBot(bool value) {
_config.setValue(_kBotKey, value);
}
}

View file

@ -67,7 +67,7 @@ class FirstRunMessenger {
/// 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.

View file

@ -188,8 +188,6 @@ abstract class FlutterCommand extends Command<void> {
bool _excludeDebug = false;
bool _excludeRelease = false;
BuildMode _defaultBuildMode;
void requiresPubspecYaml() {
_requiresPubspecYaml = true;
}
@ -833,9 +831,11 @@ abstract class FlutterCommand extends Command<void> {
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 @@ abstract class FlutterCommand extends Command<void> {
if (jitReleaseResult) {
return BuildMode.jitRelease;
}
return _defaultBuildMode;
return defaultBuildMode;
}
void usesFlavorOption() {

View file

@ -81,7 +81,7 @@ class TestCompiler {
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;

View file

@ -394,7 +394,7 @@ class WebServerDevice extends Device {
void clearLogs() { }
@override
Future<String> get emulatorId => null;
Future<String> get emulatorId async => null;
DeviceLogReader _logReader;

View file

@ -125,7 +125,7 @@ class WindowsUWPDevice extends Device {
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}) {

View file

@ -233,6 +233,8 @@ class FakeTerminal implements Terminal {
displayAcceptedCharacters: displayAcceptedCharacters
);
@override
bool get singleCharMode => terminal.singleCharMode;
@override
set singleCharMode(bool value) => terminal.singleCharMode = value;

View file

@ -672,7 +672,7 @@ class NoOpDoctor implements Doctor {
List<ValidatorTask> startValidatorTasks() => <ValidatorTask>[];
@override
Future<void> summary() => null;
Future<void> summary() async { }
@override
List<DoctorValidator> get validators => <DoctorValidator>[];

View file

@ -1264,6 +1264,10 @@ class FakeFileSystem extends Fake implements FileSystem {
@override
p.Context get path => p.Context();
@override
Directory get currentDirectory {
throw UnimplementedError();
}
@override
set currentDirectory(dynamic path) { }
}

View file

@ -236,6 +236,7 @@ class TestTerminal extends AnsiTerminal {
return mockStdInStream;
}
@override
bool singleCharMode = false;
@override

View file

@ -21,10 +21,10 @@ void main() {
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(

View file

@ -50,7 +50,7 @@ FirstRunMessenger setUpFirstRunMessenger({bool? redisplayWelcomeMessage, bool te
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);

View file

@ -444,9 +444,7 @@ class FakeDevtoolsLauncher extends Fake implements DevtoolsLauncher {
Uri devToolsUrl;
@override
Future<DevToolsServerAddress> serve() {
return null;
}
Future<DevToolsServerAddress> serve() async => null;
@override
Future<void> get ready => readyCompleter.future;

View file

@ -494,7 +494,7 @@ void main() {
_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 @@ void main() {
_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 @@ void main() {
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 FakeWipConnection extends Fake implements WipConnection {
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>();

View file

@ -312,9 +312,7 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
}
@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 {

View file

@ -161,19 +161,13 @@ class FakeHttpClient implements HttpClient {
}
@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 @@ class FakeHttpClient implements HttpClient {
}
@override
set findProxy(String Function(Uri url)? f) { }
String Function(Uri url)? findProxy;
@override
Future<HttpClientRequest> get(String host, int port, String path) {

View file

@ -71,7 +71,7 @@ class PluginEventChannel<T> {
'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);
}