Navaron Bracke
Committed by GitHub

Merge pull request #1032 from penkzhou/feature/change_platform_os_detect

feat: change platform os detect pattern
  1 +## 5.0.1
  2 +
  3 +Improvements:
  4 +* Adjusted the platform checks to use the defaultTargetPlatform API, so that tests can use the correct platform overrides.
  5 +
1 ## 5.0.0 6 ## 5.0.0
2 7
3 This major release contains all the changes from the 5.0.0 beta releases, along with the following changes: 8 This major release contains all the changes from the 5.0.0 beta releases, along with the following changes:
1 -import 'dart:io';  
2 -  
3 import 'package:flutter/foundation.dart'; 1 import 'package:flutter/foundation.dart';
4 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
5 import 'package:mobile_scanner/mobile_scanner.dart'; 3 import 'package:mobile_scanner/mobile_scanner.dart';
@@ -204,7 +202,7 @@ class BarcodeOverlay extends CustomPainter { @@ -204,7 +202,7 @@ class BarcodeOverlay extends CustomPainter {
204 final double ratioWidth; 202 final double ratioWidth;
205 final double ratioHeight; 203 final double ratioHeight;
206 204
207 - if (!kIsWeb && Platform.isIOS) { 205 + if (!kIsWeb && defaultTargetPlatform == TargetPlatform.iOS) {
208 ratioWidth = barcodeSize.width / adjustedSize.destination.width; 206 ratioWidth = barcodeSize.width / adjustedSize.destination.width;
209 ratioHeight = barcodeSize.height / adjustedSize.destination.height; 207 ratioHeight = barcodeSize.height / adjustedSize.destination.height;
210 } else { 208 } else {
1 import 'dart:async'; 1 import 'dart:async';
2 -import 'dart:io';  
3 2
  3 +import 'package:flutter/foundation.dart';
4 import 'package:flutter/services.dart'; 4 import 'package:flutter/services.dart';
5 import 'package:flutter/widgets.dart'; 5 import 'package:flutter/widgets.dart';
6 import 'package:mobile_scanner/src/enums/barcode_format.dart'; 6 import 'package:mobile_scanner/src/enums/barcode_format.dart';
@@ -54,7 +54,7 @@ class MethodChannelMobileScanner extends MobileScannerPlatform { @@ -54,7 +54,7 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
54 final List<Map<Object?, Object?>> barcodes = 54 final List<Map<Object?, Object?>> barcodes =
55 data.cast<Map<Object?, Object?>>(); 55 data.cast<Map<Object?, Object?>>();
56 56
57 - if (Platform.isMacOS) { 57 + if (defaultTargetPlatform == TargetPlatform.macOS) {
58 return BarcodeCapture( 58 return BarcodeCapture(
59 raw: event, 59 raw: event,
60 barcodes: barcodes 60 barcodes: barcodes
@@ -70,7 +70,8 @@ class MethodChannelMobileScanner extends MobileScannerPlatform { @@ -70,7 +70,8 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
70 ); 70 );
71 } 71 }
72 72
73 - if (Platform.isAndroid || Platform.isIOS) { 73 + if (defaultTargetPlatform == TargetPlatform.android ||
  74 + defaultTargetPlatform == TargetPlatform.iOS) {
74 final double? width = event['width'] as double?; 75 final double? width = event['width'] as double?;
75 final double? height = event['height'] as double?; 76 final double? height = event['height'] as double?;
76 77
1 name: mobile_scanner 1 name: mobile_scanner
2 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. 2 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.
3 -version: 5.0.0 3 +version: 5.0.1
4 repository: https://github.com/juliansteenbakker/mobile_scanner 4 repository: https://github.com/juliansteenbakker/mobile_scanner
5 5
6 screenshots: 6 screenshots: