This commit is contained in:
Alenka 2024-09-25 00:25:31 +04:00
parent 46bade5080
commit 50c1b3600e
2 changed files with 63 additions and 49 deletions

BIN
assets/сайт.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -1,76 +1,90 @@
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Demo',
title: 'Card List',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Панина Алёна Денисовна'),
home: CardListScreen(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
class CardListScreen extends StatelessWidget {
final List<Map<String, String>> items = [
{
'title': 'Москва-сити',
'description': 'ул. Пресненская Набережная, 6.',
'image': 'https://avatars.mds.yandex.net/i?id=3b3ba2410de1f807162074752fa01cbf8b8f75ed-4507796-images-thumbs&n=13'
},
{
'title': 'Красная площадь',
'description': 'ул. Тверская, д. 10.',
'image': 'https://avatars.mds.yandex.net/i?id=855279ca345f259516f990bd24c62645cc8eab24-4012351-images-thumbs&n=13'
},
{
'title': 'ГУМ',
'description': 'Красная площадь, 3.',
'image': 'https://avatars.mds.yandex.net/i?id=471812ce52e0416c0172e2ad2df2de66a7601625-13101691-images-thumbs&n=13'
},
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Куда сходить в Москве'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
body: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, // Количество колонок
crossAxisSpacing: 10, // Расстояние между колонками
mainAxisSpacing: 10, // Расстояние между строками
),
itemCount: items.length,
itemBuilder: (context, index) {
return Card(
color: Colors.grey[300],
margin: EdgeInsets.all(10),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
),
child: Padding(
padding: const EdgeInsets.all(8.0), // Уменьшение отступов
child: Column(
mainAxisSize: MainAxisSize.min, // Заставляет карточку занимать минимальный размер
children: [
Expanded(
child: Image.network(
items[index]['image']!,
fit: BoxFit.cover, // Подгоняет изображение по размеру
),
),
SizedBox(height: 5), // Отступ между изображением и текстом
Text(
items[index]['title']!,
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), // Увеличение размера текста
),
SizedBox(height: 5), // Отступ между заголовком и описанием
Text(
items[index]['description']!,
style: TextStyle(fontSize: 14), // Увеличение размера текста
textAlign: TextAlign.center, // Центрирование текста
),
],
),
),
);
},
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}