ValueListenableBuilder(
valueListenable: Hive.box('balance').listenable(),
builder: (context, box, widget) {
return Align(
alignment: Alignment.topCenter,
child: Container(
margin: const EdgeInsets.only(top: 10),
child: ElevatedButton(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
scrollable: true,
title: Container(
alignment: Alignment.center,
child: Text('Jumlah'),
),
content: Padding(
padding: const EdgeInsets.all(5.0),
child: Form(
child: Column(
children: <Widget>[
TextFormField(
controller: balanceController,
decoration: InputDecoration(
labelText: 'Saldo',
icon: Icon(Icons.money_sharp),
),
keyboardType: TextInputType.number,
),
],
),
),
),
actions: [
ElevatedButton(
child: Text("Submit"),
onPressed: () {
balanceModel.putAt(
0,
Balance(
value: int.parse(balanceController.text),
),
);
Navigator.pop(context);
},
style: ElevatedButton.styleFrom(
primary: kBlueColor,
shadowColor: kTransparentColor,
fixedSize: Size(maxWidth * 9 / 10, 50),
),
),
],
);
},
);
},
child: Text(
'Saldo: ${balanceValue.value.toString()}',
style: whiteTextStyle.copyWith(
fontSize: 18,
fontWeight: bold,
),
),
style: ElevatedButton.styleFrom(
primary: kPrimaryColor,
shadowColor: kTransparentColor,
fixedSize: Size(maxWidth * 9 / 10, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
),
),
),
);
},
),