首页 > 解决方案 > 我需要在 Flutter 中发送带有调度的通知

问题描述

我需要在我的应用程序调度通知上加上日期和时间。当用户创建卡片时,输入日期、时间并选择一个选项并收到通知。我知道 Flutter 本地通知,但我无法在我的代码中进行设置。本地通知是最好的解决方案吗?

  buildCard() {
    setState(() {
      cardWidget.add(
        Card(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Padding(
                padding: EdgeInsets.all(20.0),
                child: DateTimeField(
                  resetIcon: Icon(Entypo.ccw),
                  format: DateFormat("dd/MM/yyyy HH:mm"),
                  onShowPicker: (context, currentValue) async {
                    final date = await showDatePicker(
                        context: context,
                        firstDate: DateTime(2020),
                        initialDate: currentValue ?? DateTime.now(),
                        lastDate: DateTime(2100));
                    if (date != null) {
                      final time = await showTimePicker(
                        context: context,
                        initialTime: TimeOfDay.fromDateTime(
                            currentValue ?? DateTime.now()),
                      );
                      return DateTimeField.combine(date, time);
                    } else {
                      return currentValue;
                    }
                  },
                ),
              ),
                          FlatButton(
                color: Colors.green,
                textColor: Colors.white,
                disabledColor: Colors.grey,
                disabledTextColor: Colors.black,
                padding: EdgeInsets.symmetric(horizontal: 50),
                splashColor: Colors.black12,
                onPressed: () {
                  Timer(Duration(seconds: 0), () {
                    show(context);
                  });
                },

                /*...*/

                child: Text(
                  "Criar",
                  style: TextStyle(fontSize: 18.0),
                ),
              ),
            ],
          ),
        ),
      );
    });
    SizedBox(
      height: 27,
    );
  }
 } 

标签: flutter

解决方案


推荐阅读