2024-09-18 16:29:46 +04:00
|
|
|
|
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',
|
2024-09-18 16:52:27 +04:00
|
|
|
|
debugShowCheckedModeBanner: false,
|
2024-09-18 16:29:46 +04:00
|
|
|
|
theme: ThemeData(
|
|
|
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
|
|
|
|
useMaterial3: true,
|
|
|
|
|
),
|
2024-09-18 17:26:27 +04:00
|
|
|
|
home: const MyHomePage(title: 'Чубыкина Полина Павловна'),
|
2024-09-18 16:29:46 +04:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
|
|
|
const MyHomePage({super.key, required this.title});
|
|
|
|
|
|
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
2024-10-02 13:33:02 +04:00
|
|
|
|
final Color _color = Colors.brown.shade300;
|
2024-09-18 16:29:46 +04:00
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
backgroundColor: _color,
|
|
|
|
|
title: Text(widget.title),
|
|
|
|
|
),
|
2024-10-02 12:55:38 +04:00
|
|
|
|
body: const MyWidget(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _CardData {
|
|
|
|
|
final String text;
|
|
|
|
|
final String descriptionText;
|
|
|
|
|
final IconData icon;
|
|
|
|
|
final String? imageUrl;
|
|
|
|
|
|
|
|
|
|
_CardData(
|
|
|
|
|
this.text, {
|
|
|
|
|
required this.descriptionText,
|
|
|
|
|
this.icon = Icons.abc,
|
|
|
|
|
this.imageUrl,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MyWidget extends StatelessWidget {
|
|
|
|
|
const MyWidget({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final data = [
|
|
|
|
|
_CardData(
|
|
|
|
|
'кот',
|
|
|
|
|
descriptionText: 'глупенький',
|
2024-10-02 13:33:02 +04:00
|
|
|
|
icon: Icons.favorite,
|
2024-10-02 12:55:38 +04:00
|
|
|
|
imageUrl:
|
|
|
|
|
'https://i.pinimg.com/564x/98/74/75/98747559040c03402a6d9ad4e47152c6.jpg',
|
|
|
|
|
),
|
|
|
|
|
_CardData(
|
|
|
|
|
'сырный кот',
|
|
|
|
|
descriptionText: 'он не виноват',
|
2024-10-02 13:33:02 +04:00
|
|
|
|
icon: Icons.favorite,
|
2024-10-02 12:55:38 +04:00
|
|
|
|
imageUrl:
|
|
|
|
|
'https://i.pinimg.com/564x/e7/c5/59/e7c559e449cd0bb5370d7740b57daa1f.jpg',
|
|
|
|
|
),
|
|
|
|
|
_CardData(
|
|
|
|
|
'злой кот',
|
|
|
|
|
descriptionText: 'я бы ему не верила',
|
2024-10-02 13:33:02 +04:00
|
|
|
|
icon: Icons.favorite,
|
2024-10-02 12:55:38 +04:00
|
|
|
|
imageUrl:
|
|
|
|
|
'https://i.pinimg.com/736x/27/cf/5e/27cf5e3abe1795ce04095941902c61ca.jpg',
|
|
|
|
|
),
|
|
|
|
|
_CardData(
|
|
|
|
|
'умный кот',
|
|
|
|
|
descriptionText: 'он только делает вид что умный',
|
2024-10-02 13:33:02 +04:00
|
|
|
|
icon: Icons.favorite,
|
2024-10-02 12:55:38 +04:00
|
|
|
|
imageUrl:
|
|
|
|
|
'https://i.pinimg.com/736x/e9/24/80/e924801430b813eee2635b40fe6e11d6.jpg',
|
|
|
|
|
),
|
|
|
|
|
_CardData(
|
2024-10-02 13:33:02 +04:00
|
|
|
|
'кот в шляпе',
|
2024-10-02 12:55:38 +04:00
|
|
|
|
descriptionText: '我喜欢橘子!',
|
2024-10-02 13:33:02 +04:00
|
|
|
|
icon: Icons.favorite,
|
2024-10-02 12:55:38 +04:00
|
|
|
|
imageUrl:
|
|
|
|
|
'https://i.pinimg.com/564x/3e/ed/11/3eed1103c548ed7c46a1e37a2695f53a.jpg',
|
|
|
|
|
),
|
|
|
|
|
_CardData(
|
|
|
|
|
'котенок',
|
|
|
|
|
descriptionText: 'я его очень понимаю',
|
2024-10-02 13:33:02 +04:00
|
|
|
|
icon: Icons.favorite,
|
2024-10-02 12:55:38 +04:00
|
|
|
|
imageUrl:
|
|
|
|
|
'https://i.pinimg.com/736x/38/9f/e6/389fe61133f036fc980a6b2e7abb2557.jpg',
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return Center(
|
|
|
|
|
child: SingleChildScrollView(
|
2024-09-18 16:29:46 +04:00
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
2024-10-02 12:55:38 +04:00
|
|
|
|
children: data.map((e) => _Card.fromData(e)).toList(),
|
2024-09-18 16:29:46 +04:00
|
|
|
|
),
|
|
|
|
|
),
|
2024-10-02 12:55:38 +04:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _Card extends StatelessWidget {
|
|
|
|
|
final String text;
|
|
|
|
|
final String descriptionText;
|
|
|
|
|
final IconData icon;
|
|
|
|
|
final String? imageUrl;
|
|
|
|
|
|
|
|
|
|
const _Card(
|
|
|
|
|
this.text, {
|
|
|
|
|
this.icon = Icons.abc,
|
|
|
|
|
required this.descriptionText,
|
|
|
|
|
this.imageUrl,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
factory _Card.fromData(_CardData data) => _Card(
|
|
|
|
|
data.text,
|
|
|
|
|
descriptionText: data.descriptionText,
|
|
|
|
|
icon: data.icon,
|
|
|
|
|
imageUrl: data.imageUrl,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Container(
|
2024-10-02 13:33:02 +04:00
|
|
|
|
margin: const EdgeInsets.all(6),
|
2024-10-02 12:55:38 +04:00
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white70,
|
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
|
border: Border.all(color: Colors.grey.shade200),
|
|
|
|
|
boxShadow: [
|
|
|
|
|
BoxShadow(
|
|
|
|
|
color: Colors.grey.withOpacity(.5),
|
|
|
|
|
spreadRadius: 4,
|
|
|
|
|
offset: const Offset(0, 5),
|
|
|
|
|
blurRadius: 8,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
ClipRRect(
|
2024-10-02 13:33:02 +04:00
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
2024-10-02 12:55:38 +04:00
|
|
|
|
child: SizedBox(
|
|
|
|
|
height: 140,
|
2024-10-02 13:33:02 +04:00
|
|
|
|
width: 140,
|
2024-10-02 12:55:38 +04:00
|
|
|
|
child: Image.network(
|
|
|
|
|
imageUrl ?? '',
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
errorBuilder: (_, __, ___) => const Placeholder(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 8.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
text,
|
|
|
|
|
style: Theme.of(context).textTheme.headlineLarge,
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
descriptionText,
|
|
|
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
2024-10-02 13:33:02 +04:00
|
|
|
|
padding: const EdgeInsets.only(left: 8.0, top: 10.0),
|
2024-10-02 12:55:38 +04:00
|
|
|
|
child: Icon(icon),
|
|
|
|
|
),
|
|
|
|
|
],
|
2024-09-18 16:29:46 +04:00
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|