This is a mobile application project developed in Flutter, simulating a basic online store. The app allows you to view products, add them to your cart, mark them as favorites, complete orders, and view your purchase history. It uses dummy data for demonstration purposes and focuses on efficient state management. ## Main Features
-
Product Listing: Product grid with filter for favorites.
-
Product Details: Dedicated page with image, price, and description.
-
Favorites: Mark/unmark products as favorites.
-
Shopping Cart: Add/remove items, calculate total, and clear cart.
-
Orders: Checkout and view expandable history.
-
Navigation: Drawer to switch between store and orders.
-
Example Counter: A simple page to demonstrate basic status (optional).
During the development of this app, I learned several key Flutter concepts, with an emphasis on state management using the provider package:
-
State Management with Provider:
-
I used
ChangeNotifierProviderandMultiProviderinmain.dartto provide global states such asProductList,Cart, andOrderList. -
I created models such as
Product,Cart, andOrderListthat extendChangeNotifier, notifying listeners withnotifyListeners()when data changes (e.g., adding to cart or toggling a favorite). -
I used
Provider.of<T>(context)to access and modify states without unnecessary rebuilds, andConsumer<T>for localized rebuilds (e.g., badge in cart and favorite icon). -
I understood the difference between
listen: true/falseto optimize performance, avoiding rebuilds in widgets that don't need to react to changes. -
I implemented filtering of favorite products via
ProductList, showing how shared states facilitate features like dynamic filters. -
Other Points Learned:
-
Navigation and Routes: Configuration of named routes in
app_routes.dartand use ofNavigator.pushNamedfor smooth transitions. -
Responsive UI: Widgets like
GridView.builderfor product grids,Dismissiblefor removing items from the cart, and implicitExpansionPanelin expandable orders. -
Models and Data: Creation of classes like
Product,CartItem, andOrderfor data structure, with dummy data for rapid prototyping. -
Theme and Style: Application of
ThemeDatafor color and font consistency. -
Local vs. Global State: Comparison with local state on pages like the counter, highlighting when to use
setStatevs. Provider.
This project reinforced the importance of separating UI logic, making the code more scalable and testable.
``bash
git clone https://github.com/your-username/loja-virtual-flutter.git



