0
votes

I'm using local_auth for user verification.

The root widget of my app is a stateless widget.

The bug: The authentication screen pops up as usual. If the fingerprint (or pin) matches, the user can then access the app. However, if the back button is pressed (while the authentication screen is still up), the authentication window vanishes and the user can access the app without authenticating.

I'm using Flutter-2.5.3 and local_auth-1.1.8.

This is the main.dart:

//other imports here
import 'package:local_auth/local_auth.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  var localAuth = LocalAuthentication();
  SharedPreferences prefs = await SharedPreferences.getInstance();

  if (prefs.getBool('auth') == true) {
    await localAuth.authenticate(
        localizedReason: 'Authenticate to access Notes',
        useErrorDialogs: true,
        stickyAuth: true,);
  }

  await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]).then((_) {
    runApp(ProviderScope(child: MyApp()));
  });
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    //returns my widget
  }
}