close method

  1. @override
void close()

A CronetClient configured with a Future containing a CronetEngine.

This can be useful in circumstances where a non-Future CronetClient is required but you want to configure the CronetClient with a custom CronetEngine. For example:

void main() {
  Client clientFactory() {
    final engine = CronetEngine.build(
        cacheMode: CacheMode.memory, userAgent: 'Book Agent');
    return CronetClient.fromCronetEngineFuture(engine);
  }

  runWithClient(() => runApp(const BookSearchApp()), clientFactory);
}

Implementation

@override
void close() {
  if (!_isClosed && _ownedEngine) {
    _engine?.close();
  }
  _isClosed = true;
}