185 lines
4.6 KiB
Dart
185 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.deepPurple),
|
|
useMaterial3: true,
|
|
),
|
|
home: const MyHomePage(title: 'Захаров Ростислав, ПИбд-33'),
|
|
);
|
|
}
|
|
}
|
|
|
|
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.redAccent;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: _color,
|
|
title: Text(widget.title),
|
|
),
|
|
body: const Center(
|
|
child: MyWidget()
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class MyWidget extends StatelessWidget {
|
|
const MyWidget({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final data = [
|
|
_CardData(
|
|
'Oh?',
|
|
description: 'pain',
|
|
icon: Icons.add_box,
|
|
imageUrl: 'https://www.thespruceeats.com/thmb/QjCQ4RTjmnhrovGkuJWzZCXYFX8=/1500x0/filters:no_upscale():max_bytes(150000):strip_icc()/GettyImages-90053856-588b7aff5f9b5874ee534b04.jpg',
|
|
),
|
|
_CardData(
|
|
'Freeze?',
|
|
description: 'suffering',
|
|
icon: Icons.ac_unit_sharp,
|
|
imageUrl: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTwgAMeszx47tsBuUK20XIByglQcnAZCOEQJw&s',
|
|
),
|
|
_CardData(
|
|
'Hi?',
|
|
description: 'horror',
|
|
icon: Icons.access_alarms,
|
|
imageUrl: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRsya6wSRjwvxaWlZEKn0U7gW6F2PWI54D6hw&s',
|
|
),
|
|
];
|
|
return Center(
|
|
child: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: data.map((_CardData x) => _Card.fromData(x)).toList(),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _CardData {
|
|
final String text;
|
|
final String description;
|
|
final IconData icon;
|
|
final String? imageUrl;
|
|
|
|
_CardData(this.text, {
|
|
required this.description,
|
|
this.icon = Icons.icecream,
|
|
this.imageUrl,
|
|
});
|
|
}
|
|
|
|
class _Card extends StatelessWidget {
|
|
final String text;
|
|
final String description;
|
|
final IconData icon;
|
|
final String? imageUrl;
|
|
|
|
const _Card(this.text, {
|
|
required this.description,
|
|
this.icon = Icons.icecream,
|
|
this.imageUrl,
|
|
});
|
|
|
|
factory _Card.fromData(_CardData data) => _Card(
|
|
data.text,
|
|
description: data.description,
|
|
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.orangeAccent,
|
|
borderRadius: BorderRadius.circular(20),
|
|
border: Border.all(
|
|
color: Colors.redAccent,
|
|
width: 4,
|
|
),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.redAccent.withOpacity(.6),
|
|
spreadRadius: 4,
|
|
offset: const Offset(0, 5),
|
|
blurRadius: 8,
|
|
),
|
|
],
|
|
),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(20),
|
|
child: SizedBox(
|
|
height: 140,
|
|
width: 100,
|
|
child: Image.network(
|
|
fit: BoxFit.cover,
|
|
imageUrl ?? '',
|
|
errorBuilder: (_, __, ___) => const Placeholder(),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
text,
|
|
style: Theme.of(context).textTheme.headlineLarge,
|
|
),
|
|
Text(
|
|
description,
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Icon(icon),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|