import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( // This is the theme of your application. // // TRY THIS: Try running your application with "flutter run". You'll see // the application has a purple toolbar. Then, without quitting the app, // try changing the seedColor in the colorScheme below to Colors.green // and then invoke "hot reload" (save your changes or press the "hot // reload" button in a Flutter-supported IDE, or press "r" if you used // the command line to start the app). // // Notice that the counter didn't reset back to zero; the application // state is not lost during the reload. To reset the state, use hot // restart instead. // // This works for code too, not just values: Most code changes can be // tested with just a hot reload. colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: const MyHomePage( title: Text("Simbirsk-Oil", style: TextStyle( fontSize: 28, fontWeight: FontWeight.w600, color: Color.fromRGBO(240, 240, 240, 1)))), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final Text title; @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.deepOrangeAccent, title: widget.title, ), body: Padding( padding: const EdgeInsets.all(30), child: ListView.separated( itemBuilder: (context, index) => Card( name: "Масло GM dexos2 ${index * 5}w-${index * 10 + 20}", price: index * 500 + 4000), separatorBuilder: (context, index) => const SizedBox(height: 40), itemCount: 3, ))); } } class Card extends StatefulWidget { const Card({super.key, required this.name, required this.price}); final String name; final int price; @override State createState() => _CardState(); } class _CardState extends State { bool _isFavourite = false; void toggleIsFavourite() { setState(() { _isFavourite = !_isFavourite; }); } @override Widget build(BuildContext context) { return Stack( children: [ Container( padding: const EdgeInsets.only(top: 50, bottom: 15, left: 40, right: 40), decoration: BoxDecoration( border: Border.all(color: Colors.black12, width: 2), borderRadius: BorderRadius.circular(40)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Center( child: Image.network( "https://berimaslo.ru/upload/iblock/1b4/4w95d0a1xk1wsgkyk6irpp7h4yt7lz3k.jpeg"), ), Padding( padding: EdgeInsets.only(top: 30, right: 30), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(widget.name, style: const TextStyle( fontSize: 22, fontWeight: FontWeight.bold, color: Color.fromRGBO(70, 70, 70, 1))), SizedBox(height: 7), Text("${widget.price} ₽", style: const TextStyle( fontSize: 22, color: Color.fromRGBO(70, 70, 70, 1), fontWeight: FontWeight.bold)) ], ), ) ], ), ), Positioned( right: 20, bottom: 10, child: IconButton( icon: Icon(_isFavourite ? Icons.favorite : Icons.favorite_border), color: Colors.purple, onPressed: toggleIsFavourite, )) ], ); } }