This commit is contained in:
ValAn 2024-09-25 09:17:26 +04:00
parent 2d27d6a60e
commit a7f60f5c94

View File

@ -30,14 +30,6 @@ class MyHomePage extends StatefulWidget {
} }
class _MyHomePageState extends State<MyHomePage> { class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -45,25 +37,68 @@ class _MyHomePageState extends State<MyHomePage> {
backgroundColor: Theme.of(context).colorScheme.inversePrimary, backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title), title: Text(widget.title),
), ),
body: Center( body: const MyWidget(),
);
}
}
class MyWidget extends StatelessWidget {
const MyWidget({super.key});
@override
Widget build(BuildContext context) {
return const Center(
child: SingleChildScrollView(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: [
const Text( _Card("Hello1", translation: "desc"),
'You have pushed the button this many times:', _Card("Hello1", translation: "desc"),
), _Card("Hello", translation: "desc"),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
], ],
), ),
), ),
floatingActionButton: FloatingActionButton( );
onPressed: _incrementCounter, }
tooltip: 'Increment', }
child: const Icon(Icons.ac_unit_sharp),
), class _Card extends StatelessWidget {
final String word;
final String translation;
final IconData icon;
const _Card(
this.word, {
required this.translation,
this.icon = Icons.abc,
});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(20),
margin: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.amberAccent,
borderRadius: BorderRadius.circular(10),
),
child: Column(
children: [
Text(
word,
style: Theme.of(context).textTheme.headlineLarge,
),
Text(
translation,
style: Theme.of(context).textTheme.bodySmall,
),
Icon(
icon,
size: 50,
)
],
),
); );
} }
} }