scoped method

  1. @override
NativeMemoryStorage scoped(
  1. String scope
)
override

Creates a new NativeStorage instance with the same configuration as this instance, but with the provided scope.

If the current instance already has a scope, the new instance will have a combined scope of both the current and provided scopes.

final parent = NativeStorage(scope: 'parent');
print(parent.scope); // 'parent'

final child = parent.scoped('child');
print(child.scope); // 'parent/child'

If scope begins with a /, it will be treated as an absolute scope and will replace the current scope.

final parent = NativeStorage(scope: 'parent');
print(parent.scope); // 'parent'

final child = parent.scoped('/child');
print(child.scope); // 'child'

Implementation

@override
NativeMemoryStorage scoped(String scope) {
  final newScope = rescope(scope);
  return instances[(namespace, newScope)] ??= NativeMemoryStorage._(
    namespace: namespace,
    scope: newScope,
    storage: _storage,
  );
}