2022-04-22 22:08:59 +02:00
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class ProductBox extends StatefulWidget {
|
2022-04-23 17:55:27 +02:00
|
|
|
const ProductBox({Key? key, required this.imageUrl, required this.title})
|
|
|
|
: super(key: key);
|
2022-04-22 22:08:59 +02:00
|
|
|
|
|
|
|
final String imageUrl;
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<ProductBox> createState() => _ProductBoxState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ProductBoxState extends State<ProductBox> {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-04-23 20:37:25 +02:00
|
|
|
return Container(
|
|
|
|
margin: const EdgeInsets.all(8.0),
|
|
|
|
child: Card(
|
|
|
|
color: const Color(0xff212226),
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
),
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {},
|
2022-04-23 20:53:12 +02:00
|
|
|
borderRadius: BorderRadius.circular(10),
|
2022-04-23 20:37:25 +02:00
|
|
|
splashColor: const Color(0xff8B0000),
|
|
|
|
highlightColor: const Color(0xff8B0000),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Flexible(
|
|
|
|
flex: 4,
|
|
|
|
child: CachedNetworkImage(
|
|
|
|
imageUrl: widget.imageUrl,
|
2022-04-23 20:53:12 +02:00
|
|
|
placeholder: (context, url) =>
|
|
|
|
const CircularProgressIndicator(
|
2022-04-23 20:37:25 +02:00
|
|
|
color: Color(0xff8B0000),
|
|
|
|
),
|
|
|
|
errorWidget: (context, url, error) =>
|
|
|
|
Image.asset('assets/image-error.webp'),
|
|
|
|
fadeOutDuration: const Duration(milliseconds: 5),
|
|
|
|
imageBuilder: (context, imageProvider) => Container(
|
|
|
|
width: 300,
|
|
|
|
height: 150,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
image: DecorationImage(
|
|
|
|
image: imageProvider, fit: BoxFit.cover)),
|
|
|
|
),
|
|
|
|
),
|
2022-04-22 22:08:59 +02:00
|
|
|
),
|
2022-04-23 20:37:25 +02:00
|
|
|
Flexible(
|
|
|
|
flex: 1,
|
|
|
|
child: Container(
|
|
|
|
margin: const EdgeInsets.all(10),
|
|
|
|
child: Text(
|
|
|
|
widget.title,
|
2022-04-23 20:53:12 +02:00
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color: Colors.white,
|
|
|
|
fontWeight: FontWeight.w600),
|
2022-04-23 20:37:25 +02:00
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2022-04-23 17:55:27 +02:00
|
|
|
),
|
|
|
|
),
|
2022-04-22 22:08:59 +02:00
|
|
|
);
|
|
|
|
}
|
2022-04-23 20:53:12 +02:00
|
|
|
}
|