-
-
Notifications
You must be signed in to change notification settings - Fork 529
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ class ScannerErrorWidget extends StatelessWidget { | |
errorMessage = 'Scanning is unsupported on this device'; | ||
default: | ||
errorMessage = 'Generic Error'; | ||
break; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The linter now reports an obsolete break statement here |
||
} | ||
|
||
return ColoredBox( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
BuildContext, | ||
MobileScannerException, | ||
Widget?, | ||
); | ||
|
||
/// This widget displays a live camera preview for the barcode scanner. | ||
class MobileScanner extends StatefulWidget { | ||
/// Create a new [MobileScanner] using the provided [controller]. | ||
|
@@ -50,7 +43,7 @@ class MobileScanner extends StatefulWidget { | |
/// | ||
/// If this is null, a black [ColoredBox], | ||
/// with a centered white [Icons.error] icon is used as error widget. | ||
final MobileScannerErrorBuilder? errorBuilder; | ||
final Widget Function(BuildContext, MobileScannerException)? errorBuilder; | ||
|
||
/// The [BoxFit] for the camera preview. | ||
/// | ||
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reusing an exiting typedef from the framework here |
||
|
||
/// The scan window rectangle for the barcode scanner. | ||
/// | ||
|
@@ -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, _) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Users can create a child widget above the |
||
if (!value.isInitialized) { | ||
const Widget defaultPlaceholder = ColoredBox(color: Colors.black); | ||
|
||
return widget.placeholderBuilder?.call(context, child) ?? | ||
defaultPlaceholder; | ||
return widget.placeholderBuilder?.call(context) ?? defaultPlaceholder; | ||
} | ||
|
||
final MobileScannerException? error = value.error; | ||
|
@@ -219,8 +211,7 @@ class _MobileScannerState extends State<MobileScanner> | |
child: Center(child: Icon(Icons.error, color: Colors.white)), | ||
); | ||
|
||
return widget.errorBuilder?.call(context, error, child) ?? | ||
defaultError; | ||
return widget.errorBuilder?.call(context, error) ?? defaultError; | ||
} | ||
|
||
return LayoutBuilder( | ||
|
There was a problem hiding this comment.
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