Commit 4c530d5e authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

prefer_final_fields (#8967)

parent bc7801bf
...@@ -151,7 +151,7 @@ class _DataTableDemoState extends State<DataTableDemo> { ...@@ -151,7 +151,7 @@ class _DataTableDemoState extends State<DataTableDemo> {
int _rowsPerPage = PaginatedDataTable.defaultRowsPerPage; int _rowsPerPage = PaginatedDataTable.defaultRowsPerPage;
int _sortColumnIndex; int _sortColumnIndex;
bool _sortAscending = true; bool _sortAscending = true;
DessertDataSource _dessertsDataSource = new DessertDataSource(); final DessertDataSource _dessertsDataSource = new DessertDataSource();
void _sort<T>(Comparable<T> getField(Dessert d), int columnIndex, bool ascending) { void _sort<T>(Comparable<T> getField(Dessert d), int columnIndex, bool ascending) {
_dessertsDataSource._sort<T>(getField, ascending); _dessertsDataSource._sort<T>(getField, ascending);
......
...@@ -121,7 +121,7 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> { ...@@ -121,7 +121,7 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
TimeOfDay _fromTime = const TimeOfDay(hour: 7, minute: 28); TimeOfDay _fromTime = const TimeOfDay(hour: 7, minute: 28);
DateTime _toDate = new DateTime.now(); DateTime _toDate = new DateTime.now();
TimeOfDay _toTime = const TimeOfDay(hour: 7, minute: 28); TimeOfDay _toTime = const TimeOfDay(hour: 7, minute: 28);
List<String> _allActivities = <String>['hiking', 'swimming', 'boating', 'fishing']; final List<String> _allActivities = <String>['hiking', 'swimming', 'boating', 'fishing'];
String _activity = 'fishing'; String _activity = 'fishing';
@override @override
......
...@@ -34,8 +34,8 @@ class TextFieldDemoState extends State<TextFieldDemo> { ...@@ -34,8 +34,8 @@ class TextFieldDemoState extends State<TextFieldDemo> {
bool _autovalidate = false; bool _autovalidate = false;
bool _formWasEdited = false; bool _formWasEdited = false;
GlobalKey<FormState> _formKey = new GlobalKey<FormState>(); final GlobalKey<FormState> _formKey = new GlobalKey<FormState>();
GlobalKey<FormFieldState<InputValue>> _passwordFieldKey = new GlobalKey<FormFieldState<InputValue>>(); final GlobalKey<FormFieldState<InputValue>> _passwordFieldKey = new GlobalKey<FormFieldState<InputValue>>();
void _handleSubmitted() { void _handleSubmitted() {
final FormState form = _formKey.currentState; final FormState form = _formKey.currentState;
if (!form.validate()) { if (!form.validate()) {
......
...@@ -61,7 +61,7 @@ abstract class GestureBinding extends BindingBase implements HitTestable, HitTes ...@@ -61,7 +61,7 @@ abstract class GestureBinding extends BindingBase implements HitTestable, HitTes
/// ///
/// The state of hovering pointers is not tracked because that would require /// The state of hovering pointers is not tracked because that would require
/// hit-testing on every frame. /// hit-testing on every frame.
Map<int, HitTestResult> _hitTests = <int, HitTestResult>{}; final Map<int, HitTestResult> _hitTests = <int, HitTestResult>{};
void _handlePointerEvent(PointerEvent event) { void _handlePointerEvent(PointerEvent event) {
HitTestResult result; HitTestResult result;
......
...@@ -34,7 +34,7 @@ class _PointerState { ...@@ -34,7 +34,7 @@ class _PointerState {
/// Converts from engine pointer data to framework pointer events. /// Converts from engine pointer data to framework pointer events.
class PointerEventConverter { class PointerEventConverter {
// Map from platform pointer identifiers to PointerEvent pointer identifiers. // Map from platform pointer identifiers to PointerEvent pointer identifiers.
static Map<int, _PointerState> _pointers = <int, _PointerState>{}; static final Map<int, _PointerState> _pointers = <int, _PointerState>{};
static _PointerState _ensureStateForPointer(ui.PointerData datum, Point position) { static _PointerState _ensureStateForPointer(ui.PointerData datum, Point position) {
return _pointers.putIfAbsent( return _pointers.putIfAbsent(
......
...@@ -278,7 +278,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer { ...@@ -278,7 +278,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
double _getPrimaryValueFromOffset(Offset value); double _getPrimaryValueFromOffset(Offset value);
bool get _hasSufficientPendingDragDeltaToAccept; bool get _hasSufficientPendingDragDeltaToAccept;
Map<int, VelocityTracker> _velocityTrackers = <int, VelocityTracker>{}; final Map<int, VelocityTracker> _velocityTrackers = <int, VelocityTracker>{};
@override @override
void addPointer(PointerEvent event) { void addPointer(PointerEvent event) {
......
...@@ -115,7 +115,7 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer { ...@@ -115,7 +115,7 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
double _initialSpan; double _initialSpan;
double _currentSpan; double _currentSpan;
Map<int, Point> _pointerLocations; Map<int, Point> _pointerLocations;
Map<int, VelocityTracker> _velocityTrackers = <int, VelocityTracker>{}; final Map<int, VelocityTracker> _velocityTrackers = <int, VelocityTracker>{};
double get _scaleFactor => _initialSpan > 0.0 ? _currentSpan / _initialSpan : 1.0; double get _scaleFactor => _initialSpan > 0.0 ? _currentSpan / _initialSpan : 1.0;
......
...@@ -369,7 +369,7 @@ class _LicensePageState extends State<LicensePage> { ...@@ -369,7 +369,7 @@ class _LicensePageState extends State<LicensePage> {
_initLicenses(); _initLicenses();
} }
List<Widget> _licenses = <Widget>[]; final List<Widget> _licenses = <Widget>[];
bool _loaded = false; bool _loaded = false;
Future<Null> _initLicenses() async { Future<Null> _initLicenses() async {
......
...@@ -599,7 +599,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> { ...@@ -599,7 +599,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
DateTime _selectedDate; DateTime _selectedDate;
_DatePickerMode _mode = _DatePickerMode.day; _DatePickerMode _mode = _DatePickerMode.day;
GlobalKey _pickerKey = new GlobalKey(); final GlobalKey _pickerKey = new GlobalKey();
void _vibrate() { void _vibrate() {
switch (Theme.of(context).platform) { switch (Theme.of(context).platform) {
......
...@@ -107,8 +107,8 @@ class InputField extends StatefulWidget { ...@@ -107,8 +107,8 @@ class InputField extends StatefulWidget {
} }
class _InputFieldState extends State<InputField> { class _InputFieldState extends State<InputField> {
GlobalKey<EditableTextState> _editableTextKey = new GlobalKey<EditableTextState>(); final GlobalKey<EditableTextState> _editableTextKey = new GlobalKey<EditableTextState>();
GlobalKey<EditableTextState> _focusKey = new GlobalKey(debugLabel: "_InputFieldState _focusKey"); final GlobalKey<EditableTextState> _focusKey = new GlobalKey(debugLabel: "_InputFieldState _focusKey");
GlobalKey get focusKey => config.focusKey ?? (config.key is GlobalKey ? config.key : _focusKey); GlobalKey get focusKey => config.focusKey ?? (config.key is GlobalKey ? config.key : _focusKey);
......
...@@ -455,7 +455,7 @@ class RefreshProgressIndicator extends CircularProgressIndicator { ...@@ -455,7 +455,7 @@ class RefreshProgressIndicator extends CircularProgressIndicator {
} }
class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState { class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState {
static double _kIndicatorSize = 40.0; static const double _kIndicatorSize = 40.0;
// Always show the indeterminate version of the circular progress indicator. // Always show the indeterminate version of the circular progress indicator.
// When value is non-null the sweep of the progress indicator arrow's arc // When value is non-null the sweep of the progress indicator arrow's arc
......
...@@ -512,7 +512,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin { ...@@ -512,7 +512,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
// SNACKBAR API // SNACKBAR API
Queue<ScaffoldFeatureController<SnackBar, SnackBarClosedReason>> _snackBars = new Queue<ScaffoldFeatureController<SnackBar, SnackBarClosedReason>>(); final Queue<ScaffoldFeatureController<SnackBar, SnackBarClosedReason>> _snackBars = new Queue<ScaffoldFeatureController<SnackBar, SnackBarClosedReason>>();
AnimationController _snackBarController; AnimationController _snackBarController;
Timer _snackBarTimer; Timer _snackBarTimer;
......
...@@ -58,7 +58,7 @@ class RenderAnimatedSize extends RenderAligningShiftedBox { ...@@ -58,7 +58,7 @@ class RenderAnimatedSize extends RenderAligningShiftedBox {
AnimationController _controller; AnimationController _controller;
CurvedAnimation _animation; CurvedAnimation _animation;
SizeTween _sizeTween = new SizeTween(); final SizeTween _sizeTween = new SizeTween();
bool _didChangeTargetSizeLastFrame = false; bool _didChangeTargetSizeLastFrame = false;
bool _hasVisualOverflow; bool _hasVisualOverflow;
double _lastValue; double _lastValue;
......
...@@ -1020,7 +1020,7 @@ class PipelineOwner { ...@@ -1020,7 +1020,7 @@ class PipelineOwner {
} }
} }
List<RenderObject> _nodesNeedingCompositingBitsUpdate = <RenderObject>[]; final List<RenderObject> _nodesNeedingCompositingBitsUpdate = <RenderObject>[];
/// Updates the [needsCompositing] bits. /// Updates the [needsCompositing] bits.
/// ///
/// Called as part of the rendering pipeline after [flushLayout] and before /// Called as part of the rendering pipeline after [flushLayout] and before
......
...@@ -1079,7 +1079,7 @@ class RenderTable extends RenderBox { ...@@ -1079,7 +1079,7 @@ class RenderTable extends RenderBox {
} }
// cache the table geometry for painting purposes // cache the table geometry for painting purposes
List<double> _rowTops = <double>[]; final List<double> _rowTops = <double>[];
List<double> _columnLefts; List<double> _columnLefts;
/// Returns the position and dimensions of the box that the given /// Returns the position and dimensions of the box that the given
......
...@@ -462,7 +462,7 @@ class _DragAvatar<T> extends Drag { ...@@ -462,7 +462,7 @@ class _DragAvatar<T> extends Drag {
final OverlayState overlayState; final OverlayState overlayState;
_DragTargetState<T> _activeTarget; _DragTargetState<T> _activeTarget;
List<_DragTargetState<T>> _enteredTargets = <_DragTargetState<T>>[]; final List<_DragTargetState<T>> _enteredTargets = <_DragTargetState<T>>[];
Point _position; Point _position;
Offset _lastOffset; Offset _lastOffset;
OverlayEntry _entry; OverlayEntry _entry;
......
...@@ -70,7 +70,7 @@ class Form extends StatefulWidget { ...@@ -70,7 +70,7 @@ class Form extends StatefulWidget {
/// Typically obtained via [Form.of]. /// Typically obtained via [Form.of].
class FormState extends State<Form> { class FormState extends State<Form> {
int _generation = 0; int _generation = 0;
Set<FormFieldState<dynamic>> _fields = new Set<FormFieldState<dynamic>>(); final Set<FormFieldState<dynamic>> _fields = new Set<FormFieldState<dynamic>>();
// Called when a form field has changed. This will cause all form fields // Called when a form field has changed. This will cause all form fields
// to rebuild, useful if form fields have interdependencies. // to rebuild, useful if form fields have interdependencies.
......
...@@ -135,7 +135,7 @@ class Hero extends StatefulWidget { ...@@ -135,7 +135,7 @@ class Hero extends StatefulWidget {
} }
class _HeroState extends State<Hero> { class _HeroState extends State<Hero> {
GlobalKey _key = new GlobalKey(); final GlobalKey _key = new GlobalKey();
Size _placeholderSize; Size _placeholderSize;
void startFlight() { void startFlight() {
......
...@@ -287,8 +287,8 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render ...@@ -287,8 +287,8 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
performRebuild(); performRebuild();
} }
SplayTreeMap<int, Element> _childElements = new SplayTreeMap<int, Element>(); final SplayTreeMap<int, Element> _childElements = new SplayTreeMap<int, Element>();
Map<int, Widget> _childWidgets = new HashMap<int, Widget>(); final Map<int, Widget> _childWidgets = new HashMap<int, Widget>();
RenderBox _currentBeforeChild; RenderBox _currentBeforeChild;
@override @override
......
...@@ -18,7 +18,7 @@ class TestRoute extends LocalHistoryRoute<String> { ...@@ -18,7 +18,7 @@ class TestRoute extends LocalHistoryRoute<String> {
@override @override
List<OverlayEntry> get overlayEntries => _entries; List<OverlayEntry> get overlayEntries => _entries;
List<OverlayEntry> _entries = <OverlayEntry>[]; final List<OverlayEntry> _entries = <OverlayEntry>[];
void log(String s) { void log(String s) {
results.add('$name: $s'); results.add('$name: $s');
......
...@@ -48,7 +48,7 @@ class TestAsyncUtils { ...@@ -48,7 +48,7 @@ class TestAsyncUtils {
TestAsyncUtils._(); TestAsyncUtils._();
static const String _className = 'TestAsyncUtils'; static const String _className = 'TestAsyncUtils';
static List<_AsyncScope> _scopeStack = <_AsyncScope>[]; static final List<_AsyncScope> _scopeStack = <_AsyncScope>[];
/// Calls the given callback in a new async scope. The callback argument is /// Calls the given callback in a new async scope. The callback argument is
/// the asynchronous body of the calling method. The calling method is said to /// the asynchronous body of the calling method. The calling method is said to
......
...@@ -427,7 +427,7 @@ class AndroidDevice extends Device { ...@@ -427,7 +427,7 @@ class AndroidDevice extends Device {
return _portForwarder; return _portForwarder;
} }
static RegExp _timeRegExp = new RegExp(r'^\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}', multiLine: true); static final RegExp _timeRegExp = new RegExp(r'^\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}', multiLine: true);
/// Return the most recent timestamp in the Android log or `null` if there is /// Return the most recent timestamp in the Android log or `null` if there is
/// no available timestamp. The format can be passed to logcat's -T option. /// no available timestamp. The format can be passed to logcat's -T option.
......
...@@ -61,7 +61,7 @@ class AndroidStudio implements Comparable<AndroidStudio> { ...@@ -61,7 +61,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
String _gradlePath; String _gradlePath;
String _javaPath; String _javaPath;
bool _isValid = false; bool _isValid = false;
List<String> _validationMessages = <String>[]; final List<String> _validationMessages = <String>[];
factory AndroidStudio.fromMacOSBundle(String bundlePath) { factory AndroidStudio.fromMacOSBundle(String bundlePath) {
final String studioPath = fs.path.join(bundlePath, 'Contents'); final String studioPath = fs.path.join(bundlePath, 'Contents');
......
...@@ -11,7 +11,7 @@ typedef void ErrorHandler(dynamic error, StackTrace stackTrace); ...@@ -11,7 +11,7 @@ typedef void ErrorHandler(dynamic error, StackTrace stackTrace);
AppContext get context => Zone.current['context']; AppContext get context => Zone.current['context'];
class AppContext { class AppContext {
Map<Type, dynamic> _instances = <Type, dynamic>{}; final Map<Type, dynamic> _instances = <Type, dynamic>{};
Zone _zone; Zone _zone;
AppContext() : _zone = Zone.current; AppContext() : _zone = Zone.current;
......
...@@ -135,9 +135,9 @@ class BufferLogger extends Logger { ...@@ -135,9 +135,9 @@ class BufferLogger extends Logger {
@override @override
bool get isVerbose => false; bool get isVerbose => false;
StringBuffer _error = new StringBuffer(); final StringBuffer _error = new StringBuffer();
StringBuffer _status = new StringBuffer(); final StringBuffer _status = new StringBuffer();
StringBuffer _trace = new StringBuffer(); final StringBuffer _trace = new StringBuffer();
String get errorText => _error.toString(); String get errorText => _error.toString();
String get statusText => _status.toString(); String get statusText => _status.toString();
...@@ -282,7 +282,7 @@ class AnsiTerminal { ...@@ -282,7 +282,7 @@ class AnsiTerminal {
String clearScreen() => supportsColor ? _clear : '\n\n'; String clearScreen() => supportsColor ? _clear : '\n\n';
set singleCharMode(bool value) { set singleCharMode(bool value) {
// TODO(goderbauer): instead of trying to set lineMode and then catching [_ENOTTY] or [_INVALID_HANDLE], // TODO(goderbauer): instead of trying to set lineMode and then catching [_ENOTTY] or [_INVALID_HANDLE],
// we should check beforehand if stdin is connected to a terminal or not // we should check beforehand if stdin is connected to a terminal or not
// (requires https://github.com/dart-lang/sdk/issues/29083 to be resolved). // (requires https://github.com/dart-lang/sdk/issues/29083 to be resolved).
try { try {
......
...@@ -105,8 +105,8 @@ class ItemListNotifier<T> { ...@@ -105,8 +105,8 @@ class ItemListNotifier<T> {
Set<T> _items; Set<T> _items;
StreamController<T> _addedController = new StreamController<T>.broadcast(); final StreamController<T> _addedController = new StreamController<T>.broadcast();
StreamController<T> _removedController = new StreamController<T>.broadcast(); final StreamController<T> _removedController = new StreamController<T>.broadcast();
Stream<T> get onAdded => _addedController.stream; Stream<T> get onAdded => _addedController.stream;
Stream<T> get onRemoved => _removedController.stream; Stream<T> get onRemoved => _removedController.stream;
...@@ -168,7 +168,7 @@ class SettingsFile { ...@@ -168,7 +168,7 @@ class SettingsFile {
/// For more information, see /// For more information, see
/// http://en.wikipedia.org/wiki/Universally_unique_identifier. /// http://en.wikipedia.org/wiki/Universally_unique_identifier.
class Uuid { class Uuid {
Random _random = new Random(); final Random _random = new Random();
/// Generate a version 4 (random) uuid. This is a uuid scheme that only uses /// Generate a version 4 (random) uuid. This is a uuid scheme that only uses
/// random numbers as the source of the generated uuid. /// random numbers as the source of the generated uuid.
......
...@@ -150,8 +150,8 @@ class AnalysisServer { ...@@ -150,8 +150,8 @@ class AnalysisServer {
final List<String> directories; final List<String> directories;
Process _process; Process _process;
StreamController<bool> _analyzingController = new StreamController<bool>.broadcast(); final StreamController<bool> _analyzingController = new StreamController<bool>.broadcast();
StreamController<FileAnalysisErrors> _errorsController = new StreamController<FileAnalysisErrors>.broadcast(); final StreamController<FileAnalysisErrors> _errorsController = new StreamController<FileAnalysisErrors>.broadcast();
int _id = 0; int _id = 0;
......
...@@ -286,11 +286,11 @@ class AppDomain extends Domain { ...@@ -286,11 +286,11 @@ class AppDomain extends Domain {
registerHandler('discover', discover); registerHandler('discover', discover);
} }
static Uuid _uuidGenerator = new Uuid(); static final Uuid _uuidGenerator = new Uuid();
static String _getNewAppId() => _uuidGenerator.generateV4(); static String _getNewAppId() => _uuidGenerator.generateV4();
List<AppInstance> _apps = <AppInstance>[]; final List<AppInstance> _apps = <AppInstance>[];
Future<Map<String, dynamic>> start(Map<String, dynamic> args) async { Future<Map<String, dynamic>> start(Map<String, dynamic> args) async {
final String deviceId = _getStringArg(args, 'deviceId', required: true); final String deviceId = _getStringArg(args, 'deviceId', required: true);
...@@ -537,7 +537,7 @@ class DeviceDomain extends Domain { ...@@ -537,7 +537,7 @@ class DeviceDomain extends Domain {
} }
} }
List<PollingDeviceDiscovery> _discoverers = <PollingDeviceDiscovery>[]; final List<PollingDeviceDiscovery> _discoverers = <PollingDeviceDiscovery>[];
Future<List<Device>> getDevices([Map<String, dynamic> args]) { Future<List<Device>> getDevices([Map<String, dynamic> args]) {
final List<Device> devices = _discoverers.expand((PollingDeviceDiscovery discoverer) { final List<Device> devices = _discoverers.expand((PollingDeviceDiscovery discoverer) {
...@@ -670,7 +670,7 @@ dynamic _toJsonable(dynamic obj) { ...@@ -670,7 +670,7 @@ dynamic _toJsonable(dynamic obj) {
} }
class NotifyingLogger extends Logger { class NotifyingLogger extends Logger {
StreamController<LogMessage> _messageController = new StreamController<LogMessage>.broadcast(); final StreamController<LogMessage> _messageController = new StreamController<LogMessage>.broadcast();
Stream<LogMessage> get onMessage => _messageController.stream; Stream<LogMessage> get onMessage => _messageController.stream;
......
...@@ -34,7 +34,7 @@ class AnalysisDriver { ...@@ -34,7 +34,7 @@ class AnalysisDriver {
_processPlugins(); _processPlugins();
} }
Set<Source> _analyzedSources = new HashSet<Source>(); final Set<Source> _analyzedSources = new HashSet<Source>();
AnalysisOptionsProvider analysisOptionsProvider = AnalysisOptionsProvider analysisOptionsProvider =
new AnalysisOptionsProvider(); new AnalysisOptionsProvider();
...@@ -245,7 +245,7 @@ class PackageInfo { ...@@ -245,7 +245,7 @@ class PackageInfo {
Packages _packages; Packages _packages;
Map<String, List<file_system.Folder>> asMap() => _map; Map<String, List<file_system.Folder>> asMap() => _map;
HashMap<String, List<file_system.Folder>> _map = final HashMap<String, List<file_system.Folder>> _map =
new HashMap<String, List<file_system.Folder>>(); new HashMap<String, List<file_system.Folder>>();
Packages asPackages() => _packages; Packages asPackages() => _packages;
......
...@@ -30,7 +30,7 @@ class DeviceManager { ...@@ -30,7 +30,7 @@ class DeviceManager {
_deviceDiscoverers.add(new IOSSimulators()); _deviceDiscoverers.add(new IOSSimulators());
} }
List<DeviceDiscovery> _deviceDiscoverers = <DeviceDiscovery>[]; final List<DeviceDiscovery> _deviceDiscoverers = <DeviceDiscovery>[];
/// A user-specified device ID. /// A user-specified device ID.
String specifiedDeviceId; String specifiedDeviceId;
......
...@@ -96,7 +96,7 @@ class VMService { ...@@ -96,7 +96,7 @@ class VMService {
final Map<String, StreamController<ServiceEvent>> _eventControllers = final Map<String, StreamController<ServiceEvent>> _eventControllers =
<String, StreamController<ServiceEvent>>{}; <String, StreamController<ServiceEvent>>{};
Set<String> _listeningFor = new Set<String>(); final Set<String> _listeningFor = new Set<String>();
/// Whether our connection to the VM service has been closed; /// Whether our connection to the VM service has been closed;
bool get isClosed => _peer.isClosed; bool get isClosed => _peer.isClosed;
......
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