Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
6e3e02788a |
157
lib/main.dart
157
lib/main.dart
@ -13,10 +13,10 @@ class MyApp extends StatelessWidget {
|
|||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Flutter Demo',
|
title: 'Flutter Demo',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple.shade300),
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
),
|
),
|
||||||
home: const MyHomePage(title: 'Долгова Дарья Николаевна'),
|
home: const MyHomePage(title: 'Энциклопедия кошек'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,41 +31,144 @@ class MyHomePage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
int _counter = 0;
|
final Color _color = Colors.deepPurple.shade300;
|
||||||
|
|
||||||
void _incrementCounter() {
|
|
||||||
setState(() {
|
|
||||||
_counter++;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
backgroundColor: _color,
|
||||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
||||||
title: Text(widget.title),
|
title: Text(widget.title),
|
||||||
),
|
),
|
||||||
body: Center(
|
body: const MyWidget(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyWidget extends StatelessWidget {
|
||||||
|
const MyWidget({super.key}); // ключи
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final data = [
|
||||||
|
_CardData(
|
||||||
|
'Абиссинская',
|
||||||
|
descriptionText: 'Эфиопия',
|
||||||
|
imageUrl: 'https://ajo-pet.ru/u/ckupload/files/abissinskaya-koshka-sorrel.jpg'
|
||||||
|
),
|
||||||
|
_CardData(
|
||||||
|
'Британская',
|
||||||
|
descriptionText: 'Великобритания',
|
||||||
|
imageUrl: 'https://zoopt.ru/upload/iblock/ce2/britan.png',
|
||||||
|
),
|
||||||
|
_CardData(
|
||||||
|
'Невская Маскарадная',
|
||||||
|
descriptionText: 'СССР',
|
||||||
|
imageUrl: 'https://wikipet.ru/wp-content/uploads/2018-10/1539243031_1491312430_nev_mask_info.jpg',
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
return Center(
|
||||||
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: data.map((e) => _Card.fromData(e)).toList(),
|
||||||
const Text(
|
|
||||||
'You have pushed the button this many times:',
|
|
||||||
),
|
),
|
||||||
Text(
|
),
|
||||||
'$_counter',
|
);
|
||||||
style: Theme.of(context).textTheme.headlineMedium,
|
}
|
||||||
),
|
}
|
||||||
],
|
|
||||||
),
|
class _Card extends StatelessWidget {
|
||||||
),
|
final String text;
|
||||||
floatingActionButton: FloatingActionButton(
|
final String descriptionText;
|
||||||
onPressed: _incrementCounter,
|
final IconData icon;
|
||||||
tooltip: 'Increment',
|
final String? imageUrl;
|
||||||
child: const Icon(Icons.add),
|
|
||||||
|
const _Card(this.text, {
|
||||||
|
this.icon = Icons.ac_unit_outlined,
|
||||||
|
required this.descriptionText,
|
||||||
|
this.imageUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory _Card.fromData(_CardData data) =>
|
||||||
|
_Card(
|
||||||
|
data.text,
|
||||||
|
descriptionText: data.descriptionText,
|
||||||
|
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.white70,
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
border: Border.all(color: Colors.grey),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.grey.withOpacity(.5),
|
||||||
|
spreadRadius: 4,
|
||||||
|
offset: const Offset(0, 5),
|
||||||
|
blurRadius: 8,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
child: SizedBox(
|
||||||
|
height: 140,
|
||||||
|
width: 140,
|
||||||
|
child: Image.network(
|
||||||
|
imageUrl ?? '',
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
errorBuilder: (_, __, ___) => const Placeholder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
text,
|
||||||
|
style: TextStyle(fontSize: 25),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
descriptionText,
|
||||||
|
style: TextStyle(fontSize: 19),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
|
child: Icon(icon),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user