делаю лаб 3

This commit is contained in:
ujijrujijr 2024-10-03 00:05:26 +04:00
parent 83178515c5
commit e97a025ea6

View File

@ -32,14 +32,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(
@ -47,26 +39,81 @@ 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 GameWidget(),
);
}
}
class GameWidget extends StatelessWidget {
const GameWidget({super.key});
@override
Widget build(BuildContext context) {
return Center(
child: SingleChildScrollView(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: [
const Text( _GameCard(name: 'Late Shift', price: 399,),
'You have pushed the button this many times:', ],
)
)
);
}
}
class _GameCard extends StatelessWidget {
final String name;
final int price;
// final GameType type;
// final String? description;
//для image можно задать default значение (через = в констркуторе)
// final String image;
const _GameCard({
super.key, required this.name, required this.price,
});
// const _GameCard({
// super.key, required this.name, required this.price, required this.type, this.description, required this.image,
// });
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.only(top: 16),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.lightBlue,
borderRadius: BorderRadius.circular(5),
), ),
child:
//ПЫТАЕТСЯ РАСТЯНУТЬСЯ НА ВЕСЬ ЭКРАН, ИСПРАВИТЬ
Row(
children: [
//ЗДЕСЬ ДО СТОЛБЦА БУДЕТ ФОТО (ОНО ДОЛЖНО БЫТЬ СЛЕВА)
Column(
children: [
//название игры
Text( Text(
'$_counter', name,
style: Theme.of(context).textTheme.headlineMedium, style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
//цена игры
Text(
price.toString()+' руб.',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
), ),
], ],
), ),
), ],
floatingActionButton: FloatingActionButton( ));
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
} }
} }