Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove unused child argument #1272

Merged

Conversation

navaronbracke
Copy link
Collaborator

Fixes #1256

@@ -8,13 +8,6 @@ import 'package:mobile_scanner/src/objects/barcode_capture.dart';
import 'package:mobile_scanner/src/objects/mobile_scanner_state.dart';
import 'package:mobile_scanner/src/scan_window_calculation.dart';

/// The function signature for the error builder.
typedef MobileScannerErrorBuilder = Widget Function(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the function signature is short enough to fit on one line, I opted to remove the typedef

@@ -73,7 +66,7 @@ class MobileScanner extends StatefulWidget {
/// If this is null, a black [ColoredBox] is used as placeholder.
///
/// The placeholder is displayed when the camera preview is being initialized.
final Widget Function(BuildContext, Widget?)? placeholderBuilder;
final WidgetBuilder? placeholderBuilder;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reusing an exiting typedef from the framework here

@@ -203,12 +196,11 @@ class _MobileScannerState extends State<MobileScanner>
Widget build(BuildContext context) {
return ValueListenableBuilder<MobileScannerState>(
valueListenable: controller,
builder: (BuildContext context, MobileScannerState value, Widget? child) {
builder: (BuildContext context, MobileScannerState value, _) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users can create a child widget above the MobileScanner widget in their build method, which makes passing in a child widget redundant here. And as reported, the child parameter was unused, so it didn't add any value to the function signatures

@@ -65,7 +65,7 @@ class _BarcodeScannerWithControllerState
child: Container(
alignment: Alignment.bottomCenter,
height: 100,
color: Colors.black.withOpacity(0.4),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

withOpacity is deprecated, so I replaced it everywhere

@@ -19,7 +19,6 @@ class ScannerErrorWidget extends StatelessWidget {
errorMessage = 'Scanning is unsupported on this device';
default:
errorMessage = 'Generic Error';
break;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter now reports an obsolete break statement here

@navaronbracke navaronbracke merged commit 137466e into juliansteenbakker:ios-vision Jan 4, 2025
4 checks passed
@navaronbracke navaronbracke deleted the placeholder_child branch January 4, 2025 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant