小编Fot*_*Dim的帖子

在 Flutter 中设置切换按钮之间的间隙

我有这些ToggleButtons,我想让它们之间有一些间距。

ToggleButtons(
  children: <Widget>[
    Icon(Icons.ac_unit),
    Icon(Icons.call),
    Icon(Icons.cake),
  ],
  onPressed: (int index) {
    setState(() {
      isSelected[index] = !isSelected[index];
    });
  },
  isSelected: isSelected,
),
Run Code Online (Sandbox Code Playgroud)

想要的结果是这样的:

在此处输入图片说明

这有可能吗?

layout togglebutton dart flutter

7
推荐指数
1
解决办法
1010
查看次数

重载方法时出现“无法推断通用参数‘T’”错误

我有一个带有 2 个构造函数的小枚举。"Generic parameter 'T' could not be inferred"当我尝试使用参数初始化时出现错误Int

import UIKit

public enum Result<T> {

case Success(T)
case Failure(Int)

   init( any: T) {
       self  = .Success(any)
   }

   init( number: Int) {
       self  = .Failure(number)
   }
}

let a = Result(any: "A String")
print(a)

let b = Result(number: 1)
print(b)
Run Code Online (Sandbox Code Playgroud)

有没有办法Int从 T 中排除或以某种方式优先考虑第二个初始化器?

在 XCode 7.3.1 上测试。

generics xcode enums swift

5
推荐指数
1
解决办法
894
查看次数

标签 统计

dart ×1

enums ×1

flutter ×1

generics ×1

layout ×1

swift ×1

togglebutton ×1

xcode ×1