acquire method

Future<SfSymbolTexture?> acquire(
  1. SfSymbolConfig config
)

Renders config, or takes a reference to it if it is already rendered.

Returns null if no symbol matches config. Callers that get a texture must release it.

Implementation

Future<SfSymbolTexture?> acquire(SfSymbolConfig config) async {
  final cached = acquireCached(config);
  if (cached != null) return cached;

  // Several widgets asking for the same symbol at once share one render
  // rather than each registering their own texture.
  final pending = _pending[config];
  if (pending != null) {
    final texture = await pending;
    if (texture == null) return null;

    final entry = _entries[config];
    // The render holds a reference until its own caller releases, so the
    // entry cannot have been evicted from under us.
    if (entry == null) return null;
    entry.refCount++;
    _unused.remove(config);
    return texture;
  }

  final render = _render(config);
  _pending[config] = render;
  // _render opens the entry already holding this call's reference.
  return render;
}