import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', debugShowCheckedModeBanner: false, theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.orangeAccent), useMaterial3: true, ), home: const MyHomePage(title: 'Cards'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text(widget.title), ), body: Padding( padding: const EdgeInsets.all(20), child: ListView.separated( itemBuilder: (context, index) => GestureDetector( child: CardWidget(name: "Pizza $index", price: 150.0), onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => DetailPage( name: "Pizza $index", price: 150.0, ), ), ); }, ), separatorBuilder: (context, index) => const SizedBox(height: 20), itemCount: 10, ))); } } class CardWidget extends StatefulWidget { const CardWidget({super.key, required this.name, required this.price}); final String name; final double price; @override State createState() => _CardWidgetState(); } class _CardWidgetState extends State { bool _isFavourite = false; void toggleIsFavourite() { setState(() { _isFavourite = !_isFavourite; final snackBar = SnackBar( duration: const Duration(seconds: 1), content: Text( _isFavourite ? 'Added to favorites' : 'Removed from favorites'), ); ScaffoldMessenger.of(context).showSnackBar(snackBar); }); } @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.all(4), decoration: BoxDecoration( border: Border.all(color: Colors.deepOrangeAccent, width: 2), borderRadius: BorderRadius.circular(20), ), child: Row( children: [ // Image Expanded( child: Image.asset( "images/pizza.png", fit: BoxFit.cover, ), ), // Content Expanded( flex: 2, child: Padding( padding: const EdgeInsets.only(left: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(widget.name, style: const TextStyle(fontSize: 18)), Text( "${widget.price} Руб", style: const TextStyle(fontSize: 17, color: Colors.orange), ), ], ), ), ), // Like Button IconButton( icon: Icon(_isFavourite ? Icons.favorite : Icons.favorite_border), color: Colors.red, onPressed: toggleIsFavourite, ), ], ), ); } } class DetailPage extends StatelessWidget { final String name; final double price; const DetailPage({super.key, required this.name, required this.price}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(name), ), body: Padding( padding: const EdgeInsets.all(20), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ Center( child: Image.asset( "images/pizza.png", ), ), const SizedBox(height: 20), Text(name, style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold)), const SizedBox(height: 10), Text("$price Руб", style: const TextStyle(fontSize: 20, color: Colors.orange)), // Add more details here as needed ], ), ), ); } }