2024-09-09 20:19:01 +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-10-02 22:38:49 +04:00
|
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.lightGreen),
|
2024-09-09 20:19:01 +04:00
|
|
|
useMaterial3: true,
|
|
|
|
),
|
2024-10-02 22:38:49 +04:00
|
|
|
home: const MyHomePage(),
|
2024-09-09 20:19:01 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyHomePage extends StatefulWidget {
|
2024-10-02 22:38:49 +04:00
|
|
|
const MyHomePage({super.key});
|
2024-09-09 20:19:01 +04:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
2024-10-02 22:38:49 +04:00
|
|
|
List<_CardData> data = [
|
|
|
|
_CardData(
|
2024-10-03 00:15:45 +04:00
|
|
|
textData: "250x150 picture",
|
|
|
|
imageUrl: "https://loremflickr.com/250/150/kitty"),
|
2024-10-02 22:38:49 +04:00
|
|
|
_CardData(
|
2024-10-03 00:15:45 +04:00
|
|
|
textData: "200x250 picture",
|
|
|
|
imageUrl: "https://loremflickr.com/200/250/kitty"),
|
2024-10-02 22:38:49 +04:00
|
|
|
_CardData(
|
|
|
|
textData: "200x200 picture",
|
2024-10-03 00:15:45 +04:00
|
|
|
imageUrl: "https://loremflickr.com/200/200/kitty"),
|
2024-10-02 22:38:49 +04:00
|
|
|
_CardData(
|
|
|
|
textData: "100x150 picture",
|
2024-10-03 00:15:45 +04:00
|
|
|
imageUrl: "https://loremflickr.com/100/150/kitty"),
|
2024-10-02 22:38:49 +04:00
|
|
|
_CardData(
|
|
|
|
textData: "300x150 picture",
|
2024-10-03 00:15:45 +04:00
|
|
|
imageUrl: "https://loremflickr.com/350/150/kitty"),
|
2024-10-02 22:38:49 +04:00
|
|
|
];
|
2024-09-09 20:19:01 +04:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
2024-10-02 22:38:49 +04:00
|
|
|
appBar: AppBar(
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
|
|
title: Text(
|
|
|
|
'Item list',
|
|
|
|
),
|
2024-09-09 20:19:01 +04:00
|
|
|
),
|
2024-10-02 22:38:49 +04:00
|
|
|
body: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
children: data.map((d) => _Card.withData(d)).toList(),
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CardData {
|
|
|
|
final String textData;
|
|
|
|
final String imageUrl;
|
|
|
|
|
|
|
|
const _CardData({required this.textData, required this.imageUrl});
|
|
|
|
}
|
|
|
|
|
|
|
|
class _Card extends StatelessWidget {
|
2024-10-03 00:15:45 +04:00
|
|
|
final String text;
|
|
|
|
final String imageUrl;
|
2024-10-02 22:38:49 +04:00
|
|
|
|
2024-10-03 00:15:45 +04:00
|
|
|
const _Card({required this.text, required this.imageUrl});
|
2024-10-02 22:38:49 +04:00
|
|
|
|
|
|
|
factory _Card.withData(_CardData d) => _Card(
|
|
|
|
text: d.textData,
|
|
|
|
imageUrl: d.imageUrl,
|
|
|
|
);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Container(
|
|
|
|
margin: EdgeInsets.all(5.0),
|
|
|
|
padding: EdgeInsets.all(8.0),
|
|
|
|
decoration: BoxDecoration(
|
2024-10-03 00:15:45 +04:00
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Colors.grey.withOpacity(0.5),
|
|
|
|
spreadRadius: 3,
|
|
|
|
offset: const Offset(0, 2),
|
|
|
|
blurRadius: 4)
|
|
|
|
],
|
2024-10-02 22:38:49 +04:00
|
|
|
color: Theme.of(context).colorScheme.inversePrimary,
|
|
|
|
borderRadius: BorderRadius.circular(20)),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
child: SizedBox(
|
|
|
|
width: 150,
|
|
|
|
height: 150,
|
|
|
|
child: Image.network(
|
|
|
|
imageUrl == ""
|
|
|
|
? "https://loremflickr.com/150/150?random=1"
|
|
|
|
: imageUrl,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 16.0, top: 16.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
text,
|
|
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"This is card with picture and text",
|
|
|
|
style: Theme.of(context).textTheme.labelSmall,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
2024-09-09 20:19:01 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|