我已经浏览了local_auth包,它工作正常,但没有选项可以使用密码或引脚进行身份验证.帮助赞赏!
String _authorized = 'Not Authorized';//Start
Future<Null> _authenticate() async {
final LocalAuthentication auth = new LocalAuthentication();
bool authenticated = false;
try {
authenticated = await auth.authenticateWithBiometrics(
localizedReason: 'Scan your fingerprint to authenticate',
useErrorDialogs: true,
stickyAuth: false);
authenticated = await auth.authenticateWithBiometrics(localizedReason: 'Authenticate');
} on PlatformException catch (e) {
print(e);
}
if (!mounted) return;
setState(() {
_authorized = authenticated ? 'Authorized' : 'Not Authorized';
});
}//End
Run Code Online (Sandbox Code Playgroud)
所以这是示例代码,您可以使用生物识别身份验证,但是指纹中还存在默认的Pin/Password身份验证.
// On this noteItem long press i want to show a snackbar
class NoteItem extends StatelessWidget {
NoteItem({Note note, this.removeNote}): note = note, super(key: ObjectKey(note));
final Note note;
final RemoveNote removeNote;
@override
Widget build(BuildContext context){
return ListTile(
onLongPress: () {
removeNote(note);
},
leading: CircleAvatar(
backgroundColor: Theme.of(context).primaryColor,
child: Text(note.title[0]),
),
title: Text(note.title),
);
}
}
// This class gives the state`enter code here`
class _NoteListState extends State<NoteList> {
void _addNote() {
setState(() {
widget.notes.add(Note(title: 'New Note', description: 'Successfully Added New Note')); …Run Code Online (Sandbox Code Playgroud)