mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-21 07:54:24 +01:00
Add config to flutter example (#274)
This commit is contained in:
33
packages/flutter/example/lib/utils/config.dart
Normal file
33
packages/flutter/example/lib/utils/config.dart
Normal 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,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user