我正在构建我的第一个 Flutter 应用程序,我想创建一个简单的布局:一个背景图像和一个位于其上的半透明材质按钮。
我的 Widget 树非常简单,但 InkWell / Ripple 不可见。为什么我有这种行为?
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Material(
child: new Stack(
children: <Widget>[
new Container(
decoration: new BoxDecoration(
image: new DecorationImage(
image: new AssetImage("res/imgs/splashscreen_bg.png"),
fit: BoxFit.cover,
))),
new Center(
child: new FlatButton(
onPressed: () {}, child: new Text("Hello world")))
],
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
没有背景图像,InkWell 正在工作。我该怎么办?
谢谢
经过一些研究,我发现了这个问题:https : //github.com/flutter/flutter/issues/3782
如果我使用这个新树更改小部件内容,它现在可以工作:
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Stack(
children: <Widget>[
new Container(
decoration: new BoxDecoration(
image: new DecorationImage(
image: new AssetImage("res/imgs/splashscreen_bg.png"),
fit: BoxFit.cover,
))),
new Material(
type: MaterialType.transparency,
child: new FlatButton(...),
)
],
);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5327 次 |
| 最近记录: |