prefer_final_fields (#8967)
This commit is contained in:
committed by
GitHub
parent
bc7801bf8e
commit
4c530d5e8c
@@ -151,7 +151,7 @@ class _DataTableDemoState extends State<DataTableDemo> {
|
||||
int _rowsPerPage = PaginatedDataTable.defaultRowsPerPage;
|
||||
int _sortColumnIndex;
|
||||
bool _sortAscending = true;
|
||||
DessertDataSource _dessertsDataSource = new DessertDataSource();
|
||||
final DessertDataSource _dessertsDataSource = new DessertDataSource();
|
||||
|
||||
void _sort<T>(Comparable<T> getField(Dessert d), int columnIndex, bool ascending) {
|
||||
_dessertsDataSource._sort<T>(getField, ascending);
|
||||
|
||||
@@ -121,7 +121,7 @@ class _DateAndTimePickerDemoState extends State<DateAndTimePickerDemo> {
|
||||
TimeOfDay _fromTime = const TimeOfDay(hour: 7, minute: 28);
|
||||
DateTime _toDate = new DateTime.now();
|
||||
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';
|
||||
|
||||
@override
|
||||
|
||||
@@ -34,8 +34,8 @@ class TextFieldDemoState extends State<TextFieldDemo> {
|
||||
|
||||
bool _autovalidate = false;
|
||||
bool _formWasEdited = false;
|
||||
GlobalKey<FormState> _formKey = new GlobalKey<FormState>();
|
||||
GlobalKey<FormFieldState<InputValue>> _passwordFieldKey = new GlobalKey<FormFieldState<InputValue>>();
|
||||
final GlobalKey<FormState> _formKey = new GlobalKey<FormState>();
|
||||
final GlobalKey<FormFieldState<InputValue>> _passwordFieldKey = new GlobalKey<FormFieldState<InputValue>>();
|
||||
void _handleSubmitted() {
|
||||
final FormState form = _formKey.currentState;
|
||||
if (!form.validate()) {
|
||||
|
||||
@@ -61,7 +61,7 @@ abstract class GestureBinding extends BindingBase implements HitTestable, HitTes
|
||||
///
|
||||
/// The state of hovering pointers is not tracked because that would require
|
||||
/// hit-testing on every frame.
|
||||
Map<int, HitTestResult> _hitTests = <int, HitTestResult>{};
|
||||
final Map<int, HitTestResult> _hitTests = <int, HitTestResult>{};
|
||||
|
||||
void _handlePointerEvent(PointerEvent event) {
|
||||
HitTestResult result;
|
||||
|
||||
@@ -34,7 +34,7 @@ class _PointerState {
|
||||
/// Converts from engine pointer data to framework pointer events.
|
||||
class PointerEventConverter {
|
||||
// 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) {
|
||||
return _pointers.putIfAbsent(
|
||||
|
||||
@@ -278,7 +278,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
|
||||
double _getPrimaryValueFromOffset(Offset value);
|
||||
bool get _hasSufficientPendingDragDeltaToAccept;
|
||||
|
||||
Map<int, VelocityTracker> _velocityTrackers = <int, VelocityTracker>{};
|
||||
final Map<int, VelocityTracker> _velocityTrackers = <int, VelocityTracker>{};
|
||||
|
||||
@override
|
||||
void addPointer(PointerEvent event) {
|
||||
|
||||
@@ -115,7 +115,7 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
|
||||
double _initialSpan;
|
||||
double _currentSpan;
|
||||
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;
|
||||
|
||||
|
||||
@@ -369,7 +369,7 @@ class _LicensePageState extends State<LicensePage> {
|
||||
_initLicenses();
|
||||
}
|
||||
|
||||
List<Widget> _licenses = <Widget>[];
|
||||
final List<Widget> _licenses = <Widget>[];
|
||||
bool _loaded = false;
|
||||
|
||||
Future<Null> _initLicenses() async {
|
||||
|
||||
@@ -599,7 +599,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
|
||||
|
||||
DateTime _selectedDate;
|
||||
_DatePickerMode _mode = _DatePickerMode.day;
|
||||
GlobalKey _pickerKey = new GlobalKey();
|
||||
final GlobalKey _pickerKey = new GlobalKey();
|
||||
|
||||
void _vibrate() {
|
||||
switch (Theme.of(context).platform) {
|
||||
|
||||
@@ -107,8 +107,8 @@ class InputField extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _InputFieldState extends State<InputField> {
|
||||
GlobalKey<EditableTextState> _editableTextKey = new GlobalKey<EditableTextState>();
|
||||
GlobalKey<EditableTextState> _focusKey = new GlobalKey(debugLabel: "_InputFieldState _focusKey");
|
||||
final GlobalKey<EditableTextState> _editableTextKey = new GlobalKey<EditableTextState>();
|
||||
final GlobalKey<EditableTextState> _focusKey = new GlobalKey(debugLabel: "_InputFieldState _focusKey");
|
||||
|
||||
GlobalKey get focusKey => config.focusKey ?? (config.key is GlobalKey ? config.key : _focusKey);
|
||||
|
||||
|
||||
@@ -455,7 +455,7 @@ class RefreshProgressIndicator extends CircularProgressIndicator {
|
||||
}
|
||||
|
||||
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.
|
||||
// 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 {
|
||||
|
||||
// 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;
|
||||
Timer _snackBarTimer;
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ class RenderAnimatedSize extends RenderAligningShiftedBox {
|
||||
|
||||
AnimationController _controller;
|
||||
CurvedAnimation _animation;
|
||||
SizeTween _sizeTween = new SizeTween();
|
||||
final SizeTween _sizeTween = new SizeTween();
|
||||
bool _didChangeTargetSizeLastFrame = false;
|
||||
bool _hasVisualOverflow;
|
||||
double _lastValue;
|
||||
|
||||
@@ -1020,7 +1020,7 @@ class PipelineOwner {
|
||||
}
|
||||
}
|
||||
|
||||
List<RenderObject> _nodesNeedingCompositingBitsUpdate = <RenderObject>[];
|
||||
final List<RenderObject> _nodesNeedingCompositingBitsUpdate = <RenderObject>[];
|
||||
/// Updates the [needsCompositing] bits.
|
||||
///
|
||||
/// Called as part of the rendering pipeline after [flushLayout] and before
|
||||
|
||||
@@ -1079,7 +1079,7 @@ class RenderTable extends RenderBox {
|
||||
}
|
||||
|
||||
// cache the table geometry for painting purposes
|
||||
List<double> _rowTops = <double>[];
|
||||
final List<double> _rowTops = <double>[];
|
||||
List<double> _columnLefts;
|
||||
|
||||
/// Returns the position and dimensions of the box that the given
|
||||
|
||||
@@ -462,7 +462,7 @@ class _DragAvatar<T> extends Drag {
|
||||
final OverlayState overlayState;
|
||||
|
||||
_DragTargetState<T> _activeTarget;
|
||||
List<_DragTargetState<T>> _enteredTargets = <_DragTargetState<T>>[];
|
||||
final List<_DragTargetState<T>> _enteredTargets = <_DragTargetState<T>>[];
|
||||
Point _position;
|
||||
Offset _lastOffset;
|
||||
OverlayEntry _entry;
|
||||
|
||||
@@ -70,7 +70,7 @@ class Form extends StatefulWidget {
|
||||
/// Typically obtained via [Form.of].
|
||||
class FormState extends State<Form> {
|
||||
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
|
||||
// to rebuild, useful if form fields have interdependencies.
|
||||
|
||||
@@ -135,7 +135,7 @@ class Hero extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _HeroState extends State<Hero> {
|
||||
GlobalKey _key = new GlobalKey();
|
||||
final GlobalKey _key = new GlobalKey();
|
||||
Size _placeholderSize;
|
||||
|
||||
void startFlight() {
|
||||
|
||||
@@ -287,8 +287,8 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
|
||||
performRebuild();
|
||||
}
|
||||
|
||||
SplayTreeMap<int, Element> _childElements = new SplayTreeMap<int, Element>();
|
||||
Map<int, Widget> _childWidgets = new HashMap<int, Widget>();
|
||||
final SplayTreeMap<int, Element> _childElements = new SplayTreeMap<int, Element>();
|
||||
final Map<int, Widget> _childWidgets = new HashMap<int, Widget>();
|
||||
RenderBox _currentBeforeChild;
|
||||
|
||||
@override
|
||||
|
||||
@@ -18,7 +18,7 @@ class TestRoute extends LocalHistoryRoute<String> {
|
||||
@override
|
||||
List<OverlayEntry> get overlayEntries => _entries;
|
||||
|
||||
List<OverlayEntry> _entries = <OverlayEntry>[];
|
||||
final List<OverlayEntry> _entries = <OverlayEntry>[];
|
||||
|
||||
void log(String s) {
|
||||
results.add('$name: $s');
|
||||
|
||||
@@ -48,7 +48,7 @@ class TestAsyncUtils {
|
||||
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
|
||||
/// the asynchronous body of the calling method. The calling method is said to
|
||||
|
||||
@@ -427,7 +427,7 @@ class AndroidDevice extends Device {
|
||||
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
|
||||
/// no available timestamp. The format can be passed to logcat's -T option.
|
||||
|
||||
@@ -61,7 +61,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
|
||||
String _gradlePath;
|
||||
String _javaPath;
|
||||
bool _isValid = false;
|
||||
List<String> _validationMessages = <String>[];
|
||||
final List<String> _validationMessages = <String>[];
|
||||
|
||||
factory AndroidStudio.fromMacOSBundle(String bundlePath) {
|
||||
final String studioPath = fs.path.join(bundlePath, 'Contents');
|
||||
|
||||
@@ -11,7 +11,7 @@ typedef void ErrorHandler(dynamic error, StackTrace stackTrace);
|
||||
AppContext get context => Zone.current['context'];
|
||||
|
||||
class AppContext {
|
||||
Map<Type, dynamic> _instances = <Type, dynamic>{};
|
||||
final Map<Type, dynamic> _instances = <Type, dynamic>{};
|
||||
Zone _zone;
|
||||
|
||||
AppContext() : _zone = Zone.current;
|
||||
|
||||
@@ -135,9 +135,9 @@ class BufferLogger extends Logger {
|
||||
@override
|
||||
bool get isVerbose => false;
|
||||
|
||||
StringBuffer _error = new StringBuffer();
|
||||
StringBuffer _status = new StringBuffer();
|
||||
StringBuffer _trace = new StringBuffer();
|
||||
final StringBuffer _error = new StringBuffer();
|
||||
final StringBuffer _status = new StringBuffer();
|
||||
final StringBuffer _trace = new StringBuffer();
|
||||
|
||||
String get errorText => _error.toString();
|
||||
String get statusText => _status.toString();
|
||||
@@ -282,7 +282,7 @@ class AnsiTerminal {
|
||||
String clearScreen() => supportsColor ? _clear : '\n\n';
|
||||
|
||||
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
|
||||
// (requires https://github.com/dart-lang/sdk/issues/29083 to be resolved).
|
||||
try {
|
||||
|
||||
@@ -105,8 +105,8 @@ class ItemListNotifier<T> {
|
||||
|
||||
Set<T> _items;
|
||||
|
||||
StreamController<T> _addedController = new StreamController<T>.broadcast();
|
||||
StreamController<T> _removedController = new StreamController<T>.broadcast();
|
||||
final StreamController<T> _addedController = new StreamController<T>.broadcast();
|
||||
final StreamController<T> _removedController = new StreamController<T>.broadcast();
|
||||
|
||||
Stream<T> get onAdded => _addedController.stream;
|
||||
Stream<T> get onRemoved => _removedController.stream;
|
||||
@@ -168,7 +168,7 @@ class SettingsFile {
|
||||
/// For more information, see
|
||||
/// http://en.wikipedia.org/wiki/Universally_unique_identifier.
|
||||
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
|
||||
/// random numbers as the source of the generated uuid.
|
||||
|
||||
@@ -150,8 +150,8 @@ class AnalysisServer {
|
||||
final List<String> directories;
|
||||
|
||||
Process _process;
|
||||
StreamController<bool> _analyzingController = new StreamController<bool>.broadcast();
|
||||
StreamController<FileAnalysisErrors> _errorsController = new StreamController<FileAnalysisErrors>.broadcast();
|
||||
final StreamController<bool> _analyzingController = new StreamController<bool>.broadcast();
|
||||
final StreamController<FileAnalysisErrors> _errorsController = new StreamController<FileAnalysisErrors>.broadcast();
|
||||
|
||||
int _id = 0;
|
||||
|
||||
|
||||
@@ -286,11 +286,11 @@ class AppDomain extends Domain {
|
||||
registerHandler('discover', discover);
|
||||
}
|
||||
|
||||
static Uuid _uuidGenerator = new Uuid();
|
||||
static final Uuid _uuidGenerator = new Uuid();
|
||||
|
||||
static String _getNewAppId() => _uuidGenerator.generateV4();
|
||||
|
||||
List<AppInstance> _apps = <AppInstance>[];
|
||||
final List<AppInstance> _apps = <AppInstance>[];
|
||||
|
||||
Future<Map<String, dynamic>> start(Map<String, dynamic> args) async {
|
||||
final String deviceId = _getStringArg(args, 'deviceId', required: true);
|
||||
@@ -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]) {
|
||||
final List<Device> devices = _discoverers.expand((PollingDeviceDiscovery discoverer) {
|
||||
@@ -670,7 +670,7 @@ dynamic _toJsonable(dynamic obj) {
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class AnalysisDriver {
|
||||
_processPlugins();
|
||||
}
|
||||
|
||||
Set<Source> _analyzedSources = new HashSet<Source>();
|
||||
final Set<Source> _analyzedSources = new HashSet<Source>();
|
||||
|
||||
AnalysisOptionsProvider analysisOptionsProvider =
|
||||
new AnalysisOptionsProvider();
|
||||
@@ -245,7 +245,7 @@ class PackageInfo {
|
||||
Packages _packages;
|
||||
|
||||
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>>();
|
||||
|
||||
Packages asPackages() => _packages;
|
||||
|
||||
@@ -30,7 +30,7 @@ class DeviceManager {
|
||||
_deviceDiscoverers.add(new IOSSimulators());
|
||||
}
|
||||
|
||||
List<DeviceDiscovery> _deviceDiscoverers = <DeviceDiscovery>[];
|
||||
final List<DeviceDiscovery> _deviceDiscoverers = <DeviceDiscovery>[];
|
||||
|
||||
/// A user-specified device ID.
|
||||
String specifiedDeviceId;
|
||||
|
||||
@@ -96,7 +96,7 @@ class VMService {
|
||||
final Map<String, StreamController<ServiceEvent>> _eventControllers =
|
||||
<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;
|
||||
bool get isClosed => _peer.isClosed;
|
||||
|
||||
Reference in New Issue
Block a user