Compare commits

..

No commits in common. "lab3" and "master" have entirely different histories.
lab3 ... master

View File

@ -9,12 +9,12 @@ void main() {
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
const MyApp({super.key}); const MyApp({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
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),
useMaterial3: true, useMaterial3: true,
), ),
home: const MyHomePage(title: 'KozyrevSS'), home: const MyHomePage(title: 'KozyrevSS'),
@ -25,6 +25,8 @@ class MyApp extends StatelessWidget {
class MyHomePage extends StatefulWidget { class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title}); const MyHomePage({super.key, required this.title});
final String title; final String title;
@override @override
@ -32,132 +34,42 @@ class MyHomePage extends StatefulWidget {
} }
class _MyHomePageState extends State<MyHomePage> { class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
Color _color = Colors.white;
void _incrementCounter() {
setState(() {
_counter++;
_color = Color((Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0);
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final data = [ return Scaffold(
const _CardData( appBar: AppBar(
"First", backgroundColor: _color,
description: "SomeText", title: Text(widget.title),
), ),
const _CardData( body: Center(
"Second", child: Column(
icon: Icons.gamepad, mainAxisAlignment: MainAxisAlignment.center,
description: "ManyText", children: <Widget>[
imageUrl: "https://i.pinimg.com/originals/21/73/24/217324138d1bbc91663d4943ebe5de60.jpg", const Text(
), 'You have pushed the button this many times:',
const _CardData( ),
"Third", Text(
icon: Icons.offline_bolt_outlined, '$_counter',
description: "Wow >_<", style: Theme.of(context).textTheme.headlineMedium,
), ),
]; if (_counter > 10)
const Text("Why are you doing this?",)
return Scaffold( ],
appBar: AppBar(
backgroundColor: Colors.purple,
title: Text(widget.title),
), ),
body: Center( ),
child: SingleChildScrollView( floatingActionButton: FloatingActionButton(
child: Column( onPressed: _incrementCounter,
mainAxisAlignment: MainAxisAlignment.center, tooltip: 'Increment',
children: data.map((e) => _Card.fromData(e)).toList(), child: const Icon(Icons.add),
), ), );
)));
}
}
class _CardData {
final String text;
final String description;
final IconData icon;
final String imageUrl;
const _CardData(
this.text, {
required this.description,
this.icon = Icons.add_call,
this.imageUrl =
"https://i.pinimg.com/736x/5f/14/b3/5f14b3f14fcd157bc4dffa39085396cc.jpg",
});
}
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.add_call,
required 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.all(15),
padding: const EdgeInsets.all(15),
decoration: BoxDecoration(
color: Colors.purple,
borderRadius: BorderRadius.circular(20),
border: Border.all(color: Colors.green, width: 2),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(.4),
offset: const Offset(0, 5),
blurRadius: 6,
spreadRadius: 3
),
]
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(20),
child: SizedBox(
height: 140,
width: 100,
child: Image.network(
imageUrl ?? '',
fit: BoxFit.cover,
errorBuilder: (_, __, ___) => const Placeholder(),
),
),
),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
text * 10,
style: Theme.of(context).textTheme.headlineLarge,
),
Text(
description,
style: Theme.of(context).textTheme.bodySmall,
)
],
),
),
Padding(
padding: const EdgeInsets.only(left: 8),
child: Icon(icon),
)
],
),
);
} }
} }