Skip to content

Conversation

navaronbracke
Copy link
Collaborator

Fixes #1256

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

///
/// 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

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

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

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