Skip to content

Commit

Permalink
Fix platform handling
Browse files Browse the repository at this point in the history
  • Loading branch information
radvansky-tomas committed May 6, 2021
1 parent ced97d4 commit 4090237
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 32 deletions.
16 changes: 11 additions & 5 deletions .packages
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,28 @@
#
# For more info see: https://dart.dev/go/dot-packages-deprecation
#
# Generated by pub on 2021-05-06 21:26:03.012500.
ai_barcode_platform_interface:file:///Users/tomasradvansky/.pub-cache/git/ai_barcode_platform_interface-07ee004be6460e7683597f54d8503aa39735c002/lib/
ai_barcode_web:file:///Users/tomasradvansky/.pub-cache/git/ai_barcode_web-caabb80fd253d8b7c1eeb9f69f5e62ff97d5677a/lib/
# Generated by pub on 2021-05-06 23:05:06.497826.
ai_barcode_platform_interface:file:///Users/tomasradvansky/.pub-cache/git/ai_barcode_platform_interface-af3f01be9dfea47f1bec238139dd945e0b878629/lib/
ai_barcode_web:../ai_barcode_web/lib/
async:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/async-2.5.0/lib/
boolean_selector:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/boolean_selector-2.1.0/lib/
characters:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0/lib/
charcode:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/charcode-1.2.0/lib/
clock:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/clock-1.1.0/lib/
collection:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0/lib/
crypto:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/crypto-3.0.1/lib/
csslib:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/csslib-0.17.0/lib/
fake_async:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/fake_async-1.2.0/lib/
flutter:file:///Users/tomasradvansky/fvm/versions/dev/packages/flutter/lib/
flutter_test:file:///Users/tomasradvansky/fvm/versions/dev/packages/flutter_test/lib/
flutter_web_plugins:file:///Users/tomasradvansky/fvm/versions/dev/packages/flutter_web_plugins/lib/
html:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/html-0.15.0/lib/
js:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/js-0.6.3/lib/
matcher:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.10/lib/
meta:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0/lib/
path:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/path-1.8.0/lib/
qr:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/qr-1.3.0/lib/
qr_flutter:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/qr_flutter-3.2.0/lib/
qr:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/qr-2.0.0/lib/
qr_flutter:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/qr_flutter-4.0.0/lib/
sky_engine:file:///Users/tomasradvansky/fvm/versions/dev/bin/cache/pkg/sky_engine/lib/
source_span:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/source_span-1.8.1/lib/
stack_trace:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.10.0/lib/
Expand All @@ -30,5 +33,8 @@ string_scanner:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/s
term_glyph:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0/lib/
test_api:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/test_api-0.3.0/lib/
typed_data:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0/lib/
universal_html:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/universal_html-2.0.8/lib/
universal_io:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/universal_io-2.0.4/lib/
universal_platform:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/universal_platform-1.0.0-nullsafety/lib/
vector_math:file:///Users/tomasradvansky/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0/lib/
ai_barcode:lib/
35 changes: 35 additions & 0 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
PODS:
- ai_barcode (0.0.1):
- Flutter
- MTBBarcodeScanner
- Flutter (1.0.0)
- MTBBarcodeScanner (5.0.11)
- "permission_handler (5.1.0+2)":
- Flutter

DEPENDENCIES:
- ai_barcode (from `.symlinks/plugins/ai_barcode/ios`)
- Flutter (from `Flutter`)
- permission_handler (from `.symlinks/plugins/permission_handler/ios`)

SPEC REPOS:
trunk:
- MTBBarcodeScanner

EXTERNAL SOURCES:
ai_barcode:
:path: ".symlinks/plugins/ai_barcode/ios"
Flutter:
:path: Flutter
permission_handler:
:path: ".symlinks/plugins/permission_handler/ios"

SPEC CHECKSUMS:
ai_barcode: 67fb0a7b732dbb87e92b59bb90a438db9383fa2f
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0

PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c

COCOAPODS: 1.10.1
13 changes: 8 additions & 5 deletions example/lib/app_barcode_scanner_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ class _BarcodePermissionWidgetState extends State<_BarcodePermissionWidget> {
}

void _requestMobilePermission() async {
if (await Permission.camera.request().isGranted) {
setState(() {
_isGranted = true;
});
}
setState(() {
_isGranted = true;
});
// if (await Permission.camera.request().isGranted) {
// setState(() {
// _isGranted = true;
// });
// }
}

@override
Expand Down
7 changes: 7 additions & 0 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
universal_platform:
dependency: transitive
description:
name: universal_platform
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0-nullsafety"
vector_math:
dependency: transitive
description:
Expand Down
7 changes: 3 additions & 4 deletions lib/src/ai_barcode_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:ai_barcode/src/creator/ai_barcode_mobile_creator_plugin.dart';
import 'package:ai_barcode/src/scanner/ai_barcode_mobile_scanner_plugin.dart';
import 'package:ai_barcode_platform_interface/ai_barcode_platform_interface.dart';
import 'package:flutter/material.dart';
import 'package:universal_platform/universal_platform.dart';

///
/// PlatformScannerWidget
Expand Down Expand Up @@ -71,8 +72,7 @@ class _PlatformScannerWidgetState

