У меня есть результат таких приложений:
Почему расстояние между изображением и границей выше отличается от расстояния междутекст и границы ниже?Каково решение, чтобы оба предела были на одном и том же расстоянии?не жестко закодированы с использованием полей или отступов, потому что, если устройство работает на разных устройствах, должна быть разница в пространстве.Любой виджет для обработки?
Это мой код для получения списка.
Widget _cardCategory(AsyncSnapshot<CatlistResult> snapshot) {
var numItems = snapshot == null ? 0 : snapshot.data.catlist.sublist(0, 7).length;
return Container(
transform: Matrix4.translationValues(0.0, -20.0, 0.0),
child: Card(
elevation: 5.0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(5))),
margin: EdgeInsets.only(left: 16.0, right: 16.0),
child: numItems == 0 ? Container() : GridView.builder(
shrinkWrap: true,
primary: false, //kill scrollable
itemCount: numItems + 1, //must keep using +1
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
itemBuilder: (BuildContext context, int index) {
String imagePath;
String itemText;
if (index == numItems) {
imagePath = 'assets/images/main/cat_999.png';
itemText = 'More';
} else {
imagePath = 'assets/images/main/cat_${snapshot.data.catlist[index].a}.png';
itemText = snapshot.data.catlist[index].c;
}
return GestureDetector(
child: Card(
elevation: 0.0,
child: Column(
children: <Widget>[
Expanded(
child: Image.asset(imagePath, fit: BoxFit.cover),
),
Text(
itemText,
style: TextStyle(fontSize: 10),
),
],
),
),
// onTap: () {
// nextScreen17(index);
// }
);
},
),
),
);
}