removeNetwork method

  1. @override
Future<bool> removeNetwork(
  1. String id
)
override

Removes the network id.

Returns false, rather than throwing, when Docker refuses because a container is still attached — that is an expected outcome for a caller like rig prune walking every network it owns, not a failure of the remove call itself. Any other error still throws EngineError.

Implementation

@override
Future<bool> removeNetwork(String id) async {
  calls.add('removeNetwork:$id');
  _FakeNetwork? found;
  for (final n in _networksByName.values) {
    if (n.id == id) {
      found = n;
      break;
    }
  }
  if (found == null) return true; // already gone
  if (found.connectedContainerIds.isNotEmpty) return false;
  _networksByName.remove(found.name);
  return true;
}