@override
Widget build(BuildContext context) {
TargetPlatform platform = Theme.of(context).platform;
if (platform == TargetPlatform.android || platform == TargetPlatform.iOS) {
if (UniversalPlatform.isAndroid || UniversalPlatform.isIOS) {
AiBarcodeScannerPlatform.instance = AiBarcodeMobileScannerPlugin();
}
//Create
Expand Down Expand Up @@ -203,8 +203,7 @@ class _PlatformAiBarcodeCreatorState

@override
Widget build(BuildContext context) {
TargetPlatform platform = Theme.of(context).platform;
if (platform == TargetPlatform.android || platform == TargetPlatform.iOS) {
if (UniversalPlatform.isAndroid || UniversalPlatform.isIOS) {
AiBarcodeCreatorPlatform.instance = AiBarcodeMobileCreatorPlugin();
}
//create
Expand Down
6 changes: 3 additions & 3 deletions lib/src/creator/ai_barcode_mobile_creator_plugin.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:ai_barcode_platform_interface/ai_barcode_platform_interface.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:universal_platform/universal_platform.dart';

/// AiBarcodeMobileCreatorPlugin
class AiBarcodeMobileCreatorPlugin extends AiBarcodeCreatorPlatform {
Expand All @@ -11,8 +12,7 @@ class AiBarcodeMobileCreatorPlugin extends AiBarcodeCreatorPlatform {

/// Barcode widget
Widget _barcodeCreator({required BuildContext context}) {
TargetPlatform targetPlatform = Theme.of(context).platform;
if (targetPlatform == TargetPlatform.android) {
if (UniversalPlatform.isAndroid) {
return AndroidView(
viewType: AiBarcodePlatform.viewIdOfCreator,
creationParams: <String, dynamic>{
Expand All @@ -28,7 +28,7 @@ class AiBarcodeMobileCreatorPlugin extends AiBarcodeCreatorPlatform {
AiBarcodeCreatorPlatform.instance.initialValueOfCreator);
},
);
} else if (targetPlatform == TargetPlatform.iOS) {
} else if (UniversalPlatform.isIOS) {
return UiKitView(
viewType: AiBarcodePlatform.viewIdOfCreator,
creationParams: <String, dynamic>{
Expand Down
7 changes: 3 additions & 4 deletions lib/src/scanner/ai_barcode_mobile_scanner_plugin.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:ai_barcode_platform_interface/ai_barcode_platform_interface.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:universal_platform/universal_platform.dart';

///
/// AiBarcodeMobileScannerPlugin
Expand All @@ -14,9 +15,7 @@ class AiBarcodeMobileScannerPlugin extends AiBarcodeScannerPlatform {
///
/// Support android and ios platform barcode reader
Widget _cameraView(BuildContext context) {
TargetPlatform targetPlatform = Theme.of(context).platform;

if (targetPlatform == TargetPlatform.android) {
if (UniversalPlatform.isAndroid) {
return AndroidView(
viewType: AiBarcodePlatform.viewIdOfScanner,
onPlatformViewCreated: (int id) {
Expand All @@ -25,7 +24,7 @@ class AiBarcodeMobileScannerPlugin extends AiBarcodeScannerPlatform {
creationParams: <String, dynamic>{},
creationParamsCodec: StandardMessageCodec(),
);
} else if (targetPlatform == TargetPlatform.iOS) {
} else if (UniversalPlatform.isIOS) {
return UiKitView(
viewType: AiBarcodePlatform.viewIdOfScanner,
onPlatformViewCreated: (int id) {
Expand Down
58 changes: 49 additions & 9 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ packages:
description:
path: "."
ref: HEAD
resolved-ref: "07ee004be6460e7683597f54d8503aa39735c002"
resolved-ref: af3f01be9dfea47f1bec238139dd945e0b878629
url: "https://github.com/radvansky-tomas/ai_barcode_platform_interface.git"
source: git
version: "3.0.0"
ai_barcode_web:
dependency: "direct main"
description:
path: "."
ref: HEAD
resolved-ref: caabb80fd253d8b7c1eeb9f69f5e62ff97d5677a
url: "https://github.com/radvansky-tomas/ai_barcode_web.git"
source: git
path: "../ai_barcode_web"
relative: true
source: path
version: "3.0.0"
async:
dependency: transitive
Expand Down Expand Up @@ -61,6 +59,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
csslib:
dependency: transitive
description:
name: csslib
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.0"
fake_async:
dependency: transitive
description:
Expand All @@ -83,6 +95,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
html:
dependency: transitive
description:
name: html
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.0"
js:
dependency: transitive
description:
Expand All @@ -98,7 +117,7 @@ packages:
source: hosted
version: "0.12.10"
meta:
dependency: "direct main"
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
Expand All @@ -117,14 +136,14 @@ packages:
name: qr
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "2.0.0"
qr_flutter:
dependency: transitive
description:
name: qr_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.0"
version: "4.0.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -179,6 +198,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
universal_html:
dependency: transitive
description:
name: universal_html
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
universal_io:
dependency: transitive
description:
name: universal_io
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
universal_platform:
dependency: "direct main"
description:
name: universal_platform
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0-nullsafety"
vector_math:
dependency: transitive
description:
Expand Down
7 changes: 5 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@ environment:
dependencies:
flutter:
sdk: flutter
meta: ^1.1.7
universal_platform: 1.0.0-nullsafety
ai_barcode_platform_interface:
git:
url: https://github.com/radvansky-tomas/ai_barcode_platform_interface.git
ai_barcode_web:
git:
url: https://github.com/radvansky-tomas/ai_barcode_web.git

dependency_overrides:
ai_barcode_web:
path: ../ai_barcode_web

dev_dependencies:
flutter_test:
sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
`

# The following section is specific to Flutter.
flutter:
# This section identifies this Flutter project as a plugin project.
Expand Down

0 comments on commit 4090237

Please sign in to comment.