toMap method
Implementation
@override
Map<String, dynamic> toMap() {
var json = <String, dynamic>{
'View': buildBarcodeCountView(
style: _style.toString(),
shouldShowUserGuidanceView: shouldShowUserGuidanceView,
shouldShowListButton: shouldShowListButton,
shouldShowExitButton: shouldShowExitButton,
shouldShowShutterButton: shouldShowShutterButton,
shouldShowHints: shouldShowHints,
shouldShowClearHighlightsButton: shouldShowClearHighlightsButton,
shouldShowSingleScanButton: shouldShowSingleScanButton,
shouldShowFloatingShutterButton: shouldShowFloatingShutterButton,
shouldShowToolbar: shouldShowToolbar,
shouldShowStatusIconsOnScan: shouldShowStatusIconsOnScan,
shouldDisableModeOnExitButtonTapped: shouldDisableModeOnExitButtonTapped,
shouldShowScanAreaGuides: shouldShowScanAreaGuides,
toolbarSettings: _toolbarSettings?.toMap(),
shouldShowListProgressBar: shouldShowListProgressBar,
shouldShowTorchControl: shouldShowTorchControl,
torchControlPosition: torchControlPosition.toString(),
tapToUncountEnabled: tapToUncountEnabled,
textForTapToUncountHint: textForTapToUncountHint,
shouldShowStatusModeButton: shouldShowStatusModeButton,
hasStatusProvider: _statusProvider != null,
hasListener: _barcodeCountViewListener != null,
hasUiListener: _barcodeCountViewUiListener != null,
viewId: _viewId,
),
'BarcodeCount': _barcodeCount.toMap(),
};
// The `json['View'][...] = x` writes below stay OUTSIDE the builder on purpose,
// and the golden key-set test uses `containsAll` rather than `equals` for the
// same reason. Every key here IS a buildBarcodeCountView parameter, so the
// obvious cleanup is to pass `differs-from-default ? value : null` inline and
// let the omit-when-null rule reproduce the key set. That is safe for the ~30
// accessibility/hint strings, which are non-nullable `String` (see the
// declarations above: `set listButtonAccessibilityHint(String newValue)`), so
// "differs from default" can never mean "is null".
//
// It is NOT safe for the nullable members of the same block --
// `Brush? _recognizedBrush`, `BarcodeCountMappingFlowSettings?
// _mappingFlowSettings`, `BarcodeFilterHighlightSettings? _filterSettings`.
// For those, a value that differs from its default MAY be null, and the
// conditional writes it as PRESENT-null today. Routing them through an
// optional non-nullable builder parameter would omit the key instead --
// precisely the present-null -> absent shift that produced the two regressions
// earlier on this branch (`focusGesture: null` disabling the gesture, and the
// iOS toolbar accessibility throw documented in the barcode-count drift suite).
//
// Splitting the block per-key by nullability is real work with a real
// regression surface, so it is deliberately not bundled into this migration.
// Do not "simplify" this wholesale without checking each key's nullability and
// its native reader first.
if (listButtonAccessibilityHint != BarcodeCountDefaults.viewDefaults.listButtonAccessibilityHint) {
json['View']['listButtonAccessibilityHint'] = listButtonAccessibilityHint; // iOS Only
}
if (listButtonAccessibilityLabel != BarcodeCountDefaults.viewDefaults.listButtonAccessibilityLabel) {
json['View']['listButtonAccessibilityLabel'] = listButtonAccessibilityLabel; // iOS Only
}
if (listButtonContentDescription != BarcodeCountDefaults.viewDefaults.listButtonContentDescription) {
json['View']['listButtonContentDescription'] = listButtonContentDescription; // Android only
}
if (exitButtonAccessibilityHint != BarcodeCountDefaults.viewDefaults.exitButtonAccessibilityHint) {
json['View']['exitButtonAccessibilityHint'] = exitButtonAccessibilityHint; // iOS Only
}
if (exitButtonAccessibilityLabel != BarcodeCountDefaults.viewDefaults.exitButtonAccessibilityLabel) {
json['View']['exitButtonAccessibilityLabel'] = exitButtonAccessibilityLabel; // iOS Only
}
if (exitButtonContentDescription != BarcodeCountDefaults.viewDefaults.exitButtonContentDescription) {
json['View']['exitButtonContentDescription'] = exitButtonContentDescription; // Android only
}
if (shutterButtonAccessibilityHint != BarcodeCountDefaults.viewDefaults.shutterButtonAccessibilityHint) {
json['View']['shutterButtonAccessibilityHint'] = shutterButtonAccessibilityHint; // iOS Only
}
if (shutterButtonAccessibilityLabel != BarcodeCountDefaults.viewDefaults.shutterButtonAccessibilityLabel) {
json['View']['shutterButtonAccessibilityLabel'] = shutterButtonAccessibilityLabel; // iOS Only
}
if (shutterButtonContentDescription != BarcodeCountDefaults.viewDefaults.shutterButtonContentDescription) {
json['View']['shutterButtonContentDescription'] = shutterButtonContentDescription; // Android Only
}
if (floatingShutterButtonAccessibilityHint !=
BarcodeCountDefaults.viewDefaults.floatingShutterButtonAccessibilityHint) {
json['View']['floatingShutterButtonAccessibilityHint'] = floatingShutterButtonAccessibilityHint; // iOS Only
}
if (floatingShutterButtonAccessibilityLabel !=
BarcodeCountDefaults.viewDefaults.floatingShutterButtonAccessibilityLabel) {
json['View']['floatingShutterButtonAccessibilityLabel'] = floatingShutterButtonAccessibilityLabel; // iOS Only
}
if (floatingShutterButtonContentDescription !=
BarcodeCountDefaults.viewDefaults.floatingShutterButtonContentDescription) {
json['View']['floatingShutterButtonContentDescription'] = floatingShutterButtonContentDescription; // Android only
}
if (clearHighlightsButtonAccessibilityHint !=
BarcodeCountDefaults.viewDefaults.clearHighlightsButtonAccessibilityHint) {
json['View']['clearHighlightsButtonAccessibilityHint'] = clearHighlightsButtonAccessibilityHint; // iOS only
}
if (clearHighlightsButtonAccessibilityLabel !=
BarcodeCountDefaults.viewDefaults.clearHighlightsButtonAccessibilityLabel) {
json['View']['clearHighlightsButtonAccessibilityLabel'] = clearHighlightsButtonAccessibilityLabel; // iOS only
}
if (clearHighlightsButtonContentDescription !=
BarcodeCountDefaults.viewDefaults.clearHighlightsButtonContentDescription) {
json['View']['clearHighlightsButtonContentDescription'] = clearHighlightsButtonContentDescription; // Android Only
}
if (singleScanButtonAccessibilityHint != BarcodeCountDefaults.viewDefaults.singleScanButtonAccessibilityHint) {
json['View']['singleScanButtonAccessibilityHint'] = singleScanButtonAccessibilityHint; // iOS Only
}
if (singleScanButtonAccessibilityLabel != BarcodeCountDefaults.viewDefaults.singleScanButtonAccessibilityLabel) {
json['View']['singleScanButtonAccessibilityLabel'] = singleScanButtonAccessibilityLabel; // iOS Only
}
if (singleScanButtonContentDescription != BarcodeCountDefaults.viewDefaults.singleScanButtonContentDescription) {
json['View']['singleScanButtonContentDescription'] = singleScanButtonContentDescription; // Android Only
}
if (statusModeButtonAccessibilityHint != BarcodeCountDefaults.viewDefaults.statusModeButtonAccessibilityHint) {
json['View']['statusModeButtonAccessibilityHint'] = statusModeButtonAccessibilityHint; // iOS Only
}
if (statusModeButtonAccessibilityLabel != BarcodeCountDefaults.viewDefaults.statusModeButtonAccessibilityLabel) {
json['View']['statusModeButtonAccessibilityLabel'] = statusModeButtonAccessibilityLabel; // iOS Only
}
if (statusModeButtonContentDescription != BarcodeCountDefaults.viewDefaults.statusModeButtonContentDescription) {
json['View']['statusModeButtonContentDescription'] = statusModeButtonContentDescription; // Android Only
}
if (clearHighlightsButtonText != BarcodeCountDefaults.viewDefaults.clearHighlightsButtonText) {
json['View']['clearHighlightsButtonText'] = clearHighlightsButtonText;
}
if (exitButtonText != BarcodeCountDefaults.viewDefaults.exitButtonText) {
json['View']['exitButtonText'] = exitButtonText;
}
if (textForTapShutterToScanHint != BarcodeCountDefaults.viewDefaults.textForTapShutterToScanHint) {
json['View']['textForTapShutterToScanHint'] = textForTapShutterToScanHint;
}
if (textForScanningHint != BarcodeCountDefaults.viewDefaults.textForScanningHint) {
json['View']['textForScanningHint'] = textForScanningHint;
}
if (textForMoveCloserAndRescanHint != BarcodeCountDefaults.viewDefaults.textForMoveCloserAndRescanHint) {
json['View']['textForMoveCloserAndRescanHint'] = textForMoveCloserAndRescanHint;
}
if (textForMoveFurtherAndRescanHint != BarcodeCountDefaults.viewDefaults.textForMoveFurtherAndRescanHint) {
json['View']['textForMoveFurtherAndRescanHint'] = textForMoveFurtherAndRescanHint;
}
if (textForBarcodesNotInListDetectedHint !=
BarcodeCountDefaults.viewDefaults.textForBarcodesNotInListDetectedHint) {
json['View']['textForBarcodesNotInListDetectedHint'] = textForBarcodesNotInListDetectedHint;
}
if (textForScreenCleanedUpHint != BarcodeCountDefaults.viewDefaults.textForScreenCleanedUpHint) {
json['View']['textForScreenCleanedUpHint'] = textForScreenCleanedUpHint;
}
if (textForClusteringGestureHint != BarcodeCountDefaults.viewDefaults.textForClusteringGestureHint) {
json['View']['textForClusteringGestureHint'] = textForClusteringGestureHint;
}
if (recognizedBrush != null) {
json['View']['recognizedBrush'] = recognizedBrush?.toMap();
}
if (notInListBrush != null) {
json['View']['notInListBrush'] = notInListBrush?.toMap();
}
if (acceptedBrush != null) {
json['View']['acceptedBrush'] = acceptedBrush?.toMap();
}
if (rejectedBrush != null) {
json['View']['rejectedBrush'] = rejectedBrush?.toMap();
}
if (filterSettings != null) {
json['View']['filterSettings'] = filterSettings?.toMap();
}
if (hardwareTriggerSupported != BarcodeCountDefaults.viewDefaults.hardwareTriggerSupported) {
json['View']['hardwareTriggerSupported'] = hardwareTriggerSupported;
}
if (_mappingFlowSettings != null) {
json['View']['mappingFlowSettings'] = _mappingFlowSettings?.toMap();
}
json['View']['barcodeNotInListActionSettings'] = _barcodeNotInListActionSettings.toMap();
json['View']['hardwareTriggerEnabled'] = _hardwareTriggerEnabled;
json['View']['logoStyle'] = _logoStyle.toString();
json['View']['logoAnchor'] = _logoAnchor.toString();
return json;
}