我試圖在這兩張圖片之間添加填充物,但無法做到,我試著在子圖片中添加填充物
。class 品牌滑塊 extends StatelessWidget{
final config;
const BrandSlider({required Key key, this.config}) : super(key: 關鍵)。
@override
Widget build(BuildContext context) {
return SizedBox(
高度。100,
孩子。ListView.builder(
滾動方向。Axis.horizontal,
itemBuilder: (context, index) {
return InkWell(
// splashColor: Colors.orange,/span>
onTap: () {
ProductModel.showList(
context: 背景關系, brandIds: config['items'][index]['id'])。)
},
孩子。Image.network(config['items'][index]['image'] )。
);
},
itemCount: brands.length,
),
);
}
}
uj5u.com熱心網友回復:
我認為ListView.separated在這種情況下會更合適。
class BrandSlider extends StatelessWidget{
final config;
const BrandSlider({required Key key, this.config}) : super(key: 關鍵)。
@override
Widget build(BuildContext context) {
return SizedBox(
高度。100,
孩子。ListView.separated(
separatorBuilder。(context, index) => SizedBox(
width: 20,
),
scrollDirection: Axis.horizontal,
itemBuilder。(context, index) {
return InkWell(
splashColor: Colors.orange,
onTap: () {
ProductModel.showList(
context: context, brandIds: config['items'][index]['id'])。)
},
孩子。Image.network(config['items'][index]['image'] )。
);
},
itemCount: brands.length,
),
);
}
}
uj5u.com熱心網友回復:
你可以使用Listview padding屬性
class BrandSlider extends StatelessWidget {
final config;
const BrandSlider({required Key key, this.config}) : super(key: 關鍵)。
@override
Widget build(BuildContext context) {
return SizedBox(
高度。100,
孩子。ListView.builder(
padding: EdgeInsets.symmetric(horizontal: 8) 。
scrollDirection: Axis.horizontal,
itemBuilder。(context, index) {
return InkWell(
// splashColor: Colors.orange,/span>
onTap: () {
ProductModel.showList(
context: 背景關系, brandIds: config['items'][index]['id'])。)
},
孩子。Image.network(config['items'][index]['image'] )。
);
},
itemCount: brands.length,
),
);
}
}
uj5u.com熱心網友回復:
用padding包住墨池,如果不行,就增加SizedBox的高度
。Padding(padding:EdgeInsets.all(8.0) ,child:InkWell(
// splashColor: Colors.orange,
onTap: () {
ProductModel.showList(
context: context, brandIds: config['items'][index]['id'])。)
},
孩子。Image.network(config['items'][index]['image'] )。
));
uj5u.com熱心網友回復:
你不應該把padding放在孩子身上。你應該讓它成為父節點。
return Padding(
padding:EdgeInsets.only(right:20) 。
child:InkWell(
//splashColor:Colors.orange,.
onTap: () {
ProductModel.showList(
context: 背景關系, brandIds: config['items'][index]['id'])。)
},
孩子。Image.network(config['items'][index]['image'] )。
...
uj5u.com熱心網友回復:
@override
Widget build(BuildContext context) {
return SizedBox(
高度。100,
孩子。ListView.builder(
滾動方向。Axis.horizontal,
itemBuilder: (context, index) {
return InkWell(
// splashColor: Colors.orange,/span>
onTap: () {
ProductModel.showList(
context: 背景關系, brandIds: config['items'][index]['id'])。)
},
孩子。容器(
padding:EdgeInsets.all(10.0) 。
孩子。Image.network(config['items'][index]['image']),)。
);
},
itemCount: brands.length,
),
);
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/326622.html
標籤:
上一篇:串列視圖不能堆疊在一個容器上
下一篇:在js中制作一個檢查質數的函式

