face_detection_lock 0.0.1+1 copy "face_detection_lock: ^0.0.1+1" to clipboard
face_detection_lock: ^0.0.1+1 copied to clipboard

This widget will unlock screen when a face is detected looking at app.

example/lib/main.dart

import 'dart:developer';

import 'package:face_detection_lock/face_detection_lock.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:physical_security_app/main_app_content_placeholder.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
      DeviceOrientation.portraitDown,
    ]);
    return MaterialApp(title: 'Secure screen Demo', home: WidgetToggle());
  }
}

class WidgetToggle extends HookWidget {
  const WidgetToggle({super.key});

  @override
  Widget build(BuildContext context) {
    final isAbove = useState(false);
    return Scaffold(
      body: isAbove.value
          ? BlocProvider(
              create: (context) => FaceDetectionBloc(
                onFaceSnapshot: (faces) {
                  log(faces.toString());
                },
                // cameraController: _yourCameracontroller
              )..add(const FaceDetectionEvent.initializeCam()),
              child: FaceDetectionLock(
                isBlocInitializeAbove: isAbove.value,
                body: MainAppContentPlaceholder(),
              ),
            )
          : FaceDetectionLock(
              body: MainAppContentPlaceholder(),
            ),
      floatingActionButton: ElevatedButton(
        child: Text('Switch to isBlocInitialize = ${!isAbove.value}'),
        onPressed: () {
          isAbove.value = !isAbove.value;
        },
      ),
    );
  }
}
7
likes
120
pub points
12%
popularity

Publisher

verified publisherflutterplaza.com

This widget will unlock screen when a face is detected looking at app.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

camera, flutter, flutter_bloc, freezed_annotation, google_ml_vision

More

Packages that depend on face_detection_lock