Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:convert';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:makola_market/Models/product.dart';
- import 'package:makola_market/Pages/Content%20Cards/contentCard.dart';
- import 'package:makola_market/api.dart';
- import '../../constants.dart';
- import '../productPage.dart';
- class FeaturedCard extends StatefulWidget {
- @override
- State<StatefulWidget> createState() => _FeaturedCardState();
- }
- class _FeaturedCardState extends State<FeaturedCard> {
- @override
- Widget build(BuildContext context) {
- //Future<List<Product>> products = productsRandom(count: 3);
- return FutureBuilder(
- future: productsRandom(count: 3),
- builder: (context, snapshot) {
- if (snapshot.hasData) {
- var images = <Widget>{};
- for (var product in snapshot.data) {
- images.add(GestureDetector(
- onTap: () => Navigator.pushNamed(context, ProductPage.routeName,
- arguments: product),
- child: Image(
- image: MemoryImage(
- base64Decode((product as Product).imageStr),
- scale: 2.5))));
- }
- return ContentCard(
- Align(
- child: Text(
- 'Featured Products',
- style: contentCardTitle,
- ),
- alignment: Alignment.centerLeft),
- Row(
- children: images.toList(),
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- Container(
- key: Key('FeaturedCardFooter'),
- ),
- );
- } else if (snapshot.hasError) {
- return Text(
- snapshot.error.toString(),
- style: optionStyle,
- );
- } else {
- return ContentCard(
- Text(
- 'Featured Products',
- style: contentCardText,
- ),
- CircularProgressIndicator(),
- Container(
- key: Key('FeaturedCardFooter'),
- ),
- );
- }
- },
- );
- }
- }
Add Comment
Please, Sign In to add comment