Im working on a grid of containers that should be displayed.
The current app looks like this
as you can see, there's a giant space between each row.
I found this solution: Flutter remove space between GridView row however the structure and Sliver Widget used it's different.
Right now this is how i have my SliverGrid.
SliverGrid(
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 1.15,
mainAxisSpacing: 0,
crossAxisSpacing: 0,
),
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
print(index);
return HourMenuWidget(
active: _selectedMainPage == index,
onTap: () {
setState(() {
_selectedMainPage = index;
});
},
icon: Icons.dashboard,
title:
provider.doctors[0].hoursAvailable[index],
);
},
childCount:
provider.doctors[0].hoursAvailable.length,
),
),
and the Widget HourMenuWidget
import 'package:flutter/material.dart';
class HourMenuWidget extends StatelessWidget {
const HourMenuWidget({this.active, this.icon, this.title, this.onTap});
final bool active;
final IconData icon;
final String title;
final Function onTap;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
margin: EdgeInsets.symmetric(horizontal: 5.0, vertical: 50.0),
decoration: BoxDecoration(
color: active
? Color.fromRGBO(241, 115, 176, 1.0)
: Color.fromRGBO(233, 233, 233, 1.0),
borderRadius: BorderRadius.circular(10),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
title ?? "",
style: TextStyle(
color: active ? Colors.white : Colors.black, fontSize: 12),
)
],
),
),
);
}
}
I need help to know how to remove those gaps of spaces between each row :(