【发布时间】:2018-10-24 13:35:41
【问题描述】:
我想在点击下拉列表时更改背景图像,我将点击 BG 1 并且图像会改变,我如何访问下拉列表的单个元素?这是我的代码,我该怎么做?
new Column( children: <Widget>[
new Padding(
padding: new EdgeInsets.fromLTRB(100.0, 350.0, 100.0, 50.0)),
new DropdownButton<String>(
onChanged: (String value) {
setState(() {
return new Container(
padding: const EdgeInsets.fromLTRB(100.0, 10.0, 100.0, 00.0),
decoration: BoxDecoration(
image: DecorationImage(
image: new AssetImage('asset/bg.png'),
alignment: Alignment.topRight,
),
),
);
});
},
hint: new Text('Select Type'),
value: selectedValues,
items: <String>[
"BG 1",
"BG 2",
].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
),
],),
ImageRotate(),
]),
);
}
}
【问题讨论】: