|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_scankit/scan_kit_widget.dart';
|
|
|
|
import 'package:huixiang/generated/l10n.dart';
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:image_pickers/image_pickers.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
|
|
|
|
class QrCodeScanPage extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _QrCodeScanPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _QrCodeScanPage extends State<QrCodeScanPage> {
|
|
|
|
|
|
|
|
ScanKitController _controller;
|
|
|
|
final screenWidth = window.physicalSize.width;
|
|
|
|
final screenHeight = window.physicalSize.height;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
body: Container(
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
Positioned(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: ScanKitWidget(
|
|
|
|
callback: (controller) {
|
|
|
|
_controller = controller;
|
|
|
|
controller.onResult.listen((result) {
|
|
|
|
debugPrint("scanning result:$result");
|
|
|
|
Navigator.of(context).pop(result);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
continuouslyScan: false,
|
|
|
|
boundingBox: Rect.fromLTRB(0, 0, screenWidth, screenHeight),
|
|
|
|
),
|
|
|
|
flex: 1,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
top: 0,
|
|
|
|
bottom: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
child: MyAppBar(
|
|
|
|
title: "扫码",
|
|
|
|
titleColor: Colors.white,
|
|
|
|
leadingColor: Colors.white,
|
|
|
|
brightness: Brightness.dark,
|
|
|
|
background: Colors.transparent,
|
|
|
|
action: Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
margin: EdgeInsets.only(right: 16.w),
|
|
|
|
child: GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
_controller.pickPhoto();
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
S.of(context).xiangce,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.black,
|
|
|
|
fontSize: 18.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
// if (this._controller != null) {
|
|
|
|
// this._controller.dispose();
|
|
|
|
// }
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
}
|