43 lines
867 B
Dart
43 lines
867 B
Dart
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 GainRoom extends StatefulWidget {
|
|
const GainRoom({super.key});
|
|
|
|
@override
|
|
State<GainRoom> createState() => _GainRoomState();
|
|
}
|
|
|
|
|
|
class _GainRoomState extends State<GainRoom>{
|
|
//vars
|
|
int _mass = randomInRange(40, 80);
|
|
//methods
|
|
void _gainMass(){
|
|
setState(() {
|
|
_mass += randomInRange(1, 3);
|
|
});
|
|
}
|
|
//ui
|
|
@override
|
|
Widget build(BuildContext context){
|
|
return Scaffold(
|
|
appBar: AppBar(title: Text("Gain Room")),
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text("Current mass:"),
|
|
Text(_mass.toString()),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |