From 57ff8a59e8b4e7d3e56b77732952df403d776640 Mon Sep 17 00:00:00 2001 From: Sergey Elpashev Date: Sat, 11 May 2024 22:48:46 +0300 Subject: [PATCH] AssetImage using --- lib/components/app_bar.dart | 7 ++++--- lib/pages/basket.dart | 4 ++-- lib/pages/main.dart | 9 ++++++--- lib/pages/order_confirmation.dart | 16 ++++++++++++++-- lib/pages/order_history.dart | 4 ++-- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/lib/components/app_bar.dart b/lib/components/app_bar.dart index ae798c8..db6d080 100644 --- a/lib/components/app_bar.dart +++ b/lib/components/app_bar.dart @@ -14,9 +14,10 @@ class GymLinkAppBar extends StatelessWidget implements PreferredSizeWidget { title: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Padding( - padding: const EdgeInsets.only(right: 8), - child: Image.asset('logo.png', width: 24, height: 24), + const Padding( + padding: EdgeInsets.only(right: 8), + child: Image( + image: AssetImage('assets/logo.png'), width: 24, height: 24), ), Align( alignment: Alignment.centerRight, diff --git a/lib/pages/basket.dart b/lib/pages/basket.dart index 6c147ec..7abe21c 100644 --- a/lib/pages/basket.dart +++ b/lib/pages/basket.dart @@ -224,8 +224,8 @@ class _BasketPageState extends State { name: item['name'], price: item['price'], id: item['id'], - image: Image.asset( - item['image'], + image: Image( + image: AssetImage('assets/${item['image']}'), width: 50, ), onTapPlus: () => addItem(item['id'].toString()), diff --git a/lib/pages/main.dart b/lib/pages/main.dart index 39a0713..6a5c66f 100644 --- a/lib/pages/main.dart +++ b/lib/pages/main.dart @@ -179,8 +179,8 @@ class _MainPageState extends State { itemBuilder: (context, index) { final product = testData[index]; return ProductCard( - imagePath: Image.asset( - product['image']!, + imagePath: Image( + image: AssetImage('assets/${product['image']!}'), width: 100, ), name: product['name']!, @@ -192,7 +192,10 @@ class _MainPageState extends State { description: product['details']!, price: product['price']!, id: product['id']!, - image: Image.asset(product['image']!, width: 300), + image: Image( + image: + AssetImage('assets/${product['image']!}'), + width: 300), ), ), ), diff --git a/lib/pages/order_confirmation.dart b/lib/pages/order_confirmation.dart index d8c442a..96d3421 100644 --- a/lib/pages/order_confirmation.dart +++ b/lib/pages/order_confirmation.dart @@ -89,7 +89,10 @@ class _OrderConfirmationPageState extends State { final item = cartItems[index]; return OrderConfirmItemCard( name: item['name'], - image: Image.asset(item['image'], width: 50, height: 50), + image: Image( + image: AssetImage('assets/${item['image']}'), + width: 50, + height: 50), price: double.parse(item['price']), count: item['count'], ); @@ -126,7 +129,16 @@ class _OrderConfirmationPageState extends State { ), ElevatedButton( onPressed: () { - debugPrint('Order confirmed'); + print('debugprint'); + // if (kIsWeb) { + // Navigator.of(context).push( + // MaterialPageRoute( + // builder: (context) => const OrderPayPage(), + // ), + // ); + // } else { + // debugPrint('test'); + // } }, style: ElevatedButton.styleFrom( backgroundColor: Theme.of(context).primaryColor, diff --git a/lib/pages/order_history.dart b/lib/pages/order_history.dart index d69159e..b040c1b 100644 --- a/lib/pages/order_history.dart +++ b/lib/pages/order_history.dart @@ -60,8 +60,8 @@ class HistoryPage extends StatelessWidget { id: item['id']!, cost: item['price']!, date: item['date']!, - image: Image.asset( - item['image']!, + image: Image( + image: AssetImage('assets/${item['image']!}'), width: 50, ), status: OrderStatus.completed,