import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:random_color/random_color.dart';
import '../global/custom.dart';
import '../provider/prv_category.dart';
class WidgetCategories extends StatefulWidget {
@override
_WidgetCategoriesState createState() => _WidgetCategoriesState();
}
class _WidgetCategoriesState extends State<WidgetCategories> {
@override
Widget build(BuildContext context) {
RandomColor _randomColor = RandomColor();
// final categoryCount =
// Provider.of<ProviderProducts>(context).getCategoryCount() > 0;
final isNotNull = Provider.of<ProviderProducts>(context, listen: false)
.categories
.categoryDocumentData !=
null;
final category = Provider.of<ProviderProducts>(context);
final _categories = category.categories.categoryDocumentData;
return !isNotNull
? Center(
child: CircularProgressIndicator(),
)
: Container(
height: 115,
//width: 90,
child: ListView.builder(
physics: BouncingScrollPhysics(),
itemCount: _categories.length,
scrollDirection: Axis.horizontal,
//padding: EdgeInsets.all(1 0.0),
itemBuilder: (context, i) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Card(
color: _randomColor.randomColor(
//colorSaturation: ColorSaturation.highSaturation,
colorBrightness: ColorBrightness.dark,
),
semanticContainer: true,
clipBehavior: Clip.antiAliasWithSaveLayer,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
top: 13,
left: 15,
right: 15,
),
child: Image.network(
_categories[i]['imgPath'],
height: 60,
width: 60,
fit: BoxFit.fill,
),
),
Padding(
padding: const EdgeInsets.only(
bottom: 10.0,
),
child: CustTextBody(
cText: _categories[i]['category_name'],
cTxtStyle: Theme.of(context).textTheme.headline5,
cTxtAlign: TextAlign.center,
),
),
],
),
),
],
);
},
));
}
}