2024-09-15 21:21:26 +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',
|
|
|
|
|
theme: ThemeData(
|
2024-11-13 23:10:49 +04:00
|
|
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple.shade300),
|
2024-09-15 21:21:26 +04:00
|
|
|
|
useMaterial3: true,
|
|
|
|
|
),
|
2024-11-13 23:10:49 +04:00
|
|
|
|
home: const MyHomePage(title: 'Энциклопедия кошек'),
|
2024-09-15 21:21:26 +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-11-13 23:10:49 +04:00
|
|
|
|
final Color _color = Colors.deepPurple.shade300;
|
2024-09-15 21:21:26 +04:00
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(
|
2024-11-13 23:10:49 +04:00
|
|
|
|
backgroundColor: _color,
|
2024-09-15 21:21:26 +04:00
|
|
|
|
title: Text(widget.title),
|
|
|
|
|
),
|
2024-11-13 23:10:49 +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.ac_unit_outlined,
|
|
|
|
|
this.imageUrl,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MyWidget extends StatelessWidget {
|
|
|
|
|
const MyWidget({super.key}); // ключи
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final data = [
|
|
|
|
|
_CardData(
|
|
|
|
|
'Абиссинская',
|
|
|
|
|
descriptionText: 'Эфиопия',
|
|
|
|
|
imageUrl: 'https://ajo-pet.ru/u/ckupload/files/abissinskaya-koshka-sorrel.jpg'
|
|
|
|
|
),
|
|
|
|
|
_CardData(
|
|
|
|
|
'Британская',
|
|
|
|
|
descriptionText: 'Великобритания',
|
|
|
|
|
imageUrl: 'https://zoopt.ru/upload/iblock/ce2/britan.png',
|
|
|
|
|
),
|
|
|
|
|
_CardData(
|
|
|
|
|
'Невская Маскарадная',
|
|
|
|
|
descriptionText: 'СССР',
|
|
|
|
|
imageUrl: 'https://wikipet.ru/wp-content/uploads/2018-10/1539243031_1491312430_nev_mask_info.jpg',
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return Center(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: data.map((e) => _Card.fromData(e)).toList(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _Card extends StatelessWidget {
|
|
|
|
|
final String text;
|
|
|
|
|
final String descriptionText;
|
|
|
|
|
final IconData icon;
|
|
|
|
|
final String? imageUrl;
|
|
|
|
|
|
|
|
|
|
const _Card(this.text, {
|
|
|
|
|
this.icon = Icons.ac_unit_outlined,
|
|
|
|
|
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(
|
|
|
|
|
margin: const EdgeInsets.only(top: 16),
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white70,
|
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
|
border: Border.all(color: Colors.grey),
|
|
|
|
|
boxShadow: [
|
|
|
|
|
BoxShadow(
|
|
|
|
|
color: Colors.grey.withOpacity(.5),
|
|
|
|
|
spreadRadius: 4,
|
|
|
|
|
offset: const Offset(0, 5),
|
|
|
|
|
blurRadius: 8,
|
2024-09-15 21:21:26 +04:00
|
|
|
|
),
|
2024-11-13 23:10:49 +04:00
|
|
|
|
],
|
2024-09-15 21:21:26 +04:00
|
|
|
|
),
|
2024-11-13 23:10:49 +04:00
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
ClipRRect(
|
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
height: 140,
|
|
|
|
|
width: 140,
|
|
|
|
|
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: TextStyle(fontSize: 25),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
descriptionText,
|
|
|
|
|
style: TextStyle(fontSize: 19),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 8.0),
|
|
|
|
|
child: Icon(icon),
|
|
|
|
|
),
|
|
|
|
|
],
|
2024-09-15 21:21:26 +04:00
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-11-13 23:10:49 +04:00
|
|
|
|
}
|