From 5314292eb168d1e01534dda55d574568c90689dc Mon Sep 17 00:00:00 2001 From: Khoren Markosyan Date: Sun, 8 Jan 2023 18:56:52 +0400 Subject: [PATCH] code refactoring --- example/lib/main.dart | 14 ++++++++------ ffigen.yaml | 11 +++++++---- lib/generated_bindings.dart | 9 ++++++++- pubspec.yaml | 15 +-------------- src/zxing | 1 + zxscanner/analysis_options.yaml | 5 +---- 6 files changed, 26 insertions(+), 29 deletions(-) create mode 160000 src/zxing diff --git a/example/lib/main.dart b/example/lib/main.dart index bbffce1..5cce3da 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -62,14 +62,16 @@ class _DemoPageState extends State { children: [ if (kIsWeb) const UnsupportedPlatformWidget() - else - if (!isCameraSupported) + else if (!isCameraSupported) const Center( - - child: Text('Camera not supported on this platform'), - ) else - if (result != null) + ) + else if (result != null) + ScanResultWidget( + result: result?.text, + onScanAgain: () => setState(() => result = null), + ) + else if (result != null) ScanResultWidget( result: result?.text, onScanAgain: () => setState(() => result = null), diff --git a/ffigen.yaml b/ffigen.yaml index 0182d0e..0bc4f4f 100644 --- a/ffigen.yaml +++ b/ffigen.yaml @@ -1,15 +1,18 @@ # Run with `flutter pub run ffigen --config ffigen.yaml`. -name: FlutterZxingBindings +name: GeneratedBindings description: | Bindings for `src/native_zxing.h`. Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. -output: 'lib/flutter_zxing_bindings_generated.dart' +output: "lib/generated_bindings.dart" headers: entry-points: - - 'src/native_zxing.h' + - "src/native_zxing.h" include-directives: - - 'src/native_zxing.h' + - "src/native_zxing.h" +functions: + exclude: + - "resultToCodeResult" preamble: | // ignore_for_file: always_specify_types // ignore_for_file: camel_case_types diff --git a/lib/generated_bindings.dart b/lib/generated_bindings.dart index 269eb8c..83abb25 100644 --- a/lib/generated_bindings.dart +++ b/lib/generated_bindings.dart @@ -1,9 +1,16 @@ +// ignore_for_file: always_specify_types +// ignore_for_file: camel_case_types +// ignore_for_file: non_constant_identifier_names + // AUTO GENERATED FILE, DO NOT EDIT. // // Generated by `package:ffigen`. import 'dart:ffi' as ffi; -/// Bindings to `native_verokit.h`. +/// Bindings for `src/native_zxing.h`. +/// +/// Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. +/// class GeneratedBindings { /// Holds the symbol lookup function. final ffi.Pointer Function(String symbolName) diff --git a/pubspec.yaml b/pubspec.yaml index 7639f97..d4366b8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -33,17 +33,4 @@ flutter: ffiPlugin: true windows: ffiPlugin: true - -ffigen: - name: GeneratedBindings - description: Bindings to `native_verokit.h`. - output: "lib/generated_bindings.dart" - headers: - entry-points: - - "ios/Classes/src/native_zxing.h" - functions: - exclude: - - 'resultToCodeResult' - - -# flutter pub publish --dry-run \ No newline at end of file +# flutter pub publish --dry-run diff --git a/src/zxing b/src/zxing new file mode 160000 index 0000000..86b253d --- /dev/null +++ b/src/zxing @@ -0,0 +1 @@ +Subproject commit 86b253d699b13b1da8fca0c5e4fbd62691582d5a diff --git a/zxscanner/analysis_options.yaml b/zxscanner/analysis_options.yaml index 5ec54e5..954356b 100644 --- a/zxscanner/analysis_options.yaml +++ b/zxscanner/analysis_options.yaml @@ -26,10 +26,7 @@ analyzer: # Turned off until null-safe rollout is complete. unnecessary_null_comparison: warning exclude: - - "bin/cache/**" - # Ignore protoc generated files - - "dev/conductor/lib/proto/*" - - "lib/generated_bindings.dart" + - "lib/generated/" linter: rules: