local_biometric_auth 1.0.3 copy "local_biometric_auth: ^1.0.3" to clipboard
local_biometric_auth: ^1.0.3 copied to clipboard

local biometric auth

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get_storage/get_storage.dart';
import 'package:local_biometric_auth/local_biometric_auth.dart';
import 'package:provider/provider.dart';

import 'states/states.dart';
import 'widgets/widgets.dart';

main() async {
  await GetStorage.init();
  runApp(MultiProvider(
    providers: [
      ChangeNotifierProvider(create: (_) => AppState()),
      ChangeNotifierProvider(create: (_) => MessagesState()),
    ],
    child: MyAppCheckVersion(),
  ));
}

class App extends StatelessWidget {
  const App({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        brightness: Brightness.light,
      ),
      darkTheme: ThemeData(
        brightness: Brightness.dark,
      ),
      themeMode: ThemeMode.dark,
      home: const Home(),
    );
  }
}

class Home extends StatelessWidget {
  const Home({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Consumer<AppState>(
      builder: (_, app, __) => WillPopScope(
        onWillPop: () {
          if (app.isWrite || app.isRead) {
            app.showList();
            return Future.value(false);
          }

          return Future.value(true);
        },
        child: Scaffold(
          appBar: AppBar(
            title: Text('BiometricX'),
            centerTitle: true,
          ),
          body: Builder(
            builder: (_) {
              if (app.isWrite) return WriteMessage();
              if (app.isRead) return ReadMessage(app.currentMessage);
              return MessageList();
            },
          ),
          floatingActionButtonLocation:
              FloatingActionButtonLocation.centerFloat,
          floatingActionButton: app.isList
              ? FloatingActionButton(
                  child: Icon(Icons.add_rounded),
                  onPressed: app.write,
                )
              : null,
        ),
      ),
    );
  }
}

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

  @override
  State<MyAppCheckVersion> createState() => _MyAppState();
}

class _MyAppState extends State<MyAppCheckVersion> {
  final _youtubeChecker = AppVersionChecker(
    appId: "com.runsystem.wesmile",
    androidStore: AndroidStore.apkPure,
  );
  final _snapChatChecker = AppVersionChecker(
    appId: "com.runsystem.wesmile",
  );
  String? snapValue;
  String? youtubeValue;

  @override
  void initState() {
    super.initState();
    checkVersion();
  }

  void checkVersion() async {
    await Future.wait([
      _snapChatChecker.checkUpdate().then(
        (value) {
          snapValue = value.toString();
        },
      ),
      _youtubeChecker
          .checkUpdate()
          .then((value) => youtubeValue = value.toString()),
    ]);

    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('APP Version Checker'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(12.0),
          child: ListView(
            children: [
              const SizedBox(height: 25.0),
              const Text(
                "Facebook: (playstore)",
                style: TextStyle(fontWeight: FontWeight.bold),
              ),
              const SizedBox(height: 10.0),
              Text(
                snapValue ?? 'Loading ...',
              ),
              const SizedBox(height: 50.0),
              const Text(
                "Youtube Vanced (apkPure):",
                style: TextStyle(fontWeight: FontWeight.bold),
              ),
              const SizedBox(height: 10.0),
              Text(
                youtubeValue ?? "loading ...",
              ),
            ],
          ),
        ),
      ),
    );
  }
}