You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aku_new_community/lib/widget/grid_buttons.dart

64 lines
1.8 KiB

// Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:flutter_screenutil/flutter_screenutil.dart';
class GridButtons extends StatefulWidget {
final List<GridButton> gridList;
final int crossCount;
GridButtons({Key key, this.crossCount, this.gridList}) : super(key: key);
@override
_GridButtonsState createState() => _GridButtonsState();
}
class GridButton {
String title;
String path;
VoidCallback onTap;
GridButton(this.title, this.path, this.onTap);
}
class _GridButtonsState extends State<GridButtons> {
@override
Widget build(BuildContext context) {
return GridView.builder(
padding: EdgeInsets.zero,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: widget.gridList.length,
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: widget.gridList[index].onTap,
child: Container(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Image.asset(
widget.gridList[index].path,
height: 53.w,
width: 53.w,
fit: BoxFit.cover,
),
SizedBox(height: 5),
Text(
widget.gridList[index].title,
style: TextStyle(fontSize: 24.sp),
)
],
),
),
);
},
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: widget.crossCount,
mainAxisSpacing: 6.0,
childAspectRatio: 1.0),
);
}
}