flutter-container

Flutter Container: cannot provide both a color and a decoration

不问归期 提交于 2020-08-02 06:41:34
问题 I want to draw a border around my container and have the background be colored. Widget bodyWidget() { return Container( color: Colors.yellow, decoration: BoxDecoration( border: Border.all(color: Colors.black), ), child: Text("Flutter"), ); } But when I try this I get the error Cannot provide both a color and a decoration The color argument is just a shorthand for "decoration: new BoxDecoration(color: color)". How is this solved? 回答1: Remove the color parameter from the Container and add it to

I want to change the color of CustomListTile which is child of ListView when onTap is clicked, and setting other children color into default one?

拥有回忆 提交于 2020-01-05 08:28:19
问题 In a Drawer, in listview want to change the color of CustomListTile when the onTap is clicked and setting color of all other children to default? class CustomListTile extends StatelessWidget { final Color itemContainerColor; const CustomListTile({ //deafult color is Colors.white this.itemContainerColor= Colors.white, }); @override Widget build(BuildContext context) { return InkWell( onTap: (){}, child: Container( margin: EdgeInsets.symmetric(vertical: 4), padding: EdgeInsets.symmetric

Flutter BoxDecoration’s background color overrides the Container's background color, why?

妖精的绣舞 提交于 2019-12-08 15:07:43
问题 I have a Flutter Container widget and I defined a color for it (pink), but for some reason, the color in BoxDecoration overrides it (green). Why? new Container( color: Colors.pink, decoration: new BoxDecoration( borderRadius: new BorderRadius.circular(16.0), color: Colors.green, ), ); 回答1: Container’s color is shorthand for BoxDecoration’s color , so BoxDecoration's color in the Container's decoration property overrides its Container's color . 来源: https://stackoverflow.com/questions/45724567