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

refactor: Use explicitToJson parameter for json_serializable #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions BlinkID/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
targets:
$default:
builders:
json_serializable:
options:
explicit_to_json: true
34 changes: 18 additions & 16 deletions BlinkID/lib/microblink_scanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export 'package:blinkid_flutter/overlay_settings.dart';
export 'package:blinkid_flutter/types.dart';

class MicroblinkScanner {

static const MethodChannel _channel = const MethodChannel('blinkid_scanner');

static const String METHOD_SCAN_WITH_CAMERA = 'scanWithCamera';
Expand All @@ -22,30 +21,33 @@ class MicroblinkScanner {
static const String ARG_LICENSEE = 'licensee';
static const String ARG_SHOW_LICENSE_WARNING = 'showTrialLicenseWarning';

static Future<List<RecognizerResult>> scanWithCamera(RecognizerCollection collection, OverlaySettings overlaySettings, String license) async {
var jsonResults = jsonDecode(await _channel.invokeMethod(
METHOD_SCAN_WITH_CAMERA,
{
ARG_RECOGNIZER_COLLECTION: jsonDecode(jsonEncode(collection)),
ARG_OVERLAY_SETTINGS: jsonDecode(jsonEncode(overlaySettings)),
ARG_LICENSE: {
ARG_LICENSE_KEY: license
}
})
static Future<List<RecognizerResult>> scanWithCamera(
RecognizerCollection collection,
OverlaySettings overlaySettings,
String license,
) async {
final jsonResults = jsonDecode(
await _channel.invokeMethod(
METHOD_SCAN_WITH_CAMERA,
{
ARG_RECOGNIZER_COLLECTION: collection.toJson(),
ARG_OVERLAY_SETTINGS: overlaySettings.toJson(),
ARG_LICENSE: {ARG_LICENSE_KEY: license}
},
),
);

if (jsonResults == null) return List.empty();

var results = [];
final results = [];
for (int i = 0; i < jsonResults.length; ++i) {
var map = Map<String, dynamic>.from(jsonResults[i]);
var result = collection.recognizerArray[i].createResultFromNative(map);
final map = Map<String, dynamic>.from(jsonResults[i]);
final result = collection.recognizerArray[i].createResultFromNative(map);
if (result.resultState != RecognizerResultState.empty) {
results.add(result);
}
}

return List<RecognizerResult>.from(results);
}

}
}
3 changes: 2 additions & 1 deletion BlinkID/lib/recognizer.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions BlinkID/lib/recognizers/blink_id_combined_recognizer.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions BlinkID/lib/recognizers/blink_id_recognizer.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BlinkID/lib/recognizers/document_face_recognizer.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BlinkID/lib/recognizers/mrtd_combined_recognizer.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BlinkID/lib/recognizers/mrtd_recognizer.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BlinkID/lib/recognizers/passport_recognizer.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BlinkID/lib/recognizers/usdl_combined_recognizer.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BlinkID/lib/recognizers/visa_recognizer.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.