Julian Steenbakker

imp: apply lint

include: package:flutter_lints/flutter.yaml
linter:
rules:
unawaited_futures: true
\ No newline at end of file
include: package:lint/analysis_options_package.yaml
\ No newline at end of file
... ...
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
include: package:lint/analysis_options.yaml
\ No newline at end of file
... ...
... ... @@ -42,7 +42,7 @@ class _BarcodeScannerWithControllerState
setState(() {
this.barcode = barcode.rawValue;
});
}),
},),
Align(
alignment: Alignment.bottomCenter,
child: Container(
... ... @@ -50,7 +50,6 @@ class _BarcodeScannerWithControllerState
height: 100,
color: Colors.black.withOpacity(0.4),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
... ... @@ -58,13 +57,17 @@ class _BarcodeScannerWithControllerState
icon: ValueListenableBuilder(
valueListenable: controller.torchState,
builder: (context, state, child) {
if (state == null) {
return const Icon(Icons.flash_off,
color: Colors.grey,);
}
switch (state as TorchState) {
case TorchState.off:
return const Icon(Icons.flash_off,
color: Colors.grey);
color: Colors.grey,);
case TorchState.on:
return const Icon(Icons.flash_on,
color: Colors.yellow);
color: Colors.yellow,);
}
},
),
... ... @@ -82,7 +85,7 @@ class _BarcodeScannerWithControllerState
? controller.stop()
: controller.start();
isStarted = !isStarted;
})),
}),),
Center(
child: SizedBox(
width: MediaQuery.of(context).size.width - 200,
... ... @@ -104,6 +107,9 @@ class _BarcodeScannerWithControllerState
icon: ValueListenableBuilder(
valueListenable: controller.cameraFacingState,
builder: (context, state, child) {
if (state == null) {
return const Icon(Icons.camera_front);
}
switch (state as CameraFacing) {
case CameraFacing.front:
return const Icon(Icons.camera_front);
... ... @@ -123,20 +129,22 @@ class _BarcodeScannerWithControllerState
final ImagePicker _picker = ImagePicker();
// Pick an image
final XFile? image = await _picker.pickImage(
source: ImageSource.gallery);
source: ImageSource.gallery,);
if (image != null) {
if (await controller.analyzeImage(image.path)) {
if (!mounted) return;
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(
content: Text('Barcode found!'),
backgroundColor: Colors.green,
));
),);
} else {
if (!mounted) return;
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(
content: Text('No barcode found!'),
backgroundColor: Colors.red,
));
),);
}
}
},
... ... @@ -147,7 +155,7 @@ class _BarcodeScannerWithControllerState
),
],
);
}),
},),
);
}
}
... ...
... ... @@ -28,7 +28,7 @@ class _BarcodeScannerWithoutControllerState
setState(() {
this.barcode = barcode.rawValue;
});
}),
},),
Align(
alignment: Alignment.bottomCenter,
child: Container(
... ... @@ -36,7 +36,6 @@ class _BarcodeScannerWithoutControllerState
height: 100,
color: Colors.black.withOpacity(0.4),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Center(
... ... @@ -61,7 +60,7 @@ class _BarcodeScannerWithoutControllerState
),
],
);
}),
},),
);
}
}
... ...
... ... @@ -16,13 +16,12 @@ class MyHome extends StatelessWidget {
height: MediaQuery.of(context).size.height,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const BarcodeScannerWithController(),
));
),);
},
child: const Text('MobileScanner with Controller'),
),
... ... @@ -30,7 +29,7 @@ class MyHome extends StatelessWidget {
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const BarcodeScannerWithoutController(),
));
),);
},
child: const Text('MobileScanner without Controller'),
),
... ...
... ... @@ -6,9 +6,9 @@ environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
image_picker: ^0.8.4+9
flutter:
sdk: flutter
image_picker: ^0.8.4+9
mobile_scanner:
path: ../
... ... @@ -16,7 +16,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.4
lint: ^1.8.2
flutter:
uses-material-design: true
... ...
library mobile_scanner;
export 'src/mobile_scanner.dart';
export 'src/mobile_scanner_controller.dart';
export 'src/mobile_scanner_arguments.dart';
export 'src/mobile_scanner_controller.dart';
export 'src/objects/barcode.dart';
... ...
import 'dart:async';
import 'dart:html' as html;
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:mobile_scanner/src/web/jsqr.dart';
import 'dart:html' as html;
import 'dart:ui' as ui;
import 'package:mobile_scanner/src/web/media.dart';
/// This plugin is the web implementation of mobile_scanner.
/// It only supports QR codes.
class MobileScannerWebPlugin {
static void registerWith(Registrar registrar) {
PluginEventChannel event = PluginEventChannel(
final PluginEventChannel event = PluginEventChannel(
'dev.steenbakker.mobile_scanner/scanner/event',
const StandardMethodCodec(),
registrar);
MethodChannel channel = MethodChannel(
registrar,);
final MethodChannel channel = MethodChannel(
'dev.steenbakker.mobile_scanner/scanner/method',
const StandardMethodCodec(),
registrar);
registrar,);
final MobileScannerWebPlugin instance = MobileScannerWebPlugin();
WidgetsFlutterBinding.ensureInitialized();
... ... @@ -51,16 +50,16 @@ class MobileScannerWebPlugin {
Future<dynamic> handleMethodCall(MethodCall call) async {
switch (call.method) {
case 'start':
return await _start(call.arguments);
return _start(call.arguments as Map<String, dynamic>);
case 'torch':
return await _torch(call.arguments);
return _torch(call.arguments);
case 'stop':
return await cancel();
return cancel();
default:
throw PlatformException(
code: 'Unimplemented',
details: "The mobile_scanner plugin for web doesn't implement "
"the method '${call.method}'");
"the method '${call.method}'",);
}
}
... ... @@ -77,21 +76,21 @@ class MobileScannerWebPlugin {
}
/// Starts the video stream and the scanner
Future<Map> _start(arguments) async {
Future<Map> _start(Map<String, dynamic> arguments) async {
vidDiv.children = [video];
var cameraFacing = CameraFacing.front;
if (arguments.containsKey('facing')) {
cameraFacing = CameraFacing.values[arguments['facing']];
cameraFacing = CameraFacing.values[arguments['facing'] as int];
}
// See https://github.com/flutter/flutter/issues/41563
// ignore: UNDEFINED_PREFIXED_NAME
// ignore: UNDEFINED_PREFIXED_NAME, avoid_dynamic_calls
ui.platformViewRegistry.registerViewFactory(
viewID,
(int id) => vidDiv
..style.width = '100%'
..style.height = '100%');
..style.height = '100%',);
// Check if stream is running
if (_localStream != null) {
... ... @@ -104,13 +103,13 @@ class MobileScannerWebPlugin {
try {
// Check if browser supports multiple camera's and set if supported
Map? capabilities =
final Map? capabilities =
html.window.navigator.mediaDevices?.getSupportedConstraints();
if (capabilities != null && capabilities['facingMode']) {
var constraints = {
if (capabilities != null && capabilities['facingMode'] as bool) {
final constraints = {
'video': VideoOptions(
facingMode:
(cameraFacing == CameraFacing.front ? 'user' : 'environment'))
cameraFacing == CameraFacing.front ? 'user' : 'environment',)
};
_localStream =
... ... @@ -156,6 +155,8 @@ class MobileScannerWebPlugin {
final sources =
await html.window.navigator.mediaDevices!.enumerateDevices();
for (final e in sources) {
// TODO:
// ignore: avoid_dynamic_calls
if (e.kind == 'videoinput') {
return true;
}
... ...
... ... @@ -33,7 +33,7 @@ class MobileScanner extends StatefulWidget {
this.onDetect,
this.controller,
this.fit = BoxFit.cover,
this.allowDuplicates = false})
this.allowDuplicates = false, })
: super(key: key);
@override
... ... @@ -81,10 +81,10 @@ class _MobileScannerState extends State<MobileScanner>
if (!widget.allowDuplicates) {
if (lastScanned != barcode.rawValue) {
lastScanned = barcode.rawValue;
widget.onDetect!(barcode, value as MobileScannerArguments);
widget.onDetect!(barcode, value! as MobileScannerArguments);
}
} else {
widget.onDetect!(barcode, value as MobileScannerArguments);
widget.onDetect!(barcode, value! as MobileScannerArguments);
}
});
return ClipRect(
... ... @@ -104,8 +104,8 @@ class _MobileScannerState extends State<MobileScanner>
),
);
}
});
});
},);
},);
}
@override
... ...
... ... @@ -14,5 +14,5 @@ class MobileScannerArguments {
/// Create a [MobileScannerArguments].
MobileScannerArguments(
{this.textureId, required this.size, required this.hasTorch, this.webId});
{this.textureId, required this.size, required this.hasTorch, this.webId, });
}
... ...
... ... @@ -5,8 +5,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'objects/barcode_utility.dart';
import 'package:mobile_scanner/src/objects/barcode_utility.dart';
/// The facing of a camera.
enum CameraFacing {
... ... @@ -60,7 +59,7 @@ class MobileScannerController {
{this.facing = CameraFacing.back,
this.ratio,
this.torchEnabled,
this.formats}) {
this.formats, }) {
// In case a new instance is created before calling dispose()
if (_controllerHashcode != null) {
stop();
... ... @@ -80,26 +79,26 @@ class MobileScannerController {
// Listen to events from the platform specific code
events = eventChannel
.receiveBroadcastStream()
.listen((data) => handleEvent(data));
.listen((data) => handleEvent(data as Map));
}
void handleEvent(Map<dynamic, dynamic> event) {
void handleEvent(Map event) {
final name = event['name'];
final data = event['data'];
switch (name) {
case 'torchState':
final state = TorchState.values[data];
final state = TorchState.values[data as int];
torchState.value = state;
break;
case 'barcode':
final barcode = Barcode.fromNative(data);
final barcode = Barcode.fromNative(data as Map<String, dynamic>);
barcodesController.add(barcode);
break;
case 'barcodeMac':
barcodesController.add(Barcode(rawValue: data['payload']));
barcodesController.add(Barcode(rawValue: (data as Map<String, dynamic>)['payload'] as String));
break;
case 'barcodeWeb':
barcodesController.add(Barcode(rawValue: data));
barcodesController.add(Barcode(rawValue: data as String));
break;
default:
throw UnimplementedError();
... ... @@ -130,10 +129,10 @@ class MobileScannerController {
// Check authorization status
if (!kIsWeb) {
MobileScannerState state =
MobileScannerState.values[await methodChannel.invokeMethod('state')];
MobileScannerState.values[await methodChannel.invokeMethod('state') as int];
switch (state) {
case MobileScannerState.undetermined:
final bool result = await methodChannel.invokeMethod('request');
final bool result = await methodChannel.invokeMethod('request') as bool;
state = result
? MobileScannerState.authorized
: MobileScannerState.denied;
... ... @@ -149,7 +148,7 @@ class MobileScannerController {
cameraFacingState.value = facing;
// Set the starting arguments for the camera
Map arguments = {};
final Map arguments = {};
arguments['facing'] = facing.index;
if (ratio != null) arguments['ratio'] = ratio;
if (torchEnabled != null) arguments['torch'] = torchEnabled;
... ... @@ -166,7 +165,7 @@ class MobileScannerController {
Map<String, dynamic>? startResult = {};
try {
startResult = await methodChannel.invokeMapMethod<String, dynamic>(
'start', arguments);
'start', arguments,);
} on PlatformException catch (error) {
debugPrint('${error.code}: ${error.message}');
isStarting = false;
... ... @@ -179,18 +178,18 @@ class MobileScannerController {
throw PlatformException(code: 'INITIALIZATION ERROR');
}
hasTorch = startResult['torchable'];
hasTorch = startResult['torchable'] as bool;
if (kIsWeb) {
args.value = MobileScannerArguments(
webId: startResult['ViewID'],
size: Size(startResult['videoWidth'], startResult['videoHeight']),
hasTorch: hasTorch);
webId: startResult['ViewID'] as String?,
size: Size(startResult['videoWidth'] as double, startResult['videoHeight'] as double),
hasTorch: hasTorch,);
} else {
args.value = MobileScannerArguments(
textureId: startResult['textureId'],
size: toSize(startResult['size']),
hasTorch: hasTorch);
textureId: startResult['textureId'] as int,
size: toSize(startResult['size'] as Map<String, double>),
hasTorch: hasTorch,);
}
isStarting = false;
... ... @@ -214,7 +213,7 @@ class MobileScannerController {
return;
}
TorchState state =
final TorchState state =
torchState.value == TorchState.off ? TorchState.on : TorchState.off;
try {
... ... @@ -233,7 +232,7 @@ class MobileScannerController {
await methodChannel.invokeMethod('stop');
} on PlatformException catch (error) {
debugPrint(
'${error.code}: camera is stopped! Please start before switching camera.');
'${error.code}: camera is stopped! Please start before switching camera.',);
return;
}
facing =
... ... @@ -247,7 +246,7 @@ class MobileScannerController {
///
/// [path] The path of the image on the devices
Future<bool> analyzeImage(String path) async {
return await methodChannel.invokeMethod('analyzeImage', path);
return methodChannel.invokeMethod('analyzeImage', path) as bool;
}
/// Disposes the MobileScannerController and closes all listeners.
... ...
import 'dart:typed_data';
import 'dart:ui';
import 'barcode_utility.dart';
import 'package:mobile_scanner/src/objects/barcode_utility.dart';
/// Represents a single recognized barcode and its value.
class Barcode {
... ... @@ -77,24 +77,24 @@ class Barcode {
this.sms,
this.url,
this.wifi,
required this.rawValue});
required this.rawValue, });
/// Create a [Barcode] from native data.
Barcode.fromNative(Map<dynamic, dynamic> data)
: corners = toCorners(data['corners']),
format = toFormat(data['format']),
rawBytes = data['rawBytes'],
rawValue = data['rawValue'],
type = BarcodeType.values[data['type']],
calendarEvent = toCalendarEvent(data['calendarEvent']),
contactInfo = toContactInfo(data['contactInfo']),
driverLicense = toDriverLicense(data['driverLicense']),
email = toEmail(data['email']),
geoPoint = toGeoPoint(data['geoPoint']),
phone = toPhone(data['phone']),
sms = toSMS(data['sms']),
url = toUrl(data['url']),
wifi = toWiFi(data['wifi']);
Barcode.fromNative(Map<String, dynamic> data)
: corners = toCorners(data['corners'] as List<Map>?),
format = toFormat(data['format'] as int),
rawBytes = data['rawBytes'] as Uint8List?,
rawValue = data['rawValue'] as String?,
type = BarcodeType.values[data['type'] as int],
calendarEvent = toCalendarEvent(data['calendarEvent'] as Map<String, String?>?),
contactInfo = toContactInfo(data['contactInfo'] as Map?),
driverLicense = toDriverLicense(data['driverLicense'] as Map?),
email = toEmail(data['email'] as Map?),
geoPoint = toGeoPoint(data['geoPoint'] as Map?),
phone = toPhone(data['phone'] as Map?),
sms = toSMS(data['sms'] as Map?),
url = toUrl(data['url'] as Map?),
wifi = toWiFi(data['wifi'] as Map?);
}
/// A calendar event extracted from QRCode.
... ... @@ -135,10 +135,10 @@ class CalendarEvent {
final String? summary;
/// Create a [CalendarEvent] from native data.
CalendarEvent.fromNative(Map<dynamic, dynamic> data)
CalendarEvent.fromNative(Map<dynamic, String?> data)
: description = data['description'],
start = DateTime.tryParse(data['start']),
end = DateTime.tryParse(data['end']),
start = DateTime.tryParse(data['start']!),
end = DateTime.tryParse(data['end']!),
location = data['location'],
organizer = data['organizer'],
status = data['status'],
... ... @@ -185,15 +185,15 @@ class ContactInfo {
/// Create a [ContactInfo] from native data.
ContactInfo.fromNative(Map<dynamic, dynamic> data)
: addresses = List.unmodifiable(
data['addresses'].map((e) => Address.fromNative(e))),
(data['addresses'] as List<Map>).map((e) => Address.fromNative(e)),),
emails =
List.unmodifiable(data['emails'].map((e) => Email.fromNative(e))),
name = toName(data['name']),
organization = data['organization'],
List.unmodifiable((data['emails'] as List<Map>).map((e) => Email.fromNative(e))),
name = toName(data['name'] as Map?),
organization = data['organization'] as String?,
phones =
List.unmodifiable(data['phones'].map((e) => Phone.fromNative(e))),
title = data['title'],
urls = List.unmodifiable(data['urls']);
List.unmodifiable((data['phones'] as List<Map>).map((e) => Phone.fromNative(e))),
title = data['title'] as String?,
urls = List.unmodifiable(data['urls'] as List);
}
/// An address.
... ... @@ -208,8 +208,8 @@ class Address {
/// Create a [Address] from native data.
Address.fromNative(Map<dynamic, dynamic> data)
: addressLines = List.unmodifiable(data['addressLines']),
type = AddressType.values[data['type']];
: addressLines = List.unmodifiable(data['addressLines'] as List),
type = AddressType.values[data['type'] as int];
}
/// A person's name, both formatted version and individual name components.
... ... @@ -251,13 +251,13 @@ class PersonName {
/// Create a [PersonName] from native data.
PersonName.fromNative(Map<dynamic, dynamic> data)
: first = data['first'],
middle = data['middle'],
last = data['last'],
prefix = data['prefix'],
suffix = data['suffix'],
formattedName = data['formattedName'],
pronunciation = data['pronunciation'];
: first = data['first'] as String?,
middle = data['middle'] as String?,
last = data['last'] as String?,
prefix = data['prefix'] as String?,
suffix = data['suffix'] as String?,
formattedName = data['formattedName'] as String?,
pronunciation = data['pronunciation'] as String?;
}
/// A driver license or ID card.
... ... @@ -336,20 +336,20 @@ class DriverLicense {
/// Create a [DriverLicense] from native data.
DriverLicense.fromNative(Map<dynamic, dynamic> data)
: addressCity = data['addressCity'],
addressState = data['addressState'],
addressStreet = data['addressStreet'],
addressZip = data['addressZip'],
birthDate = data['birthDate'],
documentType = data['documentType'],
expiryDate = data['expiryDate'],
firstName = data['firstName'],
gender = data['gender'],
issueDate = data['issueDate'],
issuingCountry = data['issuingCountry'],
lastName = data['lastName'],
licenseNumber = data['licenseNumber'],
middleName = data['middleName'];
: addressCity = data['addressCity'] as String?,
addressState = data['addressState'] as String?,
addressStreet = data['addressStreet'] as String?,
addressZip = data['addressZip'] as String?,
birthDate = data['birthDate'] as String?,
documentType = data['documentType'] as String?,
expiryDate = data['expiryDate'] as String?,
firstName = data['firstName'] as String?,
gender = data['gender'] as String?,
issueDate = data['issueDate'] as String?,
issuingCountry = data['issuingCountry'] as String?,
lastName = data['lastName'] as String?,
licenseNumber = data['licenseNumber'] as String?,
middleName = data['middleName'] as String?;
}
/// An email message from a 'MAILTO:' or similar QRCode type.
... ... @@ -377,10 +377,10 @@ class Email {
/// Create a [Email] from native data.
Email.fromNative(Map<dynamic, dynamic> data)
: address = data['address'],
body = data['body'],
subject = data['subject'],
type = EmailType.values[data['type']];
: address = data['address'] as String?,
body = data['body'] as String?,
subject = data['subject'] as String?,
type = EmailType.values[data['type'] as int];
}
/// GPS coordinates from a 'GEO:' or similar QRCode type.
... ... @@ -393,8 +393,8 @@ class GeoPoint {
/// Create a [GeoPoint] from native data.
GeoPoint.fromNative(Map<dynamic, dynamic> data)
: latitude = data['latitude'],
longitude = data['longitude'];
: latitude = data['latitude'] as double?,
longitude = data['longitude'] as double?;
}
/// Phone number info.
... ... @@ -412,8 +412,8 @@ class Phone {
/// Create a [Phone] from native data.
Phone.fromNative(Map<dynamic, dynamic> data)
: number = data['number'],
type = PhoneType.values[data['type']];
: number = data['number'] as String?,
type = PhoneType.values[data['type'] as int];
}
/// A sms message from a 'SMS:' or similar QRCode type.
... ... @@ -430,8 +430,8 @@ class SMS {
/// Create a [SMS] from native data.
SMS.fromNative(Map<dynamic, dynamic> data)
: message = data['message'],
phoneNumber = data['phoneNumber'];
: message = data['message'] as String?,
phoneNumber = data['phoneNumber'] as String?;
}
/// A URL and title from a 'MEBKM:' or similar QRCode type.
... ... @@ -448,8 +448,8 @@ class UrlBookmark {
/// Create a [UrlBookmark] from native data.
UrlBookmark.fromNative(Map<dynamic, dynamic> data)
: title = data['title'],
url = data['url'];
: title = data['title'] as String?,
url = data['url'] as String?;
}
/// A wifi network parameters from a 'WIFI:' or similar QRCode type.
... ... @@ -471,9 +471,9 @@ class WiFi {
/// Create a [WiFi] from native data.
WiFi.fromNative(Map<dynamic, dynamic> data)
: encryptionType = EncryptionType.values[data['encryptionType']],
ssid = data['ssid'],
password = data['password'];
: encryptionType = EncryptionType.values[data['encryptionType'] as int],
ssid = data['ssid'] as String?,
password = data['password'] as String?;
}
enum BarcodeFormat {
... ...
import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'barcode.dart';
Size toSize(Map<dynamic, dynamic> data) {
final width = data['width'];
final height = data['height'];
Size toSize(Map<dynamic, double> data) {
final width = data['width']!;
final height = data['height']!;
return Size(width, height);
}
List<Offset>? toCorners(List<dynamic>? data) {
List<Offset>? toCorners(List<Map>? data) {
if (data != null) {
return List.unmodifiable(data.map((e) => Offset(e['x'], e['y'])));
return List.unmodifiable(data.map((e) => Offset(e['x'] as double, e['y'] as double)));
} else {
return null;
}
... ... @@ -51,7 +51,7 @@ BarcodeFormat toFormat(int value) {
}
}
CalendarEvent? toCalendarEvent(Map<dynamic, dynamic>? data) {
CalendarEvent? toCalendarEvent(Map<dynamic, String?>? data) {
if (data != null) {
return CalendarEvent.fromNative(data);
} else {
... ... @@ -59,15 +59,15 @@ CalendarEvent? toCalendarEvent(Map<dynamic, dynamic>? data) {
}
}
DateTime? toDateTime(Map<dynamic, dynamic>? data) {
DateTime? toDateTime(Map<String, dynamic>? data) {
if (data != null) {
final year = data['year'];
final month = data['month'];
final day = data['day'];
final hour = data['hours'];
final minute = data['minutes'];
final second = data['seconds'];
return data['isUtc']
final year = data['year'] as int;
final month = data['month'] as int;
final day = data['day'] as int;
final hour = data['hours'] as int;
final minute = data['minutes'] as int;
final second = data['seconds'] as int;
return data['isUtc'] as bool
? DateTime.utc(year, month, day, hour, minute, second)
: DateTime(year, month, day, hour, minute, second);
} else {
... ...
... ... @@ -4,7 +4,7 @@ library jsqr;
import 'package:js/js.dart';
@JS('jsQR')
external Code? jsQR(var data, int? width, int? height);
external Code? jsQR(dynamic data, int? width, int? height);
@JS()
class Code {
... ...
... ... @@ -26,7 +26,7 @@ class VideoOptions {
external Map get height;
external factory VideoOptions(
{String? facingMode, DeviceIdOptions? deviceId, Map? width, Map? height});
{String? facingMode, DeviceIdOptions? deviceId, Map? width, Map? height, });
}
@JS()
... ...
... ... @@ -4,7 +4,7 @@ library qrscanner;
import 'package:js/js.dart';
@JS('QrScanner')
external String scanImage(var data);
external String scanImage(dynamic data);
@JS()
class QrScanner {
... ...
... ... @@ -8,16 +8,16 @@ environment:
flutter: ">=1.10.0"
dependencies:
js: ^0.6.3
flutter:
sdk: flutter
flutter_web_plugins:
sdk: flutter
js: ^0.6.3
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.4
lint: ^1.8.2
flutter:
plugin:
... ...