为容器中的容器设置装饰
Set decoration for container in container
Error: Cannot provide both a color and a decoration To provide both,
use "decoration: BoxDecoration(color: color)".
'package:flutter/src/widgets/container.dart': Failed assertion: line
274 pos 15: 'color == null || decoration == null'
Container(
height: 250,
child: PageView.builder(
controller: _pageController,
itemCount: listTmp.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.only(left: 5, right: 5),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10), // <= Error here
),
height: 100,
child: Text(listTmp[index]),
color: Colors.red,
),
);
},
onPageChanged: (index) {
setState(() {
_currentIndex = index;
});
},
),
),
无论何时使用 BoxDecoration()
记得将颜色参数放在 BoxDecoration()
.
中
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10), // <= No more error here :)
color: Colors.red,
),
height: 100,
child: Text(listTmp[index]),
),
);
Error: Cannot provide both a color and a decoration To provide both, use "decoration: BoxDecoration(color: color)". 'package:flutter/src/widgets/container.dart': Failed assertion: line 274 pos 15: 'color == null || decoration == null'
Container(
height: 250,
child: PageView.builder(
controller: _pageController,
itemCount: listTmp.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.only(left: 5, right: 5),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10), // <= Error here
),
height: 100,
child: Text(listTmp[index]),
color: Colors.red,
),
);
},
onPageChanged: (index) {
setState(() {
_currentIndex = index;
});
},
),
),
无论何时使用 BoxDecoration()
记得将颜色参数放在 BoxDecoration()
.
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10), // <= No more error here :)
color: Colors.red,
),
height: 100,
child: Text(listTmp[index]),
),
);