Feat: add pages and navigation between them; random mass
This commit is contained in:
43
lib/pages/lose_room.dart
Normal file
43
lib/pages/lose_room.dart
Normal 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()),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user