3 Commits
master ... lab3

Author SHA1 Message Date
02001b72e7 ну короче как есть 2024-10-28 23:09:09 +04:00
366a3bd098 lab3 2024-10-25 21:04:02 +04:00
50aed4ee3a initial lab3 2024-10-25 18:23:09 +04:00

View File

@@ -7,12 +7,12 @@ void main() {
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Барсуков Павел ПИбд-31'),
@@ -22,45 +22,111 @@ class MyApp extends StatelessWidget {
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++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xFFb6e0b8),
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
shape: const Border(
bottom: BorderSide(
color: Colors.black87,
width: 3
)
),
backgroundColor: Colors.lightGreen,
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,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), );
body: const MyWidget(),
);
}
}
class MyWidget extends StatelessWidget {
const MyWidget({super.key});
@override
Widget build(BuildContext context) {
final data = [
_CardData("Get Griddy", "https://fortnite.gg/img/items/4674/icon.png?3"),
_CardData("Take The L", "https://fortnite.gg/img/items/4032/icon.png?2"),
_CardData("Lil' Bounce", "https://fortnite.gg/img/items/4904/icon.png?2"),
_CardData("Infectious", "https://fortnite.gg/img/items/3840/icon.png?2"),
];
return Center(
child: SingleChildScrollView(
child: Column(
children: data.map((e) => _Card.fromData(e)).toList(),
),
),
);
}
}
class _Card extends StatelessWidget {
final String text;
final String? image;
const _Card(this.text, this.image);
factory _Card.fromData(_CardData data) => _Card(
data.text, data.image
);
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.all(16),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.lightGreen,
border: Border.all(
color: Colors.black87,
width: 3
),
borderRadius: BorderRadius.circular(20)),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Flexible(
child: SizedBox(
height: 140,
width: 100,
child: Image.network(
image ?? '',
fit: BoxFit.cover,
errorBuilder: (_, __, ___) => const Placeholder(),
),
),
),
Expanded(
child:
Padding(
padding: const EdgeInsets.only(left: 16),
child: Text(
text,
style: Theme.of(context).textTheme.headlineLarge,
),
),
)
],
),
);
}
}
class _CardData{
final String text;
final String? image;
_CardData(this.text, this.image);
}