Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 9428081

Browse files
Enable no_leading_underscores_for_local_identifiers (#6509)
1 parent 7aa678e commit 9428081

File tree

83 files changed

+675
-616
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+675
-616
lines changed

analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ linter:
143143
# - no_default_cases # LOCAL CHANGE - Needs to be enabled and violations fixed.
144144
- no_duplicate_case_values
145145
- no_leading_underscores_for_library_prefixes
146-
# - no_leading_underscores_for_local_identifiers # LOCAL CHANGE - Needs to be enabled and violations fixed.
146+
- no_leading_underscores_for_local_identifiers
147147
- no_logic_in_create_state
148148
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
149149
- non_constant_identifier_names

packages/camera/camera/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.10.0+3
2+
3+
* Updates code for `no_leading_underscores_for_local_identifiers` lint.
4+
15
## 0.10.0+2
26

37
* Updates imports for `prefer_relative_imports`.

packages/camera/camera/example/integration_test/camera_test.dart

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,16 @@ void main() {
221221
);
222222

223223
await controller.initialize();
224-
bool _isDetecting = false;
224+
bool isDetecting = false;
225225

226226
await controller.startImageStream((CameraImage image) {
227-
if (_isDetecting) {
227+
if (isDetecting) {
228228
return;
229229
}
230230

231-
_isDetecting = true;
231+
isDetecting = true;
232232

233-
expectLater(image, isNotNull).whenComplete(() => _isDetecting = false);
233+
expectLater(image, isNotNull).whenComplete(() => isDetecting = false);
234234
});
235235

236236
expect(controller.value.isStreamingImages, true);
@@ -254,19 +254,19 @@ void main() {
254254
);
255255

256256
await controller.initialize();
257-
final Completer<CameraImage> _completer = Completer<CameraImage>();
257+
final Completer<CameraImage> completer = Completer<CameraImage>();
258258

259259
await controller.startImageStream((CameraImage image) {
260-
if (!_completer.isCompleted) {
260+
if (!completer.isCompleted) {
261261
Future<void>(() async {
262262
await controller.stopImageStream();
263263
await controller.dispose();
264264
}).then((Object? value) {
265-
_completer.complete(image);
265+
completer.complete(image);
266266
});
267267
}
268268
});
269-
return _completer.future;
269+
return completer.future;
270270
}
271271

272272
testWidgets(
@@ -277,20 +277,20 @@ void main() {
277277
return;
278278
}
279279

280-
CameraImage _image = await startStreaming(cameras, null);
281-
expect(_image, isNotNull);
282-
expect(_image.format.group, ImageFormatGroup.bgra8888);
283-
expect(_image.planes.length, 1);
280+
CameraImage image = await startStreaming(cameras, null);
281+
expect(image, isNotNull);
282+
expect(image.format.group, ImageFormatGroup.bgra8888);
283+
expect(image.planes.length, 1);
284284

285-
_image = await startStreaming(cameras, ImageFormatGroup.yuv420);
286-
expect(_image, isNotNull);
287-
expect(_image.format.group, ImageFormatGroup.yuv420);
288-
expect(_image.planes.length, 2);
285+
image = await startStreaming(cameras, ImageFormatGroup.yuv420);
286+
expect(image, isNotNull);
287+
expect(image.format.group, ImageFormatGroup.yuv420);
288+
expect(image.planes.length, 2);
289289

290-
_image = await startStreaming(cameras, ImageFormatGroup.bgra8888);
291-
expect(_image, isNotNull);
292-
expect(_image.format.group, ImageFormatGroup.bgra8888);
293-
expect(_image.planes.length, 1);
290+
image = await startStreaming(cameras, ImageFormatGroup.bgra8888);
291+
expect(image, isNotNull);
292+
expect(image.format.group, ImageFormatGroup.bgra8888);
293+
expect(image.planes.length, 1);
294294
},
295295
skip: !Platform.isIOS,
296296
);

packages/camera/camera/lib/src/camera_controller.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class CameraController extends ValueNotifier<CameraValue> {
282282
);
283283
}
284284
try {
285-
final Completer<CameraInitializedEvent> _initializeCompleter =
285+
final Completer<CameraInitializedEvent> initializeCompleter =
286286
Completer<CameraInitializedEvent>();
287287

288288
_deviceOrientationSubscription = CameraPlatform.instance
@@ -303,7 +303,7 @@ class CameraController extends ValueNotifier<CameraValue> {
303303
.onCameraInitialized(_cameraId)
304304
.first
305305
.then((CameraInitializedEvent event) {
306-
_initializeCompleter.complete(event);
306+
initializeCompleter.complete(event);
307307
}));
308308

309309
await CameraPlatform.instance.initializeCamera(
@@ -313,18 +313,18 @@ class CameraController extends ValueNotifier<CameraValue> {
313313

314314
value = value.copyWith(
315315
isInitialized: true,
316-
previewSize: await _initializeCompleter.future
316+
previewSize: await initializeCompleter.future
317317
.then((CameraInitializedEvent event) => Size(
318318
event.previewWidth,
319319
event.previewHeight,
320320
)),
321-
exposureMode: await _initializeCompleter.future
321+
exposureMode: await initializeCompleter.future
322322
.then((CameraInitializedEvent event) => event.exposureMode),
323-
focusMode: await _initializeCompleter.future
323+
focusMode: await initializeCompleter.future
324324
.then((CameraInitializedEvent event) => event.focusMode),
325-
exposurePointSupported: await _initializeCompleter.future.then(
325+
exposurePointSupported: await initializeCompleter.future.then(
326326
(CameraInitializedEvent event) => event.exposurePointSupported),
327-
focusPointSupported: await _initializeCompleter.future
327+
focusPointSupported: await initializeCompleter.future
328328
.then((CameraInitializedEvent event) => event.focusPointSupported),
329329
);
330330
} on PlatformException catch (e) {

packages/camera/camera/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing
44
Dart.
55
repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera
66
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
7-
version: 0.10.0+2
7+
version: 0.10.0+3
88

99
environment:
1010
sdk: ">=2.14.0 <3.0.0"

packages/camera/camera_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.10.0+3
2+
3+
* Updates code for `no_leading_underscores_for_local_identifiers` lint.
4+
15
## 0.10.0+2
26

37
* Removes call to `join` on the camera's background `HandlerThread`.

packages/camera/camera_android/example/integration_test/camera_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,16 @@ void main() {
225225
);
226226

227227
await controller.initialize();
228-
bool _isDetecting = false;
228+
bool isDetecting = false;
229229

230230
await controller.startImageStream((CameraImageData image) {
231-
if (_isDetecting) {
231+
if (isDetecting) {
232232
return;
233233
}
234234

235-
_isDetecting = true;
235+
isDetecting = true;
236236

237-
expectLater(image, isNotNull).whenComplete(() => _isDetecting = false);
237+
expectLater(image, isNotNull).whenComplete(() => isDetecting = false);
238238
});
239239

240240
expect(controller.value.isStreamingImages, true);

packages/camera/camera_android/example/lib/camera_controller.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class CameraController extends ValueNotifier<CameraValue> {
203203

204204
/// Initializes the camera on the device.
205205
Future<void> initialize() async {
206-
final Completer<CameraInitializedEvent> _initializeCompleter =
206+
final Completer<CameraInitializedEvent> initializeCompleter =
207207
Completer<CameraInitializedEvent>();
208208

209209
_deviceOrientationSubscription = CameraPlatform.instance
@@ -224,7 +224,7 @@ class CameraController extends ValueNotifier<CameraValue> {
224224
.onCameraInitialized(_cameraId)
225225
.first
226226
.then((CameraInitializedEvent event) {
227-
_initializeCompleter.complete(event);
227+
initializeCompleter.complete(event);
228228
});
229229

230230
await CameraPlatform.instance.initializeCamera(
@@ -234,18 +234,18 @@ class CameraController extends ValueNotifier<CameraValue> {
234234

235235
value = value.copyWith(
236236
isInitialized: true,
237-
previewSize: await _initializeCompleter.future
237+
previewSize: await initializeCompleter.future
238238
.then((CameraInitializedEvent event) => Size(
239239
event.previewWidth,
240240
event.previewHeight,
241241
)),
242-
exposureMode: await _initializeCompleter.future
242+
exposureMode: await initializeCompleter.future
243243
.then((CameraInitializedEvent event) => event.exposureMode),
244-
focusMode: await _initializeCompleter.future
244+
focusMode: await initializeCompleter.future
245245
.then((CameraInitializedEvent event) => event.focusMode),
246-
exposurePointSupported: await _initializeCompleter.future
246+
exposurePointSupported: await initializeCompleter.future
247247
.then((CameraInitializedEvent event) => event.exposurePointSupported),
248-
focusPointSupported: await _initializeCompleter.future
248+
focusPointSupported: await initializeCompleter.future
249249
.then((CameraInitializedEvent event) => event.focusPointSupported),
250250
);
251251

packages/camera/camera_android/lib/src/android_camera.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ class AndroidCamera extends CameraPlatform {
126126
return channel;
127127
});
128128

129-
final Completer<void> _completer = Completer<void>();
129+
final Completer<void> completer = Completer<void>();
130130

131131
onCameraInitialized(cameraId).first.then((CameraInitializedEvent value) {
132-
_completer.complete();
132+
completer.complete();
133133
});
134134

135135
_channel.invokeMapMethod<String, dynamic>(
@@ -147,14 +147,14 @@ class AndroidCamera extends CameraPlatform {
147147
if (error is! PlatformException) {
148148
throw error;
149149
}
150-
_completer.completeError(
150+
completer.completeError(
151151
CameraException(error.code, error.message),
152152
stackTrace,
153153
);
154154
},
155155
);
156156

157-
return _completer.future;
157+
return completer.future;
158158
}
159159

160160
@override

packages/camera/camera_android/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_android
22
description: Android implementation of the camera plugin.
33
repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.10.0+2
5+
version: 0.10.0+3
66

77
environment:
88
sdk: ">=2.14.0 <3.0.0"

packages/camera/camera_avfoundation/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 0.9.8+6
22

3+
* Updates code for `no_leading_underscores_for_local_identifiers` lint.
34
* Updates minimum Flutter version to 2.10.
45

56
## 0.9.8+5

packages/camera/camera_avfoundation/example/integration_test/camera_test.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,19 @@ void main() {
213213
);
214214

215215
await controller.initialize();
216-
final Completer<CameraImageData> _completer = Completer<CameraImageData>();
216+
final Completer<CameraImageData> completer = Completer<CameraImageData>();
217217

218218
await controller.startImageStream((CameraImageData image) {
219-
if (!_completer.isCompleted) {
219+
if (!completer.isCompleted) {
220220
Future<void>(() async {
221221
await controller.stopImageStream();
222222
await controller.dispose();
223223
}).then((Object? value) {
224-
_completer.complete(image);
224+
completer.complete(image);
225225
});
226226
}
227227
});
228-
return _completer.future;
228+
return completer.future;
229229
}
230230

231231
testWidgets(
@@ -237,20 +237,20 @@ void main() {
237237
return;
238238
}
239239

240-
CameraImageData _image = await startStreaming(cameras, null);
241-
expect(_image, isNotNull);
242-
expect(_image.format.group, ImageFormatGroup.bgra8888);
243-
expect(_image.planes.length, 1);
240+
CameraImageData image = await startStreaming(cameras, null);
241+
expect(image, isNotNull);
242+
expect(image.format.group, ImageFormatGroup.bgra8888);
243+
expect(image.planes.length, 1);
244244

245-
_image = await startStreaming(cameras, ImageFormatGroup.yuv420);
246-
expect(_image, isNotNull);
247-
expect(_image.format.group, ImageFormatGroup.yuv420);
248-
expect(_image.planes.length, 2);
245+
image = await startStreaming(cameras, ImageFormatGroup.yuv420);
246+
expect(image, isNotNull);
247+
expect(image.format.group, ImageFormatGroup.yuv420);
248+
expect(image.planes.length, 2);
249249

250-
_image = await startStreaming(cameras, ImageFormatGroup.bgra8888);
251-
expect(_image, isNotNull);
252-
expect(_image.format.group, ImageFormatGroup.bgra8888);
253-
expect(_image.planes.length, 1);
250+
image = await startStreaming(cameras, ImageFormatGroup.bgra8888);
251+
expect(image, isNotNull);
252+
expect(image.format.group, ImageFormatGroup.bgra8888);
253+
expect(image.planes.length, 1);
254254
},
255255
);
256256
}

packages/camera/camera_avfoundation/example/lib/camera_controller.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class CameraController extends ValueNotifier<CameraValue> {
203203

204204
/// Initializes the camera on the device.
205205
Future<void> initialize() async {
206-
final Completer<CameraInitializedEvent> _initializeCompleter =
206+
final Completer<CameraInitializedEvent> initializeCompleter =
207207
Completer<CameraInitializedEvent>();
208208

209209
_deviceOrientationSubscription = CameraPlatform.instance
@@ -224,7 +224,7 @@ class CameraController extends ValueNotifier<CameraValue> {
224224
.onCameraInitialized(_cameraId)
225225
.first
226226
.then((CameraInitializedEvent event) {
227-
_initializeCompleter.complete(event);
227+
initializeCompleter.complete(event);
228228
});
229229

230230
await CameraPlatform.instance.initializeCamera(
@@ -234,18 +234,18 @@ class CameraController extends ValueNotifier<CameraValue> {
234234

235235
value = value.copyWith(
236236
isInitialized: true,
237-
previewSize: await _initializeCompleter.future
237+
previewSize: await initializeCompleter.future
238238
.then((CameraInitializedEvent event) => Size(
239239
event.previewWidth,
240240
event.previewHeight,
241241
)),
242-
exposureMode: await _initializeCompleter.future
242+
exposureMode: await initializeCompleter.future
243243
.then((CameraInitializedEvent event) => event.exposureMode),
244-
focusMode: await _initializeCompleter.future
244+
focusMode: await initializeCompleter.future
245245
.then((CameraInitializedEvent event) => event.focusMode),
246-
exposurePointSupported: await _initializeCompleter.future
246+
exposurePointSupported: await initializeCompleter.future
247247
.then((CameraInitializedEvent event) => event.exposurePointSupported),
248-
focusPointSupported: await _initializeCompleter.future
248+
focusPointSupported: await initializeCompleter.future
249249
.then((CameraInitializedEvent event) => event.focusPointSupported),
250250
);
251251

packages/camera/camera_avfoundation/lib/src/avfoundation_camera.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ class AVFoundationCamera extends CameraPlatform {
126126
return channel;
127127
});
128128

129-
final Completer<void> _completer = Completer<void>();
129+
final Completer<void> completer = Completer<void>();
130130

131131
onCameraInitialized(cameraId).first.then((CameraInitializedEvent value) {
132-
_completer.complete();
132+
completer.complete();
133133
});
134134

135135
_channel.invokeMapMethod<String, dynamic>(
@@ -147,14 +147,14 @@ class AVFoundationCamera extends CameraPlatform {
147147
if (error is! PlatformException) {
148148
throw error;
149149
}
150-
_completer.completeError(
150+
completer.completeError(
151151
CameraException(error.code, error.message),
152152
stackTrace,
153153
);
154154
},
155155
);
156156

157-
return _completer.future;
157+
return completer.future;
158158
}
159159

160160
@override

0 commit comments

Comments
 (0)