mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-22 08:24:21 +01:00
Update example app on Flutter plugin (#220)
* Update example app on Flutter plugin * Expose `empty_wallet_cache` through Dart bindings (#224)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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...'));
|
||||
}
|
||||
|
||||
if (walletInfoSnapshot.requireData.balanceSat.isNaN) {
|
||||
return const Center(child: Text('No balance.'));
|
||||
}
|
||||
final walletInfo = walletInfoSnapshot.data!;
|
||||
|
||||
return Center(
|
||||
child: Text(
|
||||
"${walletInfo.balanceSat} sats",
|
||||
style: Theme.of(context).textTheme.headlineLarge?.copyWith(color: Colors.blue),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user