我在学习 Flutter 或任何编码方面花了 3 周时间,基本上我想创建一个部分,用户将他们的详细信息输入到 firebase 中,然后单击一个按钮,它会发出一个通知,说明他们的注册已完成,我尝试了一种有人建议使用 {awaitxx, awaitxx} 方法的方法,但是,它不起作用,firebase 工作得非常好顺便说一句,有人介意在这里帮助一个菜鸟吗?
class VehicleRegNotification extends StatefulWidget {
@override
_VehicleRegNotificationState createState() => _VehicleRegNotificationState();
}
class _VehicleRegNotificationState extends State<VehicleRegNotification> {
final notifications = FlutterLocalNotificationsPlugin();
@override
void initState() {
super.initState();
final settingsAndroid = AndroidInitializationSettings('icon v1.21024');
final settingsIOS = IOSInitializationSettings(
onDidReceiveLocalNotification: (id, title, body, payload) =>
onSelectNotification(payload));
notifications.initialize(
InitializationSettings(settingsAndroid, settingsIOS),
onSelectNotification: onSelectNotification);
}
Future onSelectNotification(String payload) async =>
await Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondPage(payload: payload)),
);
Padding(padding:
EdgeInsets.symmetric(horizontal: 40),
child: Container(
padding: EdgeInsets.only(top: 3, left: 3),
child: Column(
children: <Widget>[
SizedBox(height:20),
MaterialButton(
minWidth: double.infinity,
height: 60,
onPressed: () async {
await users.add({
'name' : name,
'id' : id,
'num' : num,
'vehicle' : vehicle });
Navigator.pop(context, MaterialPageRoute(builder: (context) => StudentSection()));
showOngoingNotification(notifications, title: 'Tite', body: 'Body');},
color: Color(0xff0095FF),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50)
),
child: Text(
"Complete Registration",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 18
),
),
)
],
)
),
),