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

Revert "Enable lints library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors" #5691

Merged
merged 3 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ linter:
- leading_newlines_in_multiline_strings
- library_names
- library_prefixes
- library_private_types_in_public_api
# - lines_longer_than_80_chars # not required by flutter style
- list_remove_unrelated_type
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
Expand Down Expand Up @@ -198,7 +197,7 @@ linter:
- recursive_getters
# - sized_box_for_whitespace # not yet tested
- slash_for_doc_comments
- sort_child_properties_last
# - sort_child_properties_last # not yet tested
- sort_constructors_first
- sort_unnamed_constructors_first
- test_types_in_equals
Expand Down Expand Up @@ -230,7 +229,7 @@ linter:
- use_full_hex_values_for_flutter_colors
# - use_function_type_syntax_for_parameters # not yet tested
- use_is_even_rather_than_modulo
- use_key_in_widget_constructors
# - use_key_in_widget_constructors # not yet tested
- use_late_for_private_fields_and_variables
- use_raw_strings
- use_rethrow_when_possible
Expand Down
4 changes: 1 addition & 3 deletions packages/camera/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
## 0.9.4+22
## NEXT

* Removes unnecessary imports.
* Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors
lint warnings.

## 0.9.4+21

Expand Down
14 changes: 5 additions & 9 deletions packages/camera/camera/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,18 @@ Here is a small example flutter app displaying a full screen camera preview.
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';

late List<CameraDescription> _cameras;
late List<CameraDescription> cameras;

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

_cameras = await availableCameras();
runApp(const CameraApp());
cameras = await availableCameras();
runApp(CameraApp());
}

/// CameraApp is the Main Application.
class CameraApp extends StatefulWidget {
/// Default Constructor
const CameraApp({Key? key}) : super(key: key);

@override
State<CameraApp> createState() => _CameraAppState();
_CameraAppState createState() => _CameraAppState();
}

class _CameraAppState extends State<CameraApp> {
Expand All @@ -113,7 +109,7 @@ class _CameraAppState extends State<CameraApp> {
@override
void initState() {
super.initState();
controller = CameraController(_cameras[0], ResolutionPreset.max);
controller = CameraController(cameras[0], ResolutionPreset.max);
controller.initialize().then((_) {
if (!mounted) {
return;
Expand Down
60 changes: 27 additions & 33 deletions packages/camera/camera/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// ignore_for_file: public_member_api_docs

import 'dart:async';
import 'dart:io';

Expand All @@ -11,13 +13,9 @@ import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:video_player/video_player.dart';

/// Camera example home widget.
class CameraExampleHome extends StatefulWidget {
/// Default Constructor
const CameraExampleHome({Key? key}) : super(key: key);

@override
State<CameraExampleHome> createState() {
_CameraExampleHomeState createState() {
return _CameraExampleHomeState();
}
}
Expand All @@ -36,7 +34,7 @@ IconData getCameraLensIcon(CameraLensDirection direction) {
}
}

void _logError(String code, String? message) {
void logError(String code, String? message) {
if (message != null) {
print('Error: $code\nError Message: $message');
} else {
Expand Down Expand Up @@ -136,6 +134,12 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
children: <Widget>[
Expanded(
child: Container(
child: Padding(
padding: const EdgeInsets.all(1.0),
child: Center(
child: _cameraPreviewWidget(),
),
),
decoration: BoxDecoration(
color: Colors.black,
border: Border.all(
Expand All @@ -146,12 +150,6 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
width: 3.0,
),
),
child: Padding(
padding: const EdgeInsets.all(1.0),
child: Center(
child: _cameraPreviewWidget(),
),
),
),
),
_captureControlRowWidget(),
Expand Down Expand Up @@ -235,8 +233,6 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
Container()
else
SizedBox(
width: 64.0,
height: 64.0,
child: (localVideoController == null)
? (
// The captured image on the web contains a network-accessible URL
Expand All @@ -247,8 +243,6 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
? Image.network(imageFile!.path)
: Image.file(File(imageFile!.path)))
: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.pink)),
child: Center(
child: AspectRatio(
aspectRatio:
Expand All @@ -257,7 +251,11 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
: 1.0,
child: VideoPlayer(localVideoController)),
),
decoration: BoxDecoration(
border: Border.all(color: Colors.pink)),
),
width: 64.0,
height: 64.0,
),
],
),
Expand Down Expand Up @@ -396,6 +394,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
mainAxisSize: MainAxisSize.max,
children: <Widget>[
TextButton(
child: const Text('AUTO'),
style: styleAuto,
onPressed: controller != null
? () =>
Expand All @@ -407,22 +406,21 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
showInSnackBar('Resetting exposure point');
}
},
child: const Text('AUTO'),
),
TextButton(
child: const Text('LOCKED'),
style: styleLocked,
onPressed: controller != null
? () =>
onSetExposureModeButtonPressed(ExposureMode.locked)
: null,
child: const Text('LOCKED'),
),
TextButton(
child: const Text('RESET OFFSET'),
style: styleLocked,
onPressed: controller != null
? () => controller!.setExposureOffset(0.0)
: null,
child: const Text('RESET OFFSET'),
),
],
),
Expand Down Expand Up @@ -481,6 +479,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
mainAxisSize: MainAxisSize.max,
children: <Widget>[
TextButton(
child: const Text('AUTO'),
style: styleAuto,
onPressed: controller != null
? () => onSetFocusModeButtonPressed(FocusMode.auto)
Expand All @@ -491,14 +490,13 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
}
showInSnackBar('Resetting focus point');
},
child: const Text('AUTO'),
),
TextButton(
child: const Text('LOCKED'),
style: styleLocked,
onPressed: controller != null
? () => onSetFocusModeButtonPressed(FocusMode.locked)
: null,
child: const Text('LOCKED'),
),
],
),
Expand Down Expand Up @@ -584,13 +582,13 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
onNewCameraSelected(description);
};

