diff --git a/lib/Presentation/home_page/card.dart b/lib/Presentation/home_page/card.dart index 43c425a..22e268d 100644 --- a/lib/Presentation/home_page/card.dart +++ b/lib/Presentation/home_page/card.dart @@ -3,7 +3,7 @@ part of 'home_page.dart'; class _CardData { final String text; final String info; - final String urlImage; + final String? urlImage; _CardData({required this.text, required this.info, required this.urlImage}); } @@ -11,7 +11,7 @@ class _CardData { class _Card extends StatefulWidget { final String text; final String info; - final String urlImage; + final String? urlImage; const _Card({super.key, required this.text, required this.info, required this.urlImage}); @@ -36,7 +36,7 @@ class _CardState extends State<_Card> { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Image.network( - widget.urlImage, + widget.urlImage ?? 'https://hlebzavod3.ru/images/virtuemart/product/011_IMG_9657.jpg', fit: BoxFit.cover, height: 150.0, width: double.infinity, diff --git a/lib/Presentation/home_page/home_page.dart b/lib/Presentation/home_page/home_page.dart index afb02c6..72756dd 100644 --- a/lib/Presentation/home_page/home_page.dart +++ b/lib/Presentation/home_page/home_page.dart @@ -46,7 +46,10 @@ class Body extends StatelessWidget { urlImage: "https://shokoladd.ru/wp-content/uploads/2019/02/Croissant_Chocolate_Plate_Two_547531_2048x1152.jpg"), _CardData(text: "Чиаба́тта", info: "Итальянский пшеничный хлеб, выпекаемый с использованием закваски, дрожжей и оливкового масла", - urlImage: "https://avatars.mds.yandex.net/i?id=a9163f90a989a596b26b30ad39beaf47_l-10629685-images-thumbs&n=13") + urlImage: "https://avatars.mds.yandex.net/i?id=a9163f90a989a596b26b30ad39beaf47_l-10629685-images-thumbs&n=13"), + _CardData(text: "Булочка без картинки", + info: "Очень кусьна", + urlImage: null) ]; return Center( child: SingleChildScrollView( @@ -57,4 +60,17 @@ class Body extends StatelessWidget { ) ); } + + void _showSnackBar(BuildContext context) { + WidgetsBinding.instance.addPostFrameCallback((_){ + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text( + 'Bread liked!', + style: Theme.of(context).textTheme.bodyLarge, + ), + backgroundColor: Colors.blueGrey, + duration: const Duration(seconds: 1), + )); + }); + } } \ No newline at end of file