Add config to flutter example (#274)

This commit is contained in:
Ross Savage
2024-06-03 18:46:19 +02:00
committed by GitHub
parent 04ac2c20e4
commit 0a8f2545db
4 changed files with 42 additions and 9 deletions

View File

@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:flutter_breez_liquid/flutter_breez_liquid.dart';
import 'package:path_provider/path_provider.dart';
Future<Config> getConfig({
Network network = Network.mainnet,
}) async {
debugPrint("Getting default SDK config for network: $network");
final defaultConf = defaultConfig(network: network);
debugPrint("Getting SDK config");
final workingDir = await getApplicationDocumentsDirectory();
return defaultConf.copyWith(
workingDir: workingDir.path,
);
}
extension ConfigCopyWith on Config {
Config copyWith({
String? boltzUrl,
String? electrumUrl,
String? workingDir,
Network? network,
BigInt? paymentTimeoutSec,
}) {
return Config(
boltzUrl: boltzUrl ?? this.boltzUrl,
electrumUrl: electrumUrl ?? this.electrumUrl,
workingDir: workingDir ?? this.workingDir,
network: network ?? this.network,
paymentTimeoutSec: paymentTimeoutSec ?? this.paymentTimeoutSec,
);
}
}