我正在尝试创建方形按钮,但Expanded似乎与容器的工作方式不同.以下面的代码为例
new Expanded(
flex: 2,
child: new Column(
children: <Widget>[
new Expanded(
child:new Row(
children: <Widget>[
new Expanded(child: new MaterialButton(...)),
new Expanded(child: new MaterialButton(....)),
new Expanded(child: new Container(color: Colors.red)),
new Expanded(child: new Container(color: Colors.green)),
]
)
)
],
)
)
....
Run Code Online (Sandbox Code Playgroud)
它显示两个水平扩展但不垂直的按钮.同时,容器将水平和垂直扩展.如果我执行以下操作,则会产生相同的效果:
new Expanded(
flex: 2,
child: new Column(
children: <Widget>[
new Expanded(
child:new Column(
children: <Widget>[
new Expanded(child: new MaterialButton(...)),
new Expanded(child: new MaterialButton(....)),
new Expanded(child: new Container(color: Colors.red)),
new Expanded(child: new Container(color: Colors.green)),
]
)
)
],
) …Run Code Online (Sandbox Code Playgroud) 这是片段(来自Java Generics and Collections),下面是问题:
public static <T extends Comparable<? super T>> Comparator<T> reverseOrder()
{
return new Comparator<T>() {
public int compare(T o1, T o2) { return o2.compareTo(o1); }
};
}
Run Code Online (Sandbox Code Playgroud)
正如我所遵循的那样,你有一个使用通配符的方法,它可以比较类型T和"上面".然后它返回一个新的Comparator,它在其中显然有一个方法,它使用两个类型为T的对象返回compareTo的值.所以问题:
这没有参数,所以o1和o2来自哪里?