为什么Positioned红色widget是透明的,这样可以透过它看到Second Label Text widget?
设置: 列:
- 堆
- 文本域
- 定位
- 红色容器
- TextField(第二个标签文本)
目的是红色小部件以不透明的方式覆盖其下方的文本字段。
谢谢
@override
Widget build(BuildContext context) {
const pad = 16.0;
const vertPadding = 10.0;
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Column(children: [
Stack(clipBehavior: Clip.none, children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 5.0),
child: TextField(
autocorrect: false,
maxLines: null,
decoration: InputDecoration(
border: _border,
labelText: "Label text",
labelStyle: TextStyle(color: Colors.grey),
),
),
),
Positioned(
top: pad,
left: pad,
width: 200.0,
child: Container(
decoration: BoxDecoration(
color: Colors.red,
),
width: 200,
height: 84,
child: Padding(
padding:
const EdgeInsets.fromLTRB(16, vertPadding, 0, vertPadding),
child: Container(),
),
),
),
]),
Padding(
padding: const EdgeInsets.fromLTRB(25, 0, 25, 0),
child: TextField(
decoration: InputDecoration(
border: _border,
labelText: "Second Label text",
),
),
)
]),
);
}
final OutlineInputBorder _border = OutlineInputBorder(
borderRadius: BorderRadius.circular(4.0),
borderSide: BorderSide(
color: Colors.grey,
width: 1.0,
),
);