【发布时间】:2023-04-07 18:24:01
【问题描述】:
我的目标是在将 firebase 中的数据显示给用户之前对其运行解密功能。
这是显示数据的小部件:
Widget buildPatientCard(BuildContext context, DocumentSnapshot document) {
final patient = Patient.fromSnapshot(document);
return new Container(
child: Card(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 4.0),
child: Row(children: <Widget>[
Text(patient.name,
style: new TextStyle(
fontSize: 24.0, fontWeight: FontWeight.bold)),
Spacer(),
Text(patient.gender,
style: new TextStyle(
fontSize: 20.0, fontWeight: FontWeight.bold)),
Text(", ",
style: new TextStyle(
fontSize: 20.0, fontWeight: FontWeight.bold)),
Text(patient.age,
style: new TextStyle(
fontSize: 20.0, fontWeight: FontWeight.bold))
]),
),
Padding(
padding: const EdgeInsets.only(top: 4.0, bottom: 80.0),
child: Row(children: <Widget>[
Text(patient.dob,
style: new TextStyle(
fontSize: 16.0, fontWeight: FontWeight.bold)),
Spacer(),
]),
),
Row(
children: <Widget>[
Text(
patient.notes,
style: new TextStyle(fontSize: 16.0),
),
Spacer(),
Icon(Icons.person),
这是患者模型:
Patient.fromSnapshot(DocumentSnapshot snapshot):
patientId = snapshot.documentID,
name = snapshot['Patient name'],
gender = snapshot['Gender'],
age = snapshot['Age'],
dob = snapshot['Date of Birth'],
notes = snapshot['Notes'];
这是我想在每个数据快照显示之前对其运行的解密函数:
_decrypt() async {
var userKey = await getUserKey();
final decryptedText =
await FlutterAesEcbPkcs5.decryptString(DATA FROM FIREBASE HERE, userKey);
return decryptedText;
}
【问题讨论】:
标签: firebase flutter google-cloud-firestore