SHARE
TWEET

Bla




Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:simple_permissions/simple_permissions.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatelessWidget {
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Flutter Demo',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: MyHomePage(title: 'Flutter Demo Home Page'),
- );
- }
- }
- class MyHomePage extends StatefulWidget {
- MyHomePage({Key key, this.title}) : super(key: key);
- final String title;
- @override
- _MyHomePageState createState() => _MyHomePageState();
- }
- class _MyHomePageState extends State<MyHomePage> {
- var _data = "Scan";
- //Fungsi Untuk Check Permission Camera -> Scan QR
- void scanQr() async {
- bool isAllowed = await SimplePermissions.checkPermission(Permission.Camera);
- PermissionStatus status = PermissionStatus.notDetermined;
- if (isAllowed) {
- print("Di izinkan");
- }
- requestPermission();
- }
- requestPermission() async {
- final res = await SimplePermissions.requestPermission(Permission.Camera);
- print("permission request result is " + res.toString());
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: Colors.white,
- body: Center(
- child: GestureDetector(
- onTap: (){
- scanQr();
- },
- child: Container(
- width: 150.0,
- height: 50.0,
- decoration: BoxDecoration(
- color: Colors.greenAccent[400]
- ),
- child: Center(
- child: Text(_data, style: TextStyle(color: Colors.white),),
- ),
- ),
- ),
- ),
- );
- }
- }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.