if (_cameras.isEmpty) {
if (cameras.isEmpty) {
_ambiguate(SchedulerBinding.instance)?.addPostFrameCallback((_) async {
showInSnackBar('No camera found.');
});
return const Text('None');
} else {
for (final CameraDescription cameraDescription in _cameras) {
for (final CameraDescription cameraDescription in cameras) {
toggles.add(
SizedBox(
width: 90.0,
Expand Down Expand Up @@ -1016,35 +1014,31 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
}

void _showCameraException(CameraException e) {
_logError(e.code, e.description);
logError(e.code, e.description);
showInSnackBar('Error: ${e.code}\n${e.description}');
}
}

/// CameraApp is the Main Application.
class CameraApp extends StatelessWidget {
/// Default Constructor
const CameraApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return const MaterialApp(
return MaterialApp(
home: CameraExampleHome(),
);
}
}

List<CameraDescription> _cameras = <CameraDescription>[];
List<CameraDescription> cameras = <CameraDescription>[];

Future<void> main() async {
// Fetch the available cameras before initializing the app.
try {
WidgetsFlutterBinding.ensureInitialized();
_cameras = await availableCameras();
cameras = await availableCameras();
} on CameraException catch (e) {
_logError(e.code, e.description);
logError(e.code, e.description);
}
runApp(const CameraApp());
runApp(CameraApp());
}

/// This allows a value of type T or T? to be treated as a value of type T?.
Expand Down
16 changes: 7 additions & 9 deletions packages/camera/camera/example/lib/readme_full_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// ignore_for_file: public_member_api_docs

// #docregion FullAppExample
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';

late List<CameraDescription> _cameras;
late List<CameraDescription> cameras;

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

_cameras = await availableCameras();
runApp(const CameraApp());
cameras = await availableCameras();
runApp(CameraApp());
}

/// CameraApp is the Main Application.
class CameraApp extends StatefulWidget {
/// Default Constructor
const CameraApp({Key? key}) : super(key: key);

@override
State<CameraApp> createState() => _CameraAppState();
_CameraAppState createState() => _CameraAppState();
}

class _CameraAppState extends State<CameraApp> {
Expand All @@ -30,7 +28,7 @@ class _CameraAppState extends State<CameraApp> {
@override
void initState() {
super.initState();
controller = CameraController(_cameras[0], ResolutionPreset.max);
controller = CameraController(cameras[0], ResolutionPreset.max);
controller.initialize().then((_) {
if (!mounted) {
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera/example/test/main_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Test snackbar', (WidgetTester tester) async {
WidgetsFlutterBinding.ensureInitialized();
await tester.pumpWidget(const CameraApp());
await tester.pumpWidget(CameraApp());
await tester.pumpAndSettle();
expect(find.byType(SnackBar), findsOneWidget);
});
Expand Down
3 changes: 1 addition & 2 deletions packages/camera/camera/lib/src/camera_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import 'package:flutter/services.dart';
/// A widget showing a live camera preview.
class CameraPreview extends StatelessWidget {
/// Creates a preview widget for the given camera controller.
const CameraPreview(this.controller, {Key? key, this.child})
: super(key: key);
const CameraPreview(this.controller, {this.child});

/// The controller for the camera that the preview is shown for.
final CameraController controller;
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing
Dart.
repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.9.4+22
version: 0.9.4+21

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down
5 changes: 0 additions & 5 deletions packages/camera/camera_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
## 0.2.1+5

* Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors
lint warnings.

## 0.2.1+4

* Migrates from `ui.hash*` to `Object.hash*`.
Expand Down
5 changes: 1 addition & 4 deletions packages/camera/camera_web/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@

import 'package:flutter/material.dart';

void main() => runApp(const MyApp());
void main() => runApp(MyApp());

/// App for testing
class MyApp extends StatelessWidget {
/// Default Constructor
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return const Directionality(
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_web
description: A Flutter plugin for getting information about and controlling the camera on Web.
repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.2.1+5
version: 0.2.1+4

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
4 changes: 1 addition & 3 deletions packages/camera/camera_windows/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
## 0.1.0+1
## NEXT

* Removes unnecessary imports.
* Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors
lint warnings.

## 0.1.0

Expand Down
Loading