Compare commits
No commits in common. "lab3" and "master" have entirely different histories.
161
lib/main.dart
161
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.shade300),
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
),
|
),
|
||||||
home: const MyHomePage(title: 'Энциклопедия кошек'),
|
home: const MyHomePage(title: 'Долгова Дарья Николаевна'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,144 +31,41 @@ class MyHomePage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
final Color _color = Colors.deepPurple.shade300;
|
int _counter = 0;
|
||||||
|
|
||||||
|
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: const MyWidget(),
|
body: Center(
|
||||||
);
|
child: Column(
|
||||||
}
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
}
|
children: <Widget>[
|
||||||
|
const Text(
|
||||||
class _CardData {
|
'You have pushed the button this many times:',
|
||||||
final String text;
|
),
|
||||||
final String descriptionText;
|
Text(
|
||||||
final IconData icon;
|
'$_counter',
|
||||||
final String? imageUrl;
|
style: Theme.of(context).textTheme.headlineMedium,
|
||||||
|
),
|
||||||
_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(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: data.map((e) => _Card.fromData(e)).toList(),
|
|
||||||
),
|
),
|
||||||
),
|
floatingActionButton: FloatingActionButton(
|
||||||
);
|
onPressed: _incrementCounter,
|
||||||
}
|
tooltip: 'Increment',
|
||||||
}
|
child: const Icon(Icons.add),
|
||||||
|
|
||||||
class _Card extends StatelessWidget {
|
|
||||||
final String text;
|
|
||||||
final String descriptionText;
|
|
||||||
final IconData icon;
|
|
||||||
final String? imageUrl;
|
|
||||||
|
|
||||||
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