fromAsset static method

Future<PaymentConfiguration> fromAsset(
  1. String paymentConfigurationAsset, {
  2. ConfigLoader profileLoader = _defaultProfileLoader,
})

Creates a PaymentConfiguration object wrapped in a Future from a configuration loaded from an external source.

The configuration is referenced in the paymentConfigurationAsset and retrieved with the profileLoader specified. If empty, a default loader is used to get the configuration from the assets folder in the package.

Here's an example of a configuration loaded with a bespoke loader:

Future<Map<String, dynamic>> _fileSystemLoader(String filePath) async =>
    jsonDecode(File(filePath).readAsStringSync());
final config = await PaymentConfiguration.fromAsset('path-to-file.json',
    profileLoader: _fileSystemLoader);

Implementation

static Future<PaymentConfiguration> fromAsset(
    String paymentConfigurationAsset,
    {ConfigLoader profileLoader = _defaultProfileLoader}) async {
  final configuration = await profileLoader(paymentConfigurationAsset);
  return PaymentConfiguration._(configuration);
}