2020-06-24 16:06:15 +06:30
|
|
|
import 'package:barcode_scan/barcode_scan.dart';
|
|
|
|
|
import 'package:barcode_scan/model/scan_result.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
2020-06-25 15:34:41 +06:30
|
|
|
import 'package:flutter_icons/flutter_icons.dart';
|
2020-06-24 16:06:15 +06:30
|
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:fcs/model/product_model.dart';
|
2020-09-04 15:30:10 +06:30
|
|
|
import 'package:fcs/fcs/common/helpers/theme.dart';
|
2020-06-24 16:06:15 +06:30
|
|
|
import 'package:fcs/vo/buyer.dart';
|
|
|
|
|
import 'package:fcs/vo/product.dart';
|
|
|
|
|
import 'package:fcs/widget/progress.dart';
|
|
|
|
|
|
|
|
|
|
class BarcodeScreenPage extends StatefulWidget {
|
|
|
|
|
final BuyerProduct buyerProduct;
|
|
|
|
|
const BarcodeScreenPage({Key key, this.buyerProduct}) : super(key: key);
|
|
|
|
|
@override
|
|
|
|
|
_BarcodeScreenPageState createState() => _BarcodeScreenPageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _BarcodeScreenPageState extends State<BarcodeScreenPage> {
|
|
|
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
ScanResult scanResult;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
backgroundColor: primaryColor,
|
|
|
|
|
title: Text("Bar Code Scranner"),
|
|
|
|
|
),
|
|
|
|
|
body: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
|
children: <Widget>[
|
2020-06-25 15:34:41 +06:30
|
|
|
InkWell(
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Text(
|
|
|
|
|
"Scan : ",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
fontSize: 20),
|
|
|
|
|
),
|
|
|
|
|
Icon(
|
|
|
|
|
Ionicons.ios_qr_scanner,
|
|
|
|
|
size: 50,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
onTap: () async {
|
2020-06-24 16:06:15 +06:30
|
|
|
await scan();
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future scan() async {
|
|
|
|
|
var result = await BarcodeScanner.scan();
|
|
|
|
|
print("ScanResult => $result");
|
|
|
|
|
setState(() => scanResult = result);
|
|
|
|
|
}
|
|
|
|
|
}
|