Files
breez-sdk-liquid/packages/flutter/example/lib/routes/home/widgets/balance.dart
Erdem Yerebasmaz 015fb1f307 Bug fixes & improvements on Flutter plugin example app (#359)
* Remove unneeded resource files from iOS Project

* Remove breez_liquid_sdk.h
* Remove outdated method to enforce bundling on AppDelegate

* Add NSCameraUsageDescription to be able to scan QR codes on example app

* Do not show "No Balance" text when balance is 0

* Wait for reconnect attempt on startup

* Add a cancel button to mobile scanner

* Bound size of QR image view

* Reverse the payment list
2024-07-08 12:38:38 +03:00

53 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_breez_liquid/flutter_breez_liquid.dart';
class Balance extends StatelessWidget {
final Stream<GetInfoResponse> walletInfoStream;
const Balance({super.key, required this.walletInfoStream});
@override
Widget build(BuildContext context) {
return StreamBuilder<GetInfoResponse>(
stream: walletInfoStream,
builder: (context, walletInfoSnapshot) {
if (walletInfoSnapshot.hasError) {
return Center(child: Text('Error: ${walletInfoSnapshot.error}'));
}
if (!walletInfoSnapshot.hasData) {
return const Center(child: Text('Loading...'));
}
final walletInfo = walletInfoSnapshot.data!;
return Center(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"${walletInfo.balanceSat} sats",
style: Theme.of(context).textTheme.headlineLarge?.copyWith(color: Colors.blue),
),
if (walletInfo.pendingReceiveSat != BigInt.zero) ...[
Text(
"Pending Receive: ${walletInfo.pendingReceiveSat} sats",
style: Theme.of(context).textTheme.labelSmall?.copyWith(color: Colors.blueGrey),
),
],
if (walletInfo.pendingSendSat != BigInt.zero) ...[
Text(
"Pending Send: ${walletInfo.pendingSendSat} sats",
style: Theme.of(context).textTheme.labelSmall?.copyWith(color: Colors.blueGrey),
),
],
],
),
);
},
);
}
}