Compare commits
No commits in common. "laba_3" and "master" have entirely different histories.
157
lib/main.dart
157
lib/main.dart
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -11,12 +13,11 @@ class MyApp extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Flutter Demo',
|
title: 'Flutter Demo',
|
||||||
debugShowCheckedModeBanner: false,
|
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.white),
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.black),
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
),
|
),
|
||||||
home: const MyHomePage(title: 'Блохин Дмитрий Алексеевич'),
|
home: const MyHomePage(title: 'Flutter rocks!'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -24,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
|
||||||
@ -31,138 +34,48 @@ class MyHomePage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
|
int _counter = 0;
|
||||||
|
Color _color = Colors.green;
|
||||||
|
|
||||||
|
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 = [
|
|
||||||
const _CardData(
|
|
||||||
'Freeze',
|
|
||||||
descriptionText: 'lol',
|
|
||||||
imageUrl: 'https://steamuserimages-a.akamaihd.net/ugc/974353381258701515/67DFC214C7166FAECF380BFACC10976AA2D86D1D/?imw=512&imh=512&ima=fit&impolicy=Letterbox&imcolor=%23000000&letterbox=true',
|
|
||||||
),
|
|
||||||
const _CardData(
|
|
||||||
'Hi',
|
|
||||||
descriptionText: 'aboba',
|
|
||||||
icon: Icons.abc_rounded,
|
|
||||||
imageUrl: 'https://i.pinimg.com/736x/c1/43/f8/c143f8b663bc1f6ba4e0d63fe3295bc3.jpg',
|
|
||||||
),
|
|
||||||
const _CardData(
|
|
||||||
'SUI',
|
|
||||||
descriptionText: 'Portugal',
|
|
||||||
icon: Icons.portrait,
|
|
||||||
imageUrl: 'https://us-tuna-sounds-images.voicemod.net/1871fd78-7359-4b9e-8e65-957cc1d35de5-1692182201559.jpg',
|
|
||||||
),
|
|
||||||
];
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: Colors.deepPurple,
|
backgroundColor: _color,
|
||||||
title: Text(widget.title),
|
title: Text(widget.title),
|
||||||
),
|
),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: data.map((e) => _Card.fromData(e)).toList(),
|
children: <Widget>[
|
||||||
),
|
const Text(
|
||||||
),
|
'You have pushed the button this many times:',
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CardData {
|
|
||||||
final String text;
|
|
||||||
final String descriptionText;
|
|
||||||
final IconData icon;
|
|
||||||
final String? imageUrl;
|
|
||||||
|
|
||||||
const _CardData(
|
|
||||||
this.text, {
|
|
||||||
required this.descriptionText,
|
|
||||||
this.icon = Icons.add_ic_call,
|
|
||||||
this.imageUrl,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
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.greenAccent,
|
|
||||||
borderRadius: BorderRadius.circular(15),
|
|
||||||
border: Border.all(
|
|
||||||
color: Colors.black,
|
|
||||||
width: 2,
|
|
||||||
),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.grey.withOpacity(.5),
|
|
||||||
spreadRadius: 4,
|
|
||||||
offset: const Offset(0, 5),
|
|
||||||
blurRadius: 8,
|
|
||||||
)
|
|
||||||
]
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(15),
|
|
||||||
child: SizedBox(
|
|
||||||
height: 140,
|
|
||||||
width: 100,
|
|
||||||
child: Image.network(
|
|
||||||
imageUrl ?? '',
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
errorBuilder: (_, __, ___) => const Placeholder(),
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
Flexible(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 3.0),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
text,
|
|
||||||
style: Theme.of(context).textTheme.headlineLarge,
|
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
descriptionText,
|
'$_counter',
|
||||||
style: Theme.of(context).textTheme.bodyLarge,
|
style: Theme.of(context).textTheme.headlineMedium,
|
||||||
)
|
),
|
||||||
|
if (_counter > 10)
|
||||||
|
Text(
|
||||||
|
'Why are you clicking?',
|
||||||
|
style: Theme.of(context).textTheme.headlineMedium,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
floatingActionButton: FloatingActionButton(
|
||||||
Padding(
|
onPressed: _incrementCounter,
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
backgroundColor: _color,
|
||||||
child: Icon(icon),
|
tooltip: 'Increment',
|
||||||
),
|
child: const Icon(Icons.add),
|
||||||
],
|
), );
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user