Search

Flutter E-commerce App With Backend #1 to #4.

class Product {
  final String id;
  final String title;
  final String description;
  final double price;
  final String imageUrl;
  bool isFavorite;

  Product({
    required this.id,
    required this.title,
    required this.description,
    required this.price,
    required this.imageUrl,
    required this.isFavorite,
});
}
import 'package:flutter/material.dart';
class ProductDetailScreen extends StatelessWidget {
/*final String title;
final double price;

ProductDetailScreen(this.title,
    this.price);*/
static const routeName = '/product-detail';

  @override
  Widget build(BuildContext context) {
   final productId =  ModalRoute.of(context)?.settings.arguments as String;
    return Scaffold(
      appBar: AppBar(title: Text('title')
        ,),
    );
  }
}

import 'package:flutter/material.dart';
import '../models/product.dart';
import '../widgets/product_item.dart';
class ProductOverviewScreen extends StatelessWidget {

final List<Product> loadedProducts = [
  Product(
    id: 'p1',
    title: 'Red Shirt',
    description: 'A red shirt - it is pretty red!',
    price: 29.99,
    imageUrl:
    'https://cdn.pixabay.com/photo/2016/10/02/22/17/red-t-shirt-1710578_1280.jpg',
    isFavorite: true,


  ),
  Product(
    id: 'p2',
    title: 'Trousers',
    description: 'A nice pair of trousers.',
    price: 59.99,
    imageUrl:
    'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Trousers%2C_dress_%28AM_1960.022-8%29.jpg/512px-Trousers%2C_dress_%28AM_1960.022-8%29.jpg',
    isFavorite: true,
  ),
  Product(
    id: 'p3',
    title: 'Yellow Scarf',
    description: 'Warm and cozy - exactly what you need for the winter.',
    price: 19.99,
    imageUrl:
    'https://live.staticflickr.com/4043/4438260868_cc79b3369d_z.jpg',
    isFavorite: true,
  ),
  Product(
    id: 'p4',
    title: 'A Pan',
    description: 'Prepare any meal you want.',
    price: 49.99,
    imageUrl:
    'https://upload.wikimedia.org/wikipedia/commons/thumb/1/14/Cast-Iron-Pan.jpg/1024px-Cast-Iron-Pan.jpg',
    isFavorite: true,
  ),
];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text ('MyShop'),
      ),
body: GridView.builder(
  padding: const EdgeInsets.all(10.0),
  itemCount: loadedProducts.length,
  itemBuilder: (ctx, i) => ProductItem(
    loadedProducts[i].id,
  loadedProducts[i].title,
  loadedProducts[i].imageUrl,
  ),
  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2,
      childAspectRatio: 3/2,
  crossAxisSpacing: 10,
  mainAxisSpacing: 10,),

),
    );
  }
}

import 'package:flutter/material.dart';
import '../screens/product_details.dart';
class ProductItem extends StatelessWidget {
  final String id;
  final String title;
  final String imageUrl;
  ProductItem(this.id,
      this.title,
      this.imageUrl);

  @override
  Widget build(BuildContext context) {
    return ClipRRect(
      borderRadius: BorderRadius.circular(10),
    child:
      GridTile(
        child:
            GestureDetector(
              onTap: () {
                Navigator.of(context).pushNamed(ProductDetailScreen.routeName,
                  arguments: id,
                );
              },
        child:
    Image.network(imageUrl,
      fit: BoxFit.cover,),)
        ,
    footer: GridTileBar(
      backgroundColor: Colors.black87,
      leading: IconButton(icon: Icon(Icons.favorite),
      onPressed: () {},
        color: Theme.of(context).accentColor,
      ),
      title:
    Text(title,textAlign: TextAlign.center,),
      trailing: IconButton(icon:
        Icon(Icons.shopping_cart,),
      onPressed: () {},
      color: Theme.of(context).accentColor,),
    ),)
    );
  }
}













0 comments

Recent Posts

See All

namefood ingredients app flutter projectFood Donation App College ProjectCollege Android and Website ProjectCollege Leave Management SystemServey for Indian fingerprint unlocking system for

Order any project or you have any idea. Contact - 9306637630. Online Course and Examination Management System Advanced Car & Scooty Training Driving School Management System Advanced Employee Manageme