Compare commits
No commits in common. "lab3" and "master" have entirely different histories.
138
lib/main.dart
138
lib/main.dart
@ -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 = [
|
|
||||||
const _CardData(
|
|
||||||
"First",
|
|
||||||
description: "SomeText",
|
|
||||||
),
|
|
||||||
const _CardData(
|
|
||||||
"Second",
|
|
||||||
icon: Icons.gamepad,
|
|
||||||
description: "ManyText",
|
|
||||||
imageUrl: "https://i.pinimg.com/originals/21/73/24/217324138d1bbc91663d4943ebe5de60.jpg",
|
|
||||||
),
|
|
||||||
const _CardData(
|
|
||||||
"Third",
|
|
||||||
icon: Icons.offline_bolt_outlined,
|
|
||||||
description: "Wow >_<",
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: Colors.purple,
|
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 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(
|
Text(
|
||||||
description,
|
'$_counter',
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
style: Theme.of(context).textTheme.headlineMedium,
|
||||||
)
|
),
|
||||||
|
if (_counter > 10)
|
||||||
|
const Text("Why are you doing this?",)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
floatingActionButton: FloatingActionButton(
|
||||||
padding: const EdgeInsets.only(left: 8),
|
onPressed: _incrementCounter,
|
||||||
child: Icon(icon),
|
tooltip: 'Increment',
|
||||||
)
|
child: const Icon(Icons.add),
|
||||||
],
|
), );
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user