2024-09-08 19:40:49 +04:00
|
|
|
import 'dart:math';
|
|
|
|
|
|
|
|
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-10-18 17:07:54 +04:00
|
|
|
debugShowCheckedModeBanner: false,
|
2024-09-08 19:40:49 +04:00
|
|
|
theme: ThemeData(
|
|
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange),
|
|
|
|
useMaterial3: true,
|
|
|
|
),
|
2024-09-08 20:53:37 +04:00
|
|
|
home: const MyHomePage(title: 'Афанасьев Степан Сергеевич'),
|
2024-09-08 19:40:49 +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-18 17:07:54 +04:00
|
|
|
final Color _color = Colors.orangeAccent;
|
2024-09-08 19:40:49 +04:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
backgroundColor: _color,
|
|
|
|
title: Text(widget.title),
|
|
|
|
),
|
2024-10-18 17:07:54 +04:00
|
|
|
body: const MyWidget(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-18 17:07:54 +04:00
|
|
|
|
|
|
|
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,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-10-18 17:07:54 +04:00
|
|
|
class MyWidget extends StatelessWidget {
|
2024-10-18 17:07:54 +04:00
|
|
|
const MyWidget({super.key}); // ключи
|
2024-10-18 17:07:54 +04:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final data = [
|
2024-10-18 17:07:54 +04:00
|
|
|
_CardData(
|
|
|
|
'Hello',
|
|
|
|
descriptionText: 'hshhshs',
|
|
|
|
imageUrl: 'https://images.stopgame.ru/games/logos/8351/c1536x856/VdQJNv5ECykaiteg212k5g/far_cry_2-square_1.jpg'
|
|
|
|
), // создаётся объект ранее созданного контейнера
|
|
|
|
_CardData(
|
|
|
|
'Ivan',
|
|
|
|
descriptionText: 'hshhshs',
|
|
|
|
imageUrl: 'https://images.stopgame.ru/games/logos/8351/c1536x856/VdQJNv5ECykaiteg212k5g/far_cry_2-square_1.jpg'
|
|
|
|
|
|
|
|
),
|
|
|
|
_CardData(
|
|
|
|
'Stepan',
|
|
|
|
descriptionText: 'hshhshs',
|
|
|
|
imageUrl: 'https://images.stopgame.ru/games/logos/8351/c1536x856/VdQJNv5ECykaiteg212k5g/far_cry_2-square_1.jpg'
|
|
|
|
|
2024-10-18 17:07:54 +04:00
|
|
|
),
|
|
|
|
];
|
|
|
|
return Center(
|
2024-10-18 17:07:54 +04:00
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, //расположение по главной оси
|
|
|
|
children: data.map((e) => _Card.fromData(e)).toList(),
|
|
|
|
),
|
2024-10-18 17:07:54 +04:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-18 17:07:54 +04:00
|
|
|
class _Card extends StatefulWidget {
|
2024-10-18 17:07:54 +04:00
|
|
|
final String text;
|
|
|
|
final String descriptionText;
|
2024-10-18 17:07:54 +04:00
|
|
|
final IconData icon;
|
2024-10-18 17:07:54 +04:00
|
|
|
final String? imageUrl;
|
|
|
|
|
|
|
|
const _Card(
|
|
|
|
this.text, {
|
2024-10-18 17:07:54 +04:00
|
|
|
this.icon = Icons.ac_unit_outlined,
|
2024-10-18 17:07:54 +04:00
|
|
|
required this.descriptionText,
|
|
|
|
this.imageUrl,
|
|
|
|
|
2024-10-18 17:07:54 +04:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
factory _Card.fromData(_CardData data) => _Card(
|
2024-10-18 17:07:54 +04:00
|
|
|
data.text,
|
|
|
|
descriptionText: data.descriptionText,
|
2024-10-18 17:07:54 +04:00
|
|
|
icon: data.icon,
|
2024-10-18 17:07:54 +04:00
|
|
|
imageUrl: data.imageUrl,
|
|
|
|
);
|
|
|
|
|
2024-10-18 17:07:54 +04:00
|
|
|
@override
|
|
|
|
State<_Card> createState() => _CardState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CardState extends State<_Card> {
|
2024-10-18 17:07:54 +04:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-10-18 17:07:54 +04:00
|
|
|
return Container(
|
|
|
|
margin: const EdgeInsets.only(top: 15),
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.orangeAccent,
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
border: Border.all(
|
|
|
|
color: Colors.grey,
|
|
|
|
width: 2,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Flexible(
|
|
|
|
child: ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
child: SizedBox(
|
|
|
|
height: 140,
|
|
|
|
width: 100,
|
|
|
|
child: Image.network(
|
|
|
|
widget.imageUrl ?? '',
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
errorBuilder: (_, __, ___) => const Placeholder(),
|
|
|
|
),
|
2024-10-18 17:07:54 +04:00
|
|
|
),
|
2024-10-18 17:07:54 +04:00
|
|
|
)),
|
|
|
|
Flexible(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
widget.text,
|
|
|
|
style:Theme.of(context).textTheme.headlineLarge,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
widget.descriptionText,
|
|
|
|
style:Theme.of(context).textTheme.bodyLarge,
|
|
|
|
),
|
|
|
|
],
|
2024-09-08 19:40:49 +04:00
|
|
|
),
|
2024-10-18 17:07:54 +04:00
|
|
|
),
|
2024-10-18 17:07:54 +04:00
|
|
|
),
|
|
|
|
const Spacer(),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 8.0),
|
|
|
|
child: Icon(widget.icon),
|
|
|
|
),
|
|
|
|
],
|
2024-09-08 19:40:49 +04:00
|
|
|
),
|
2024-10-18 17:07:54 +04:00
|
|
|
);
|
2024-09-08 19:40:49 +04:00
|
|
|
}
|
|
|
|
}
|
2024-10-18 17:07:54 +04:00
|
|
|
|