mirror of
https://github.com/Iconica-Development/flutter_shopping.git
synced 2025-05-19 08:53:46 +02:00
fix: dependency
This commit is contained in:
parent
d37689e855
commit
abfbdfd152
15 changed files with 74 additions and 334 deletions
|
@ -1,173 +0,0 @@
|
||||||
import "package:flutter/material.dart";
|
|
||||||
import "package:flutter_order_details/src/configuration/order_detail_title_style.dart";
|
|
||||||
|
|
||||||
/// Abstract class for order detail input.
|
|
||||||
/// Each input field must extend from this class.
|
|
||||||
abstract class OrderDetailInput<T> {
|
|
||||||
/// Constructor for the order detail input.
|
|
||||||
OrderDetailInput({
|
|
||||||
required this.title,
|
|
||||||
required this.outputKey,
|
|
||||||
this.titleStyle = OrderDetailTitleStyle.text,
|
|
||||||
this.titleAlignment = Alignment.centerLeft,
|
|
||||||
this.titlePadding = const EdgeInsets.symmetric(vertical: 4),
|
|
||||||
this.subtitle,
|
|
||||||
this.isRequired = true,
|
|
||||||
this.isReadOnly = false,
|
|
||||||
this.initialValue,
|
|
||||||
this.validators = const [],
|
|
||||||
this.onValueChanged,
|
|
||||||
this.hint,
|
|
||||||
this.errorIsRequired = "This field is required",
|
|
||||||
this.paddingBetweenFields = const EdgeInsets.symmetric(vertical: 4),
|
|
||||||
});
|
|
||||||
|
|
||||||
/// Title of the input field.
|
|
||||||
final String title;
|
|
||||||
|
|
||||||
/// Subtitle of the input field.
|
|
||||||
final String? subtitle;
|
|
||||||
|
|
||||||
/// The styling for the title.
|
|
||||||
final OrderDetailTitleStyle titleStyle;
|
|
||||||
|
|
||||||
/// The alignment of the titl
|
|
||||||
final Alignment titleAlignment;
|
|
||||||
|
|
||||||
/// Padding around the title.
|
|
||||||
final EdgeInsets titlePadding;
|
|
||||||
|
|
||||||
/// The output key of the input field.
|
|
||||||
final String outputKey;
|
|
||||||
|
|
||||||
/// Hint message of the input field.
|
|
||||||
final String? hint;
|
|
||||||
|
|
||||||
/// Determines if the input field is required.
|
|
||||||
final bool isRequired;
|
|
||||||
|
|
||||||
/// Error message for when an user does not insert something in the field
|
|
||||||
/// even though it is required.
|
|
||||||
final String errorIsRequired;
|
|
||||||
|
|
||||||
/// A read-only field that users cannot change.
|
|
||||||
final bool isReadOnly;
|
|
||||||
|
|
||||||
/// An initial value for the input field. This is ideal incombination
|
|
||||||
/// with the [isReadOnly] field.
|
|
||||||
final T? initialValue;
|
|
||||||
|
|
||||||
/// Internal current value. Do not use.
|
|
||||||
T? currentValue;
|
|
||||||
|
|
||||||
/// List of validators that should be executed when the input field
|
|
||||||
/// is validated.
|
|
||||||
List<String? Function(T?)> validators;
|
|
||||||
|
|
||||||
/// Function that is called when the value of the input field changes.
|
|
||||||
final Function(T)? onValueChanged;
|
|
||||||
|
|
||||||
/// Padding between the fields.
|
|
||||||
final EdgeInsets paddingBetweenFields;
|
|
||||||
|
|
||||||
/// Allows you to update the current value.
|
|
||||||
@protected
|
|
||||||
set updateValue(T value) {
|
|
||||||
currentValue = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Function that validates the input field. Automatically keeps track
|
|
||||||
/// of the [isRequired] keys and all the custom validators.
|
|
||||||
@protected
|
|
||||||
String? validate(T? value) {
|
|
||||||
if (isRequired && (value == null || value.toString().isEmpty)) {
|
|
||||||
return errorIsRequired;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var validator in validators) {
|
|
||||||
var error = validator(value);
|
|
||||||
if (error != null) {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Builds the basic outline of an input field.
|
|
||||||
@protected
|
|
||||||
Widget buildOutline(
|
|
||||||
BuildContext context,
|
|
||||||
// ignore: avoid_annotating_with_dynamic
|
|
||||||
dynamic child,
|
|
||||||
Function({bool needsBlur}) onBlurBackground,
|
|
||||||
) {
|
|
||||||
var theme = Theme.of(context);
|
|
||||||
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
if (titleStyle == OrderDetailTitleStyle.text) ...[
|
|
||||||
Align(
|
|
||||||
alignment: titleAlignment,
|
|
||||||
child: Padding(
|
|
||||||
padding: titlePadding,
|
|
||||||
child: Text(
|
|
||||||
title,
|
|
||||||
style: theme.textTheme.titleMedium,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (subtitle != null) ...[
|
|
||||||
Padding(
|
|
||||||
padding: titlePadding,
|
|
||||||
child: Align(
|
|
||||||
alignment: titleAlignment,
|
|
||||||
child: Text(
|
|
||||||
subtitle!,
|
|
||||||
style: theme.textTheme.titleSmall,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
if (child is FormField || child is Widget) ...[
|
|
||||||
child,
|
|
||||||
] else if (child is List<FormField>) ...[
|
|
||||||
Column(
|
|
||||||
children: child
|
|
||||||
.map(
|
|
||||||
(FormField field) => Padding(
|
|
||||||
padding: paddingBetweenFields,
|
|
||||||
child: field,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
),
|
|
||||||
] else if (child is List<OrderDetailInput>) ...[
|
|
||||||
Column(
|
|
||||||
children: child
|
|
||||||
.map(
|
|
||||||
(OrderDetailInput input) => Padding(
|
|
||||||
padding: paddingBetweenFields,
|
|
||||||
child: input.build(
|
|
||||||
context,
|
|
||||||
input.initialValue,
|
|
||||||
onBlurBackground,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Abstract build function that each orderinput class must implement
|
|
||||||
/// themsleves. For a basic layout, they can use the [buildOutline] function.
|
|
||||||
Widget build(
|
|
||||||
BuildContext context,
|
|
||||||
T? buildInitialValue,
|
|
||||||
Function({bool needsBlur}) onBlurBackground,
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,6 +1,7 @@
|
||||||
name: flutter_order_details
|
name: flutter_order_details
|
||||||
description: "A Flutter module for order details."
|
description: "A Flutter module for order details."
|
||||||
version: 1.0.0
|
version: 2.0.0
|
||||||
|
publish_to: 'none'
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.3.0 <4.0.0'
|
sdk: '>=3.3.0 <4.0.0'
|
||||||
|
@ -8,6 +9,14 @@ environment:
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
animated_toggle:
|
||||||
|
git:
|
||||||
|
url: https://github.com/Iconica-Development/flutter_animated_toggle
|
||||||
|
ref: 0.0.3
|
||||||
|
flutter_form_wizard:
|
||||||
|
git:
|
||||||
|
url: https://github.com/Iconica-Development/flutter_form_wizard
|
||||||
|
ref: 6.5.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
@ -18,13 +27,4 @@ dev_dependencies:
|
||||||
ref: 7.0.0
|
ref: 7.0.0
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
# assets:
|
|
||||||
# - images/a_dot_burr.jpeg
|
|
||||||
# - images/a_dot_ham.jpeg
|
|
||||||
|
|
||||||
# fonts:
|
|
||||||
# - family: Schyler
|
|
||||||
# fonts:
|
|
||||||
# - asset: fonts/Schyler-Regular.ttf
|
|
||||||
# - asset: fonts/Schyler-Italic.ttf
|
|
||||||
# style: italic
|
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
/// The product page shop class contains all the required information
|
|
||||||
class Product {
|
|
||||||
/// Constructor for the product.
|
|
||||||
Product({
|
|
||||||
required this.id,
|
|
||||||
required this.name,
|
|
||||||
required this.imageUrl,
|
|
||||||
required this.category,
|
|
||||||
required this.price,
|
|
||||||
required this.hasDiscount,
|
|
||||||
this.discountPrice,
|
|
||||||
this.quantity = 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
/// The unique identifier for the product.
|
|
||||||
final String id;
|
|
||||||
|
|
||||||
/// The name of the product.
|
|
||||||
final String name;
|
|
||||||
|
|
||||||
/// The image URL of the product.
|
|
||||||
final String imageUrl;
|
|
||||||
|
|
||||||
/// The category of the product.
|
|
||||||
final String category;
|
|
||||||
|
|
||||||
/// The price of the product.
|
|
||||||
final double price;
|
|
||||||
|
|
||||||
/// Whether the product has a discount or not.
|
|
||||||
final bool hasDiscount;
|
|
||||||
|
|
||||||
/// The discounted price of the product. Only used if [hasDiscount] is true.
|
|
||||||
final double? discountPrice;
|
|
||||||
|
|
||||||
/// Quantity for the product.
|
|
||||||
final int quantity;
|
|
||||||
}
|
|
|
@ -1,7 +1,7 @@
|
||||||
name: flutter_product_page
|
name: flutter_product_page
|
||||||
description: "A Flutter module for the product page"
|
description: "A Flutter module for the product page"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
version: 1.0.0
|
version: 2.0.0
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.3.4 <4.0.0'
|
sdk: '>=3.3.4 <4.0.0'
|
||||||
|
@ -15,6 +15,11 @@ dependencies:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/Iconica-Development/flutter_nested_categories
|
url: https://github.com/Iconica-Development/flutter_nested_categories
|
||||||
ref: 0.0.1
|
ref: 0.0.1
|
||||||
|
flutter_shopping:
|
||||||
|
git:
|
||||||
|
url: https://github.com/Iconica-Development/flutter_shopping
|
||||||
|
path: packages/flutter_shopping
|
||||||
|
ref: 2.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
@ -26,13 +31,3 @@ dev_dependencies:
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
||||||
# assets:
|
|
||||||
# - images/a_dot_burr.jpeg
|
|
||||||
# - images/a_dot_ham.jpeg
|
|
||||||
# fonts:
|
|
||||||
# - family: Schyler
|
|
||||||
# fonts:
|
|
||||||
# - asset: fonts/Schyler-Regular.ttf
|
|
||||||
# - asset: fonts/Schyler-Italic.ttf
|
|
||||||
# style: italic
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import "package:example/src/models/my_product.dart";
|
|
||||||
import "package:example/src/routes.dart";
|
import "package:example/src/routes.dart";
|
||||||
import "package:example/src/services/order_service.dart";
|
import "package:example/src/services/order_service.dart";
|
||||||
import "package:example/src/services/shop_service.dart";
|
import "package:example/src/services/shop_service.dart";
|
||||||
|
@ -7,7 +6,7 @@ import "package:flutter_shopping/flutter_shopping.dart";
|
||||||
import "package:go_router/go_router.dart";
|
import "package:go_router/go_router.dart";
|
||||||
|
|
||||||
// (REQUIRED): Create your own instance of the ProductService.
|
// (REQUIRED): Create your own instance of the ProductService.
|
||||||
final ProductService<MyProduct> productService = ProductService([]);
|
final ProductService<Product> productService = ProductService([]);
|
||||||
|
|
||||||
FlutterShoppingConfiguration getFlutterShoppingConfiguration() =>
|
FlutterShoppingConfiguration getFlutterShoppingConfiguration() =>
|
||||||
FlutterShoppingConfiguration(
|
FlutterShoppingConfiguration(
|
||||||
|
@ -24,8 +23,7 @@ FlutterShoppingConfiguration getFlutterShoppingConfiguration() =>
|
||||||
shops: Future.value(getShops()),
|
shops: Future.value(getShops()),
|
||||||
|
|
||||||
// (REQUIRED): Function to add a product to the cart
|
// (REQUIRED): Function to add a product to the cart
|
||||||
onAddToCart: (ProductPageProduct product) =>
|
onAddToCart: productService.addProduct,
|
||||||
productService.addProduct(product as MyProduct),
|
|
||||||
|
|
||||||
// (REQUIRED): Function to get the products for a shop
|
// (REQUIRED): Function to get the products for a shop
|
||||||
getProducts: (ProductPageShop shop) =>
|
getProducts: (ProductPageShop shop) =>
|
||||||
|
@ -43,7 +41,7 @@ FlutterShoppingConfiguration getFlutterShoppingConfiguration() =>
|
||||||
|
|
||||||
// (RECOMMENDED) Function that returns the description for a
|
// (RECOMMENDED) Function that returns the description for a
|
||||||
// product that is on sale.
|
// product that is on sale.
|
||||||
getDiscountDescription: (ProductPageProduct product) =>
|
getDiscountDescription: (product) =>
|
||||||
"""${product.name} for just \$${product.discountPrice?.toStringAsFixed(2)}""",
|
"""${product.name} for just \$${product.discountPrice?.toStringAsFixed(2)}""",
|
||||||
|
|
||||||
// (RECOMMENDED) Function that is fired when the shop selection
|
// (RECOMMENDED) Function that is fired when the shop selection
|
||||||
|
@ -60,7 +58,7 @@ FlutterShoppingConfiguration getFlutterShoppingConfiguration() =>
|
||||||
localizations: const ProductPageLocalization(),
|
localizations: const ProductPageLocalization(),
|
||||||
|
|
||||||
// (OPTIONAL) Appbar
|
// (OPTIONAL) Appbar
|
||||||
appBar: AppBar(
|
appBar: (context) => AppBar(
|
||||||
title: const Text("Shop"),
|
title: const Text("Shop"),
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
|
@ -85,7 +83,8 @@ FlutterShoppingConfiguration getFlutterShoppingConfiguration() =>
|
||||||
productService: productService,
|
productService: productService,
|
||||||
|
|
||||||
// (REQUIRED) product item builder:
|
// (REQUIRED) product item builder:
|
||||||
productItemBuilder: (context, locale, product) => ListTile(
|
productItemBuilder: (context, locale, product, service, config) =>
|
||||||
|
ListTile(
|
||||||
title: Text(product.name),
|
title: Text(product.name),
|
||||||
subtitle: Text(product.price.toStringAsFixed(2)),
|
subtitle: Text(product.price.toStringAsFixed(2)),
|
||||||
leading: Image.network(
|
leading: Image.network(
|
||||||
|
@ -121,9 +120,6 @@ FlutterShoppingConfiguration getFlutterShoppingConfiguration() =>
|
||||||
// (RECOMMENDED) localizations:
|
// (RECOMMENDED) localizations:
|
||||||
localizations: const ShoppingCartLocalizations(),
|
localizations: const ShoppingCartLocalizations(),
|
||||||
|
|
||||||
// (OPTIONAL) title above product list:
|
|
||||||
title: "Products",
|
|
||||||
|
|
||||||
/// (OPTIONAL) no content builder for when there are no products
|
/// (OPTIONAL) no content builder for when there are no products
|
||||||
/// in the shopping cart.
|
/// in the shopping cart.
|
||||||
noContentBuilder: (context) => const Center(
|
noContentBuilder: (context) => const Center(
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
import "package:flutter_shopping/flutter_shopping.dart";
|
|
||||||
|
|
||||||
class MyProduct extends ShoppingCartProduct with ProductPageProduct {
|
|
||||||
MyProduct({
|
|
||||||
required super.id,
|
|
||||||
required super.name,
|
|
||||||
required super.price,
|
|
||||||
required this.category,
|
|
||||||
required this.imageUrl,
|
|
||||||
this.discountPrice,
|
|
||||||
this.hasDiscount = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final String category;
|
|
||||||
|
|
||||||
@override
|
|
||||||
final String imageUrl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
final double? discountPrice;
|
|
||||||
|
|
||||||
@override
|
|
||||||
final bool hasDiscount;
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
import "package:example/src/models/my_product.dart";
|
|
||||||
import "package:flutter_shopping/flutter_shopping.dart";
|
import "package:flutter_shopping/flutter_shopping.dart";
|
||||||
|
|
||||||
/// Example implementation of storing an order in a database.
|
/// Example implementation of storing an order in a database.
|
||||||
void storeOrderInDatabase(List<MyProduct> products, OrderResult result) {
|
void storeOrderInDatabase(List<Product> products, OrderResult result) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import "package:example/src/models/my_product.dart";
|
|
||||||
import "package:example/src/models/my_shop.dart";
|
import "package:example/src/models/my_shop.dart";
|
||||||
import "package:flutter_shopping/flutter_shopping.dart";
|
import "package:flutter_shopping/flutter_shopping.dart";
|
||||||
|
|
||||||
|
@ -20,8 +19,8 @@ ProductPageContent getShopContent(String shopId) {
|
||||||
|
|
||||||
/// This function should have your own implementation. Generally this would
|
/// This function should have your own implementation. Generally this would
|
||||||
/// contain some API call to fetch the list of products for a shop.
|
/// contain some API call to fetch the list of products for a shop.
|
||||||
List<MyProduct> getProducts(String shopId) => <MyProduct>[
|
List<Product> getProducts(String shopId) => <Product>[
|
||||||
MyProduct(
|
Product(
|
||||||
id: "1",
|
id: "1",
|
||||||
name: "White bread",
|
name: "White bread",
|
||||||
price: 2.99,
|
price: 2.99,
|
||||||
|
@ -29,19 +28,22 @@ List<MyProduct> getProducts(String shopId) => <MyProduct>[
|
||||||
imageUrl: "https://via.placeholder.com/150",
|
imageUrl: "https://via.placeholder.com/150",
|
||||||
hasDiscount: true,
|
hasDiscount: true,
|
||||||
discountPrice: 1.99,
|
discountPrice: 1.99,
|
||||||
|
description: "",
|
||||||
),
|
),
|
||||||
MyProduct(
|
Product(
|
||||||
id: "2",
|
id: "2",
|
||||||
name: "Brown bread",
|
name: "Brown bread",
|
||||||
price: 2.99,
|
price: 2.99,
|
||||||
category: "Loaves",
|
category: "Loaves",
|
||||||
imageUrl: "https://via.placeholder.com/150",
|
imageUrl: "https://via.placeholder.com/150",
|
||||||
|
description: "",
|
||||||
),
|
),
|
||||||
MyProduct(
|
Product(
|
||||||
id: "3",
|
id: "3",
|
||||||
name: "Cheese sandwich",
|
name: "Cheese sandwich",
|
||||||
price: 1.99,
|
price: 1.99,
|
||||||
category: "Sandwiches",
|
category: "Sandwiches",
|
||||||
imageUrl: "https://via.placeholder.com/150",
|
imageUrl: "https://via.placeholder.com/150",
|
||||||
|
description: "",
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
|
@ -12,12 +12,11 @@ dependencies:
|
||||||
flutter_hooks: ^0.20.0
|
flutter_hooks: ^0.20.0
|
||||||
hooks_riverpod: ^2.1.1
|
hooks_riverpod: ^2.1.1
|
||||||
go_router: 12.1.3
|
go_router: 12.1.3
|
||||||
|
|
||||||
# Iconica packages
|
|
||||||
|
|
||||||
## Userstories
|
|
||||||
flutter_shopping:
|
flutter_shopping:
|
||||||
path: ../
|
git:
|
||||||
|
url: https://github.com/Iconica-Development/flutter_shopping
|
||||||
|
path: packages/flutter_shopping
|
||||||
|
ref: 2.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import "package:amazon/src/models/my_product.dart";
|
|
||||||
import "package:amazon/src/routes.dart";
|
import "package:amazon/src/routes.dart";
|
||||||
import "package:amazon/src/services/category_service.dart";
|
import "package:amazon/src/services/category_service.dart";
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
|
@ -6,7 +5,7 @@ import "package:flutter_shopping/flutter_shopping.dart";
|
||||||
import "package:go_router/go_router.dart";
|
import "package:go_router/go_router.dart";
|
||||||
|
|
||||||
// (REQUIRED): Create your own instance of the ProductService.
|
// (REQUIRED): Create your own instance of the ProductService.
|
||||||
final ProductService<MyProduct> productService = ProductService([]);
|
final ProductService<Product> productService = ProductService([]);
|
||||||
|
|
||||||
FlutterShoppingConfiguration getFlutterShoppingConfiguration() =>
|
FlutterShoppingConfiguration getFlutterShoppingConfiguration() =>
|
||||||
FlutterShoppingConfiguration(
|
FlutterShoppingConfiguration(
|
||||||
|
@ -27,8 +26,9 @@ FlutterShoppingConfiguration getFlutterShoppingConfiguration() =>
|
||||||
pagePadding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
|
pagePadding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
|
||||||
|
|
||||||
// (REQUIRED): Function to add a product to the cart
|
// (REQUIRED): Function to add a product to the cart
|
||||||
onAddToCart: (ProductPageProduct product) =>
|
onAddToCart: (product) {
|
||||||
productService.addProduct(product as MyProduct),
|
return productService.addProduct(product);
|
||||||
|
},
|
||||||
|
|
||||||
// (REQUIRED): Function to get the products for a shop
|
// (REQUIRED): Function to get the products for a shop
|
||||||
getProducts: (ProductPageShop shop) =>
|
getProducts: (ProductPageShop shop) =>
|
||||||
|
@ -41,7 +41,9 @@ FlutterShoppingConfiguration getFlutterShoppingConfiguration() =>
|
||||||
|
|
||||||
shopSelectorStyle: ShopSelectorStyle.row,
|
shopSelectorStyle: ShopSelectorStyle.row,
|
||||||
|
|
||||||
navigateToShoppingCartBuilder: (context) => const SizedBox.shrink(),
|
navigateToShoppingCartBuilder: (context, productpageinfo, shop) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
},
|
||||||
|
|
||||||
bottomNavigationBar: BottomNavigationBar(
|
bottomNavigationBar: BottomNavigationBar(
|
||||||
fixedColor: theme.primaryColor,
|
fixedColor: theme.primaryColor,
|
||||||
|
@ -164,7 +166,7 @@ FlutterShoppingConfiguration getFlutterShoppingConfiguration() =>
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
FilledButton(
|
FilledButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
productService.addProduct(product as MyProduct);
|
productService.addProduct(product);
|
||||||
},
|
},
|
||||||
child: const Text("In winkelwagen"),
|
child: const Text("In winkelwagen"),
|
||||||
),
|
),
|
||||||
|
@ -206,7 +208,7 @@ FlutterShoppingConfiguration getFlutterShoppingConfiguration() =>
|
||||||
),
|
),
|
||||||
|
|
||||||
// (OPTIONAL) Appbar
|
// (OPTIONAL) Appbar
|
||||||
appBar: AppBar(
|
appBar: (context) => AppBar(
|
||||||
title: const SizedBox(
|
title: const SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
child: SearchBar(
|
child: SearchBar(
|
||||||
|
@ -262,7 +264,8 @@ FlutterShoppingConfiguration getFlutterShoppingConfiguration() =>
|
||||||
productService: productService,
|
productService: productService,
|
||||||
|
|
||||||
// (REQUIRED) product item builder:
|
// (REQUIRED) product item builder:
|
||||||
productItemBuilder: (context, locale, product) => ListTile(
|
productItemBuilder: (context, locale, product, service, config) =>
|
||||||
|
ListTile(
|
||||||
title: Text(product.name),
|
title: Text(product.name),
|
||||||
subtitle: Text(product.price.toStringAsFixed(2)),
|
subtitle: Text(product.price.toStringAsFixed(2)),
|
||||||
leading: Image.network(
|
leading: Image.network(
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
import 'package:flutter_shopping/flutter_shopping.dart';
|
|
||||||
|
|
||||||
class MyProduct extends ShoppingCartProduct with ProductPageProduct {
|
|
||||||
MyProduct({
|
|
||||||
required super.id,
|
|
||||||
required super.name,
|
|
||||||
required super.price,
|
|
||||||
required this.category,
|
|
||||||
required this.imageUrl,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final String category;
|
|
||||||
|
|
||||||
@override
|
|
||||||
final String imageUrl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
final double? discountPrice = 0.0;
|
|
||||||
|
|
||||||
@override
|
|
||||||
final bool hasDiscount = false;
|
|
||||||
}
|
|
|
@ -1,5 +1,4 @@
|
||||||
import "package:amazon/src/models/my_category.dart";
|
import "package:amazon/src/models/my_category.dart";
|
||||||
import "package:amazon/src/models/my_product.dart";
|
|
||||||
import "package:flutter_shopping/flutter_shopping.dart";
|
import "package:flutter_shopping/flutter_shopping.dart";
|
||||||
|
|
||||||
Map<String, String> categories = {
|
Map<String, String> categories = {
|
||||||
|
@ -8,8 +7,8 @@ Map<String, String> categories = {
|
||||||
"TV's": "TV's",
|
"TV's": "TV's",
|
||||||
};
|
};
|
||||||
|
|
||||||
List<MyProduct> allProducts() => [
|
List<Product> allProducts() => [
|
||||||
MyProduct(
|
Product(
|
||||||
id: "1",
|
id: "1",
|
||||||
name:
|
name:
|
||||||
"Skar Audio Single 8\" Complete 1,200 Watt EVL Series Subwoofer Bass Package - Includes Loaded Enclosure with...",
|
"Skar Audio Single 8\" Complete 1,200 Watt EVL Series Subwoofer Bass Package - Includes Loaded Enclosure with...",
|
||||||
|
@ -17,8 +16,9 @@ List<MyProduct> allProducts() => [
|
||||||
category: categories["Electronics"]!,
|
category: categories["Electronics"]!,
|
||||||
imageUrl:
|
imageUrl:
|
||||||
"https://m.media-amazon.com/images/I/710n3hnbfXL._AC_UY218_.jpg",
|
"https://m.media-amazon.com/images/I/710n3hnbfXL._AC_UY218_.jpg",
|
||||||
|
description: "",
|
||||||
),
|
),
|
||||||
MyProduct(
|
Product(
|
||||||
id: "2",
|
id: "2",
|
||||||
name:
|
name:
|
||||||
"Frameo 10.1 Inch WiFi Digital Picture Frame, 1280x800 HD IPS Touch Screen Photo Frame Electronic, 32GB Memory, Auto...",
|
"Frameo 10.1 Inch WiFi Digital Picture Frame, 1280x800 HD IPS Touch Screen Photo Frame Electronic, 32GB Memory, Auto...",
|
||||||
|
@ -26,8 +26,9 @@ List<MyProduct> allProducts() => [
|
||||||
category: categories["Electronics"]!,
|
category: categories["Electronics"]!,
|
||||||
imageUrl:
|
imageUrl:
|
||||||
"https://m.media-amazon.com/images/I/61O+aorCp0L._AC_UY218_.jpg",
|
"https://m.media-amazon.com/images/I/61O+aorCp0L._AC_UY218_.jpg",
|
||||||
|
description: "",
|
||||||
),
|
),
|
||||||
MyProduct(
|
Product(
|
||||||
id: "3",
|
id: "3",
|
||||||
name:
|
name:
|
||||||
"STREBITO Electronics Precision Screwdriver Sets 142-Piece with 120 Bits Magnetic Repair Tool Kit for iPhone, MacBook,...",
|
"STREBITO Electronics Precision Screwdriver Sets 142-Piece with 120 Bits Magnetic Repair Tool Kit for iPhone, MacBook,...",
|
||||||
|
@ -35,8 +36,9 @@ List<MyProduct> allProducts() => [
|
||||||
category: categories["Electronics"]!,
|
category: categories["Electronics"]!,
|
||||||
imageUrl:
|
imageUrl:
|
||||||
"https://m.media-amazon.com/images/I/81-C7lGtQsL._AC_UY218_.jpg",
|
"https://m.media-amazon.com/images/I/81-C7lGtQsL._AC_UY218_.jpg",
|
||||||
|
description: "",
|
||||||
),
|
),
|
||||||
MyProduct(
|
Product(
|
||||||
id: "4",
|
id: "4",
|
||||||
name:
|
name:
|
||||||
"Samsung Galaxy A15 (SM-155M/DSN), 128GB 6GB RAM, Dual SIM, Factory Unlocked GSM, International Version (Wall...",
|
"Samsung Galaxy A15 (SM-155M/DSN), 128GB 6GB RAM, Dual SIM, Factory Unlocked GSM, International Version (Wall...",
|
||||||
|
@ -44,8 +46,9 @@ List<MyProduct> allProducts() => [
|
||||||
category: categories["Smart phones"]!,
|
category: categories["Smart phones"]!,
|
||||||
imageUrl:
|
imageUrl:
|
||||||
"https://m.media-amazon.com/images/I/51rp0nqaPoL._AC_UY218_.jpg",
|
"https://m.media-amazon.com/images/I/51rp0nqaPoL._AC_UY218_.jpg",
|
||||||
|
description: "",
|
||||||
),
|
),
|
||||||
MyProduct(
|
Product(
|
||||||
id: "5",
|
id: "5",
|
||||||
name:
|
name:
|
||||||
"SAMSUNG Galaxy S24 Ultra Cell Phone, 512GB AI Smartphone, Unlocked Android, 50MP Zoom Camera, Long...",
|
"SAMSUNG Galaxy S24 Ultra Cell Phone, 512GB AI Smartphone, Unlocked Android, 50MP Zoom Camera, Long...",
|
||||||
|
@ -53,6 +56,7 @@ List<MyProduct> allProducts() => [
|
||||||
category: categories["Smart phones"]!,
|
category: categories["Smart phones"]!,
|
||||||
imageUrl:
|
imageUrl:
|
||||||
"https://m.media-amazon.com/images/I/71ZoDT7a2wL._AC_UY218_.jpg",
|
"https://m.media-amazon.com/images/I/71ZoDT7a2wL._AC_UY218_.jpg",
|
||||||
|
description: "",
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -72,7 +76,7 @@ ProductPageContent getShopContent(String shopId) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MyProduct> getProducts(String categoryId) {
|
List<Product> getProducts(String categoryId) {
|
||||||
if (categoryId == "1") {
|
if (categoryId == "1") {
|
||||||
return allProducts();
|
return allProducts();
|
||||||
} else if (categoryId == "2") {
|
} else if (categoryId == "2") {
|
||||||
|
|
|
@ -17,7 +17,10 @@ dependencies:
|
||||||
url: https://github.com/Iconica-Development/flutter_nested_categories
|
url: https://github.com/Iconica-Development/flutter_nested_categories
|
||||||
ref: 0.0.1
|
ref: 0.0.1
|
||||||
flutter_shopping:
|
flutter_shopping:
|
||||||
path: ../
|
git:
|
||||||
|
url: https://github.com/Iconica-Development/flutter_shopping
|
||||||
|
path: packages/flutter_shopping
|
||||||
|
ref: 2.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
name: flutter_shopping
|
name: flutter_shopping
|
||||||
description: "A new Flutter project."
|
description: "A new Flutter project."
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
publish_to: 'none'
|
||||||
version: 1.0.0
|
version: 2.0.0
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.3.4 <4.0.0'
|
sdk: '>=3.3.4 <4.0.0'
|
||||||
|
@ -13,17 +13,17 @@ dependencies:
|
||||||
flutter_product_page:
|
flutter_product_page:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/Iconica-Development/flutter_shopping
|
url: https://github.com/Iconica-Development/flutter_shopping
|
||||||
ref: 1.0.0
|
ref: 2.0.0
|
||||||
path: packages/flutter_product_page
|
path: packages/flutter_product_page
|
||||||
flutter_shopping_cart:
|
flutter_shopping_cart:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/Iconica-Development/flutter_shopping
|
url: https://github.com/Iconica-Development/flutter_shopping
|
||||||
ref: 1.0.0
|
ref: 2.0.0
|
||||||
path: packages/flutter_shopping_cart
|
path: packages/flutter_shopping_cart
|
||||||
flutter_order_details:
|
flutter_order_details:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/Iconica-Development/flutter_shopping
|
url: https://github.com/Iconica-Development/flutter_shopping
|
||||||
ref: 1.0.0
|
ref: 2.0.0
|
||||||
path: packages/flutter_order_details
|
path: packages/flutter_order_details
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
@ -35,13 +35,4 @@ dev_dependencies:
|
||||||
ref: 7.0.0
|
ref: 7.0.0
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
# assets:
|
|
||||||
# - images/a_dot_burr.jpeg
|
|
||||||
# - images/a_dot_ham.jpeg
|
|
||||||
|
|
||||||
# fonts:
|
|
||||||
# - family: Schyler
|
|
||||||
# fonts:
|
|
||||||
# - asset: fonts/Schyler-Regular.ttf
|
|
||||||
# - asset: fonts/Schyler-Italic.ttf
|
|
||||||
# style: italic
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
name: flutter_shopping_cart
|
name: flutter_shopping_cart
|
||||||
description: "A Flutter module for a shopping cart."
|
description: "A Flutter module for a shopping cart."
|
||||||
version: 1.0.0
|
version: 2.0.0
|
||||||
|
publish_to: 'none'
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.3.0 <4.0.0'
|
sdk: '>=3.3.0 <4.0.0'
|
||||||
|
@ -9,6 +10,12 @@ environment:
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
flutter_shopping:
|
||||||
|
git:
|
||||||
|
url: https://github.com/Iconica-Development/flutter_shopping
|
||||||
|
path: packages/flutter_shopping
|
||||||
|
ref: 2.0.0
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Reference in a new issue