Feat: add pages and navigation between them; random mass

This commit is contained in:
Grail Finder
2025-04-27 08:41:23 +03:00
parent e79b3e691a
commit 374728da45
5 changed files with 165 additions and 24 deletions

43
lib/pages/lose_room.dart Normal file
View File

@ -0,0 +1,43 @@
import 'package:flutter/material.dart';
import 'dart:math';
int randomInRange(int min, int max) {
final random = Random();
return min + random.nextInt(max - min + 1);
}
class LoseRoom extends StatefulWidget {
const LoseRoom({super.key});
@override
State<LoseRoom> createState() => _LoseRoomState();
}
class _LoseRoomState extends State<LoseRoom>{
//vars
int _mass = randomInRange(40, 80);
//methods
void _loseMass(){
setState(() {
_mass -= randomInRange(1, 3);
});
}
// ui
@override
Widget build(BuildContext context){
return Scaffold(
appBar: AppBar(title: Text("Lose Room")),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Current mass:"),
Text(_mass.toString()),
],
),
),
);
}
}