77 lines
2.5 KiB
Dart
77 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:food_ui/util/categories.dart';
|
|
|
|
class Categories extends StatelessWidget {
|
|
const Categories({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
elevation: 0.0,
|
|
title: const Text('Categories'),
|
|
centerTitle: true,
|
|
),
|
|
body: GridView.count(
|
|
crossAxisCount: 2,
|
|
children: List.generate(
|
|
categories.length,
|
|
(index) {
|
|
final cat = categories[index];
|
|
return Container(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
child: Stack(
|
|
children: [
|
|
Image.asset(
|
|
cat["img"],
|
|
fit: BoxFit.cover,
|
|
height: double.infinity,
|
|
width: double.infinity,
|
|
),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
// Add one stop for each color. Stops should increase from 0 to 1
|
|
stops: [0.2, 0.7],
|
|
colors: [
|
|
cat['color1'],
|
|
cat['color2'],
|
|
],
|
|
),
|
|
),
|
|
height: double.infinity,
|
|
width: double.infinity,
|
|
),
|
|
Center(
|
|
child: SizedBox(
|
|
height: MediaQuery.of(context).size.height,
|
|
width: MediaQuery.of(context).size.height,
|
|
// padding: const EdgeInsets.all(1),
|
|
child: Center(
|
|
child: Text(
|
|
cat["name"],
|
|
style: const TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|