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

Commit 6766f22

Browse files
authored
Revert "Revert "Enable lints library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors" (#5691)"
This reverts commit edfd9c0.
1 parent edfd9c0 commit 6766f22

File tree

231 files changed

+948
-574
lines changed

Some content is hidden

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

231 files changed

+948
-574
lines changed

analysis_options.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ linter:
134134
- leading_newlines_in_multiline_strings
135135
- library_names
136136
- library_prefixes
137+
- library_private_types_in_public_api
137138
# - lines_longer_than_80_chars # not required by flutter style
138139
- list_remove_unrelated_type
139140
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
@@ -197,7 +198,7 @@ linter:
197198
- recursive_getters
198199
# - sized_box_for_whitespace # not yet tested
199200
- slash_for_doc_comments
200-
# - sort_child_properties_last # not yet tested
201+
- sort_child_properties_last
201202
- sort_constructors_first
202203
- sort_unnamed_constructors_first
203204
- test_types_in_equals
@@ -229,7 +230,7 @@ linter:
229230
- use_full_hex_values_for_flutter_colors
230231
# - use_function_type_syntax_for_parameters # not yet tested
231232
- use_is_even_rather_than_modulo
232-
# - use_key_in_widget_constructors # not yet tested
233+
- use_key_in_widget_constructors
233234
- use_late_for_private_fields_and_variables
234235
- use_raw_strings
235236
- use_rethrow_when_possible

packages/camera/camera/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
## NEXT
1+
## 0.9.4+22
22

33
* Removes unnecessary imports.
4+
* Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors
5+
lint warnings.
46

57
## 0.9.4+21
68

