169 lines
4.6 KiB
Dart
169 lines
4.6 KiB
Dart
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(
|
||
// colorScheme: ColorScheme.fromSeed(seedColor: Colors.black), colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
||
useMaterial3: true,
|
||
),
|
||
home: const MyHomePage(title: 'Flutter rocks!'),
|
||
);
|
||
}
|
||
}
|
||
|
||
class MyHomePage extends StatefulWidget {
|
||
const MyHomePage({super.key, required this.title});
|
||
|
||
final String title;
|
||
|
||
@override
|
||
State<MyHomePage> createState() => _MyHomePageState();
|
||
}
|
||
|
||
class _MyHomePageState extends State<MyHomePage> {
|
||
final Color _color = Colors.orangeAccent;
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Scaffold(
|
||
appBar: AppBar(
|
||
backgroundColor: _color,
|
||
title: Text(widget.title),
|
||
),
|
||
body: const MyWidget(),
|
||
);
|
||
}
|
||
}
|
||
|
||
class MyWidget extends StatelessWidget {
|
||
const MyWidget({super.key});
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
final data = [
|
||
_CardDate(
|
||
'Какая-то новость',
|
||
description: 'В данном блоке рекомендуем разместить краткую информацию',
|
||
imgUrl:
|
||
'https://universal.revengel.ru/assets/cache_image/images/services/3_731x487_1cb.png',
|
||
),
|
||
_CardDate(
|
||
'Ещё какая-то новость',
|
||
description: 'В данном блоке рекомендуем разместить краткую информацию',
|
||
imgUrl:
|
||
"https://universal.revengel.ru/assets/cache_image/images/services/2_731x487_1cb.png",
|
||
),
|
||
_CardDate(
|
||
'Ещё одна новость',
|
||
description: 'В данном блоке рекомендуем разместить краткую информацию',
|
||
imgUrl:
|
||
"https://universal.revengel.ru/assets/cache_image/images/services/1_731x487_1cb.png",
|
||
)
|
||
];
|
||
|
||
return Center(
|
||
child: SingleChildScrollView(
|
||
padding: const EdgeInsets.only(left: 20, right: 20, top: 20),
|
||
child: Column(
|
||
children: data.map((e) => _Card.fromData(e)).toList(),
|
||
),
|
||
),
|
||
);
|
||
}
|
||
}
|
||
|
||
class _CardDate {
|
||
final String text;
|
||
final String description;
|
||
final String? imgUrl;
|
||
|
||
_CardDate(
|
||
this.text, {
|
||
required this.description,
|
||
this.imgUrl,
|
||
});
|
||
}
|
||
|
||
class _Card extends StatelessWidget {
|
||
final String text;
|
||
final String description;
|
||
final String? imgUrl;
|
||
|
||
const _Card(
|
||
this.text, {
|
||
required this.description,
|
||
this.imgUrl,
|
||
});
|
||
|
||
factory _Card.fromData(_CardDate data) => _Card(
|
||
data.text,
|
||
description: data.description,
|
||
imgUrl: data.imgUrl,
|
||
);
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Container(
|
||
margin: const EdgeInsets.only(bottom: 20),
|
||
decoration: BoxDecoration(
|
||
color: Colors.white,
|
||
borderRadius: BorderRadius.circular(20),
|
||
boxShadow: [
|
||
BoxShadow(
|
||
color: Colors.black.withOpacity(0.1),
|
||
spreadRadius: 1,
|
||
offset: const Offset(0, 0),
|
||
blurRadius: 15,
|
||
)
|
||
]),
|
||
child: Column(children: [
|
||
ClipRRect(
|
||
borderRadius: const BorderRadius.only(
|
||
topLeft: Radius.circular(20), topRight: Radius.circular(20)),
|
||
child: Image.network(
|
||
imgUrl ?? '',
|
||
errorBuilder: (_, __, ___) => const Placeholder(),
|
||
fit: BoxFit.fitWidth,
|
||
),
|
||
),
|
||
Padding(
|
||
padding: const EdgeInsets.all(20),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Padding(
|
||
padding: const EdgeInsets.only(bottom:10),
|
||
child: Text(
|
||
text,
|
||
style: const TextStyle(
|
||
color: Color(0xff4c4c4c),
|
||
fontSize: 30,
|
||
fontWeight: FontWeight.bold,
|
||
),
|
||
),
|
||
),
|
||
Text(
|
||
description,
|
||
style: const TextStyle(
|
||
color: Color(0xff9c9c9c),
|
||
fontSize: 20,
|
||
fontWeight: FontWeight.normal,
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
]),
|
||
);
|
||
}
|
||
}
|