Skip to content

Commit

Permalink
Merge pull request #1032 from penkzhou/feature/change_platform_os_detect
Browse files Browse the repository at this point in the history
feat: change platform os detect pattern
  • Loading branch information
navaronbracke authored Apr 23, 2024
2 parents 8c87026 + f61c230 commit c113dff
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 5.0.1

Improvements:
* Adjusted the platform checks to use the defaultTargetPlatform API, so that tests can use the correct platform overrides.

## 5.0.0

This major release contains all the changes from the 5.0.0 beta releases, along with the following changes:
Expand Down
4 changes: 1 addition & 3 deletions example/lib/barcode_scanner_window.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
Expand Down Expand Up @@ -204,7 +202,7 @@ class BarcodeOverlay extends CustomPainter {
final double ratioWidth;
final double ratioHeight;

if (!kIsWeb && Platform.isIOS) {
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.iOS) {
ratioWidth = barcodeSize.width / adjustedSize.destination.width;
ratioHeight = barcodeSize.height / adjustedSize.destination.height;
} else {
Expand Down
7 changes: 4 additions & 3 deletions lib/src/method_channel/mobile_scanner_method_channel.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:async';
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:mobile_scanner/src/enums/barcode_format.dart';
Expand Down Expand Up @@ -54,7 +54,7 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
final List<Map<Object?, Object?>> barcodes =
data.cast<Map<Object?, Object?>>();

if (Platform.isMacOS) {
if (defaultTargetPlatform == TargetPlatform.macOS) {
return BarcodeCapture(
raw: event,
barcodes: barcodes
Expand All @@ -70,7 +70,8 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
);
}

if (Platform.isAndroid || Platform.isIOS) {
if (defaultTargetPlatform == TargetPlatform.android ||
defaultTargetPlatform == TargetPlatform.iOS) {
final double? width = event['width'] as double?;
final double? height = event['height'] as double?;

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mobile_scanner
description: A universal barcode and QR code scanner for Flutter based on MLKit. Uses CameraX on Android, AVFoundation on iOS and Apple Vision & AVFoundation on macOS.
version: 5.0.0
version: 5.0.1
repository: https://github.com/juliansteenbakker/mobile_scanner

screenshots:
Expand Down

0 comments on commit c113dff

Please sign in to comment.