addOrUpdateToken method

Future<void> addOrUpdateToken(
  1. TokenDef token
)

Adds or updates a token definition.

If a token with the same key already exists, its definition is replaced.

Implementation

Future<void> addOrUpdateToken(TokenDef token) async {
  final tokens = [
    ..._config.tokenDefs.where((item) => item.key != token.key),
    token,
  ];

  _config = _copyConfig(_config, tokenDefs: tokens);

  await _storage.save(_config);
  notifyListeners();
}