Flutter - 如何将 "Switch" 转换为 "raised button"(推送通知)?

Flutter - How to convert "Switch" to "raised button" ( Push-Notifications )?

我想将“开关”转换为“凸起按钮”或类似的东西,并获得相应的功能...

                      **Switch(
                        onChanged: (bool enabled) {
                          setState(() {
                            _notificationsEnabled = enabled;
                            _updateNotifications(enabled);
                          });
                        },
                        value: _notificationsEnabled,
                      ),**

总代码摘录:

                Container(
                  margin: EdgeInsets.only(top: 5.0, bottom: 5.0, right: 5.0, left: 5.0),
                  decoration: BoxDecoration(
                      border: Border(
                          bottom: BorderSide(
                              color: Colors.black.withOpacity(0.13)
                          )
                      )
                  ),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text('PUSH-BENACHRICHTIGUNGEN AKTIVIEREN', style: TextStyle(color: isDark ? Colors.cyanAccent : Color(0xFF000000), fontFamily: "Storopia", fontSize: 13.0)),
                      **Switch(
                        onChanged: (bool enabled) {
                          setState(() {
                            _notificationsEnabled = enabled;
                            _updateNotifications(enabled);
                          });
                        },
                        value: _notificationsEnabled,
                      ),**
                    ],
                  ),
                ),

pictorial representation

目标是创建一个“凸起按钮”,当推送通知被激活时它会亮起绿色,当它们被停用时它会亮起红色而不是开关。我不确定是否有一个简单的解决方案,但我希望有人有一个简单的解决方案,因为我是新手。我之前在这里得到过帮助,超级简单快捷,我感到非常惊讶,认为这里有如此活跃的社区真是太好了

**Switch(
                        onChanged: (bool enabled) {
                          setState(() {
                            _notificationsEnabled = enabled;
                            _updateNotifications(enabled);
                          });
                        },
                        value: _notificationsEnabled,
                      ),**

你可以使用三元:

// Below your stateful widget class
bool _enabled = false;

// [...]

RaisedButton(
      color: _enabled ? Colors.green : Colors.red,
      onPressed: () {
        setState(() {
          _enabled = !_enabled;
          _updateNotifications(_enabled);
        });
      },
      child: Text(_enabled? "On" : "Off")),