我想在库比蒂诺交换机内添加文本,就像附加的图像一样.有没有办法做到这一点?

enter image description here

推荐答案

我创建自定义窗口小部件,但其中没有立方体switch 动画.我希望这能满足你的需要

GestureDetector(
                                onTap: () {
                                  setState(() {
                                    val = !val;
                                  });
                                },
                                child: Container(
                                  width: size.width * 0.35,
                                  decoration: BoxDecoration(
                                      borderRadius: BorderRadius.circular(30),
                                      color: kSecondaryColor),
                                  child: Padding(
                                    padding: const EdgeInsets.all(8.0),
                                    child: Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceBetween,
                                      children: [
                                        Container(
                                          width: 60,
                                          height: 30,
                                          decoration: BoxDecoration(
                                              borderRadius:
                                                  BorderRadius.circular(30),
                                              color: val
                                                  ? Colors.white
                                                  : kSecondaryColor),
                                          child: Center(
                                              child: Text(
                                            'BUY',
                                            style: TextStyle(
                                                fontWeight: FontWeight.bold,
                                                color: val
                                                    ? Colors.black
                                                    : Colors.white),
                                          )),
                                        ),
                                        Container(
                                          width: 60,
                                          height: 30,
                                          decoration: BoxDecoration(
                                              borderRadius:
                                                  BorderRadius.circular(30),
                                              color: val
                                                  ? kSecondaryColor
                                                  : Colors.white),
                                          child: Center(
                                              child: Text(
                                            'SELL',
                                            style: TextStyle(
                                                fontWeight: FontWeight.bold,
                                                color: val
                                                    ? Colors.white
                                                    : Colors.black),
                                          )),
                                        ),
                                      ],
                                    ),
                                  ),
                                ),
                              ),

image

Flutter相关问答推荐

在Flutter 动中绘制ECG图

为什么Flutter InAppWebView中的DatePicker看起来很旧?

blocTest错误:没有从`when()`中调用方法存根

分页控制器在到达页面末尾之前或在初始化页面时对每个索引调用API

有没有可能不在BlocBuilder中重新构建内容?

如何确定Flutter 中的文本 colored颜色 ?

在 Flutter 中,SpinEdit 叫什么?

MediaQuery 在不同手机上不一致

Flutter 分析发现 Gitlab CI/CD 管道中的问题,但它在本地没有

Flutter可滚动定位列表支持rtl方向吗?

如何在 Flutter 中测试动画图标

Flutter:为什么我的 listTile colored颜色 被容器 colored颜色 覆盖了?

Getx Flutter 在更新值时抛出空错误

使用 onPressed 切换到另一个屏幕无法正常工作

Flutter Web App 未启动:脚本的 MIME 类型不受支持

使用 Chaquopy 插件后 Gradle Sync 无法正常工作

Flutter NavigationBar 忽略我的背景 colored颜色

解密 Modulr 安全令牌

参数类型Future>不能分配给参数类型Future>?

如何在 Flutter 中创建类似箭头标签的设计