fqreader 0.2.2
fqreader: ^0.2.2 copied to clipboard

Flutter Android iOS

A highly customizable Scan Widget

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:fqreader/fqreader.dart';
import 'package:flustars/flustars.dart';
import 'package:cool_ui/cool_ui.dart';
// import 'package:image_picker/image_picker.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  GlobalKey<ScanViewState> scanView;
  Size cameraSize;

  @override
  void initState() {
    super.initState();
    scanView = GlobalKey<ScanViewState>();
  }

  @override
  Widget build(BuildContext context) {

    return new MaterialApp(
      home: Builder(builder: (context) {
        ScreenUtil.getInstance().init(context);
        Size pictureSize = Size(
            ScreenUtil.screenWidth,
            ScreenUtil.screenHeight -
                ScreenUtil.appBarHeight -
                ScreenUtil.statusBarHeight);
        if(ScreenUtil.screenDensity == 1){
          return Container();
        }
        Size scanSize =
            Size(ScreenUtil.screenWidth * 0.8, ScreenUtil.screenWidth * 0.8);
        return new Scaffold(
            appBar: new AppBar(
              title: const Text('Plugin example app'),
            ),
            body: Stack(
              children: <Widget>[
                ScanView(
                  key: scanView,
                  scanAilgn: Alignment.center,
                  scanSize: scanSize,
                  viewSize: pictureSize,
                  maskColor: Colors.white,
                  devicePixelRatio: ScreenUtil.screenDensity,
                  onScan: (result) async {
                    showWeuiSuccessToast(context: context, message: Text(result.data));
                    print(result.data);
                    return false;
                  },
                ),
                Container(
                  child:Text('屏幕dp宽度:${ScreenUtil.screenWidth}\n屏幕dp高度:${ScreenUtil.screenHeight}\n DP 对 PX比率:${ScreenUtil.screenDensity}\n' + 
                      (this.cameraSize != null? '图片宽度:${cameraSize.width}\n图片高度:${cameraSize.height}':''))
                )
              ],
            ));
      }),
    );
  }
}
0
likes
75
pub points
50%
popularity

A highly customizable Scan Widget

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

liangkaikevin@gmail.com

License

Apache 2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on fqreader