packages/camera/camera/README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,22 @@ Here is a small example flutter app displaying a full screen camera preview.
8989
import 'package:camera/camera.dart';
9090
import 'package:flutter/material.dart';
9191
92-
late List<CameraDescription> cameras;
92+
late List<CameraDescription> _cameras;
9393
9494
Future<void> main() async {
9595
WidgetsFlutterBinding.ensureInitialized();
9696
97-
cameras = await availableCameras();
98-
runApp(CameraApp());
97+
_cameras = await availableCameras();
98+
runApp(const CameraApp());
9999
}
100100
101+
/// CameraApp is the Main Application.
101102
class CameraApp extends StatefulWidget {
103+
/// Default Constructor
104+
const CameraApp({Key? key}) : super(key: key);
105+
102106
@override
103-
_CameraAppState createState() => _CameraAppState();
107+
State<CameraApp> createState() => _CameraAppState();
104108
}
105109
106110
class _CameraAppState extends State<CameraApp> {
@@ -109,7 +113,7 @@ class _CameraAppState extends State<CameraApp> {
109113
@override
110114
void initState() {
111115
super.initState();
112-
controller = CameraController(cameras[0], ResolutionPreset.max);
116+
controller = CameraController(_cameras[0], ResolutionPreset.max);
113117
controller.initialize().then((_) {
114118
if (!mounted) {
115119
return;

packages/camera/camera/example/lib/main.dart

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// ignore_for_file: public_member_api_docs
6-
75
import 'dart:async';
86
import 'dart:io';
97

@@ -13,9 +11,13 @@ import 'package:flutter/material.dart';
1311
import 'package:flutter/scheduler.dart';
1412
import 'package:video_player/video_player.dart';
1513

14+
/// Camera example home widget.
1615
class CameraExampleHome extends StatefulWidget {
16+
/// Default Constructor
17+
const CameraExampleHome({Key? key}) : super(key: key);
18+
1719
@override
18-
_CameraExampleHomeState createState() {
20+
State<CameraExampleHome> createState() {
1921
return _CameraExampleHomeState();
2022
}
2123
}
@@ -34,7 +36,7 @@ IconData getCameraLensIcon(CameraLensDirection direction) {
3436
}
3537
}
3638

37-
void logError(String code, String? message) {
39+
void _logError(String code, String? message) {
3840
if (message != null) {
3941
print('Error: $code\nError Message: $message');
4042
} else {
@@ -134,12 +136,6 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
134136
children: <Widget>[
135137
Expanded(
136138
child: Container(
137-
child: Padding(
138-
padding: const EdgeInsets.all(1.0),
139-
child: Center(
140-
child: _cameraPreviewWidget(),
141-
),
142-
),
143139
decoration: BoxDecoration(
144140
color: Colors.black,
145141
border: Border.all(
@@ -150,6 +146,12 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
150146
width: 3.0,
151147
),
152148
),
149+
child: Padding(
150+
padding: const EdgeInsets.all(1.0),
151+
child: Center(
152+
child: _cameraPreviewWidget(),
153+
),
154+
),
153155
),
154156
),
155157
_captureControlRowWidget(),
@@ -233,6 +235,8 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
233235
Container()
234236
else
235237
SizedBox(
238+
width: 64.0,
239+
height: 64.0,
236240
child: (localVideoController == null)
237241
? (
238242
// The captured image on the web contains a network-accessible URL
@@ -243,6 +247,8 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
243247
? Image.network(imageFile!.path)
244248
: Image.file(File(imageFile!.path)))
245249
: Container(
250+
decoration: BoxDecoration(
251+
border: Border.all(color: Colors.pink)),
246252
child: Center(
247253
child: AspectRatio(
248254
aspectRatio:
@@ -251,11 +257,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
251257
: 1.0,
252258
child: VideoPlayer(localVideoController)),
253259
),
254-
decoration: BoxDecoration(
255-
border: Border.all(color: Colors.pink)),
256260
),
257-
width: 64.0,
258-
height: 64.0,
259261
),
260262
],
261263
),
@@ -394,7 +396,6 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
394396
mainAxisSize: MainAxisSize.max,
395397
children: <Widget>[
396398
TextButton(
397-
child: const Text('AUTO'),
398399
style: styleAuto,
399400
onPressed: controller != null
400401
? () =>
@@ -406,21 +407,22 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
406407
showInSnackBar('Resetting exposure point');
407408
}
408409
},
410+
child: const Text('AUTO'),
409411
),
410412
TextButton(
411-
child: const Text('LOCKED'),
412413
style: styleLocked,
413414
onPressed: controller != null
414415
? () =>
415416
onSetExposureModeButtonPressed(ExposureMode.locked)
416417
: null,
418+
child: const Text('LOCKED'),
417419
),
418420
TextButton(
419-
child: const Text('RESET OFFSET'),
420421
style: styleLocked,
421422
onPressed: controller != null
422423
? () => controller!.setExposureOffset(0.0)
423424
: null,
425+
child: const Text('RESET OFFSET'),
424426
),
425427
],
426428
),
@@ -479,7 +481,6 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
479481
mainAxisSize: MainAxisSize.max,
480482
children: <Widget>[
481483
TextButton(
482-
child: const Text('AUTO'),
483484
style: styleAuto,
484485
onPressed: controller != null
485486
? () => onSetFocusModeButtonPressed(FocusMode.auto)
@@ -490,13 +491,14 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
490491
}
491492
showInSnackBar('Resetting focus point');
492493
},
494+
child: const Text('AUTO'),
493495
),
494496
TextButton(
495-
child: const Text('LOCKED'),
496497
style: styleLocked,
497498
onPressed: controller != null
498499
? () => onSetFocusModeButtonPressed(FocusMode.locked)
499500
: null,
501+
child: const Text('LOCKED'),
500502
),
501503
],
502504
),
@@ -582,13 +584,13 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
582584
onNewCameraSelected(description);
583585
};
584586

585-
if (cameras.isEmpty) {
587+
if (_cameras.isEmpty) {
586588
_ambiguate(SchedulerBinding.instance)?.addPostFrameCallback((_) async {
587589
showInSnackBar('No camera found.');
588590
});
589591
return const Text('None');
590592
} else {
591-
for (final CameraDescription cameraDescription in cameras) {
593+
for (final CameraDescription cameraDescription in _cameras) {
592594
toggles.add(
593595
SizedBox(
594596
width: 90.0,
@@ -1014,31 +1016,35 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
10141016
}
10151017

10161018
void _showCameraException(CameraException e) {
1017-
logError(e.code, e.description);
1019+
_logError(e.code, e.description);
10181020
showInSnackBar('Error: ${e.code}\n${e.description}');
10191021
}
10201022
}
10211023

1024+
/// CameraApp is the Main Application.
10221025
class CameraApp extends StatelessWidget {
1026+
/// Default Constructor
1027+
const CameraApp({Key? key}) : super(key: key);
1028+
10231029
@override
10241030
Widget build(BuildContext context) {
1025-
return MaterialApp(
1031+
return const MaterialApp(
10261032
home: CameraExampleHome(),
10271033
);
10281034
}
10291035
}
10301036

1031-
List<CameraDescription> cameras = <CameraDescription>[];
1037+
List<CameraDescription> _cameras = <CameraDescription>[];
10321038

10331039
Future<void> main() async {
10341040
// Fetch the available cameras before initializing the app.
10351041
try {
10361042
WidgetsFlutterBinding.ensureInitialized();
1037-
cameras = await availableCameras();
1043+
_cameras = await availableCameras();
10381044
} on CameraException catch (e) {
1039-
logError(e.code, e.description);
1045+
_logError(e.code, e.description);
10401046
}
1041-
runApp(CameraApp());
1047+
runApp(const CameraApp());
10421048
}
10431049

10441050
/// This allows a value of type T or T? to be treated as a value of type T?.

packages/camera/camera/example/lib/readme_full_example.dart

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// ignore_for_file: public_member_api_docs
6-
75
// #docregion FullAppExample
86
import 'package:camera/camera.dart';
97
import 'package:flutter/material.dart';
108

11-
late List<CameraDescription> cameras;
9+
late List<CameraDescription> _cameras;
1210

1311
Future<void> main() async {
1412
WidgetsFlutterBinding.ensureInitialized();
1513

16-
cameras = await availableCameras();
17-
runApp(CameraApp());
14+
_cameras = await availableCameras();
15+
runApp(const CameraApp());
1816
}
1917

18+
/// CameraApp is the Main Application.
2019
class CameraApp extends StatefulWidget {
20+
/// Default Constructor
21+
const CameraApp({Key? key}) : super(key: key);
22+
2123
@override
22-
_CameraAppState createState() => _CameraAppState();
24+
State<CameraApp> createState() => _CameraAppState();
2325
}
2426

2527
class _CameraAppState extends State<CameraApp> {
@@ -28,7 +30,7 @@ class _CameraAppState extends State<CameraApp> {
2830
@override
2931
void initState() {
3032
super.initState();
31-
controller = CameraController(cameras[0], ResolutionPreset.max);
33+
controller = CameraController(_cameras[0], ResolutionPreset.max);
3234
controller.initialize().then((_) {
3335
if (!mounted) {
3436
return;

packages/camera/camera/example/test/main_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
99
void main() {
1010
testWidgets('Test snackbar', (WidgetTester tester) async {
1111
WidgetsFlutterBinding.ensureInitialized();
12-
await tester.pumpWidget(CameraApp());
12+
await tester.pumpWidget(const CameraApp());
1313
await tester.pumpAndSettle();
1414
expect(find.byType(SnackBar), findsOneWidget);
1515
});

packages/camera/camera/lib/src/camera_preview.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import 'package:flutter/services.dart';
1010
/// A widget showing a live camera preview.
1111
class CameraPreview extends StatelessWidget {
1212
/// Creates a preview widget for the given camera controller.
13-
const CameraPreview(this.controller, {this.child});
13+
const CameraPreview(this.controller, {Key? key, this.child})
14+
: super(key: key);
1415

1516
/// The controller for the camera that the preview is shown for.
1617
final CameraController controller;

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.9.4+21
7+
version: 0.9.4+22
88

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

packages/camera/camera_web/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.2.1+5
2+
3+
* Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors
4+
lint warnings.
5+
16
## 0.2.1+4
27

38
* Migrates from `ui.hash*` to `Object.hash*`.

packages/camera/camera_web/example/lib/main.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55
import 'package:flutter/material.dart';
66

7-
void main() => runApp(MyApp());
7+
void main() => runApp(const MyApp());
88

99
/// App for testing
1010
class MyApp extends StatelessWidget {
11+
/// Default Constructor
12+
const MyApp({Key? key}) : super(key: key);
13+
1114
@override
1215
Widget build(BuildContext context) {
1316
return const Directionality(

packages/camera/camera_web/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_web
22
description: A Flutter plugin for getting information about and controlling the camera on Web.
33
repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera_web
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.2.1+4
5+
version: 0.2.1+5
66

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

packages/camera/camera_windows/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
## NEXT
1+
## 0.1.0+1
22

33
* Removes unnecessary imports.
4+
* Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors
5+
lint warnings.
46

57
## 0.1.0
68

0 commit comments

Comments
 (0)