我有这些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)
想要的结果是这样的:
这有可能吗?
我有一个带有 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 上测试。