Ver a proveniência

imp: apply flutter_lints suggestions

flutter-beta
Julian Steenbakker há 4 anos
ascendente
cometimento
a845c9e615
Não foi encontrada uma chave conhecida para esta assinatura, na base de dados ID da chave GPG: ACF0400DFB95F3FD
5 ficheiros alterados com 31 adições e 24 eliminações
  1. +1
    -1
      analysis_options.yaml
  2. +1
    -1
      example/analysis_options.yaml
  3. +17
    -13
      example/lib/main.dart
  4. +3
    -3
      lib/src/qr_code_scanner.dart
  5. +9
    -6
      lib/src/web/flutter_qr_web.dart

+ 1
- 1
analysis_options.yaml Ver ficheiro

@@ -1 +1 @@
include: package:flutter_lints/flutter.dart
include: package:flutter_lints/flutter.yaml

+ 1
- 1
example/analysis_options.yaml Ver ficheiro

@@ -1 +1 @@
include: package:flutter_lints/flutter.dart
include: package:flutter_lints/flutter.yaml

+ 17
- 13
example/lib/main.dart Ver ficheiro

@@ -5,7 +5,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';

void main() => runApp(MaterialApp(home: MyHome()));
void main() => runApp(const MaterialApp(home: MyHome()));

class MyHome extends StatelessWidget {
const MyHome({Key? key}) : super(key: key);
@@ -13,15 +13,15 @@ class MyHome extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Flutter Demo Home Page')),
appBar: AppBar(title: const Text('Flutter Demo Home Page')),
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => QRViewExample(),
builder: (context) => const QRViewExample(),
));
},
child: Text('qrView'),
child: const Text('qrView'),
),
),
);
@@ -29,6 +29,8 @@ class MyHome extends StatelessWidget {
}

class QRViewExample extends StatefulWidget {
const QRViewExample({Key? key}) : super(key: key);

@override
State<StatefulWidget> createState() => _QRViewExampleState();
}
@@ -66,13 +68,13 @@ class _QRViewExampleState extends State<QRViewExample> {
Text(
'Barcode Type: ${describeEnum(result!.format)} Data: ${result!.code}')
else
Text('Scan a code'),
const Text('Scan a code'),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
child: ElevatedButton(
onPressed: () async {
await controller?.toggleFlash();
@@ -86,7 +88,7 @@ class _QRViewExampleState extends State<QRViewExample> {
)),
),
Container(
margin: EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
child: ElevatedButton(
onPressed: () async {
await controller?.flipCamera();
@@ -99,7 +101,7 @@ class _QRViewExampleState extends State<QRViewExample> {
return Text(
'Camera facing ${describeEnum(snapshot.data!)}');
} else {
return Text('loading');
return const Text('loading');
}
},
)),
@@ -111,21 +113,23 @@ class _QRViewExampleState extends State<QRViewExample> {
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
child: ElevatedButton(
onPressed: () async {
await controller?.pauseCamera();
},
child: Text('pause', style: TextStyle(fontSize: 20)),
child: const Text('pause',
style: TextStyle(fontSize: 20)),
),
),
Container(
margin: EdgeInsets.all(8),
margin: const EdgeInsets.all(8),
child: ElevatedButton(
onPressed: () async {
await controller?.resumeCamera();
},
child: Text('resume', style: TextStyle(fontSize: 20)),
child: const Text('resume',
style: TextStyle(fontSize: 20)),
),
)
],
@@ -175,7 +179,7 @@ class _QRViewExampleState extends State<QRViewExample> {
log('${DateTime.now().toIso8601String()}_onPermissionSet $p');
if (!p) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('no Permission')),
const SnackBar(content: Text('no Permission')),
);
}
}


+ 3
- 3
lib/src/qr_code_scanner.dart Ver ficheiro

@@ -126,7 +126,7 @@ class _QRViewState extends State<QRView> {
onPlatformViewCreated: _onPlatformViewCreated,
creationParams:
_QrCameraSettings(cameraFacing: widget.cameraFacing).toMap(),
creationParamsCodec: StandardMessageCodec(),
creationParamsCodec: const StandardMessageCodec(),
);
break;
case TargetPlatform.iOS:
@@ -135,7 +135,7 @@ class _QRViewState extends State<QRView> {
onPlatformViewCreated: _onPlatformViewCreated,
creationParams:
_QrCameraSettings(cameraFacing: widget.cameraFacing).toMap(),
creationParamsCodec: StandardMessageCodec(),
creationParamsCodec: const StandardMessageCodec(),
);
break;
default:
@@ -327,7 +327,7 @@ class QRViewController {
{QrScannerOverlayShape? overlay}) async {
if (defaultTargetPlatform == TargetPlatform.iOS) {
// Add small delay to ensure the render box is loaded
await Future.delayed(Duration(milliseconds: 300));
await Future.delayed(const Duration(milliseconds: 300));
if (key.currentContext == null) return false;
final renderBox = key.currentContext!.findRenderObject() as RenderBox;
try {


+ 9
- 6
lib/src/web/flutter_qr_web.dart Ver ficheiro

@@ -1,3 +1,5 @@
// ignore_for_file: avoid_web_libraries_in_flutter

import 'dart:async';
import 'dart:core';
import 'dart:html' as html;
@@ -59,11 +61,11 @@ class _WebQrViewState extends State<WebQrView> {

QRViewControllerWeb? _controller;

late Size _size = Size(0, 0);
late Size _size = const Size(0, 0);
Timer? timer;
String? code;
String? _errorMsg;
var video;
html.VideoElement video = html.VideoElement();
String viewID = 'QRVIEW-' + DateTime.now().millisecondsSinceEpoch.toString();

final StreamController<Barcode> _scanUpdateController =
@@ -78,13 +80,13 @@ class _WebQrViewState extends State<WebQrView> {

facing = widget.cameraFacing ?? CameraFacing.front;

video = html.VideoElement();
// video = html.VideoElement();
WebQrView.vidDiv.children = [video];
// ignore: UNDEFINED_PREFIXED_NAME
ui.platformViewRegistry
.registerViewFactory(viewID, (int id) => WebQrView.vidDiv);
// giving JavaScipt some time to process the DOM changes
Timer(Duration(milliseconds: 500), () {
Timer(const Duration(milliseconds: 500), () {
start();
});
}
@@ -92,7 +94,8 @@ class _WebQrViewState extends State<WebQrView> {
Future start() async {
await _makeCall();
_frameIntervall?.cancel();
_frameIntervall = Timer.periodic(Duration(milliseconds: 200), (timer) {
_frameIntervall =
Timer.periodic(const Duration(milliseconds: 200), (timer) {
_captureFrame2();
});
}
@@ -202,7 +205,7 @@ class _WebQrViewState extends State<WebQrView> {
return Center(child: Text(_errorMsg!));
}
if (_localStream == null) {
return Center(child: CircularProgressIndicator());
return const Center(child: CircularProgressIndicator());
}
return LayoutBuilder(
builder: (context, constraints) {


Carregando…
Cancelar
Guardar