checkLinkChecksum static method

void checkLinkChecksum(
  1. String libName,
  2. String expectedChecksum,
  3. String readChecksum()
)

Implementation

static void checkLinkChecksum(
  String libName,
  String expectedChecksum,
  String Function() readChecksum,
) {
  late final String actual;
  try {
    actual = readChecksum();
  } catch (error) {
    throw StateError(
      '$libName: Nitro bridge checksum check failed. Run `nitrogen generate` '
      'and rebuild the WASM module (web/build_web.sh) so the generated Dart '
      'and WASM bridge come from the same generation. Details: $error',
    );
  }
  if (actual != expectedChecksum) {
    throw StateError(
      '$libName: Nitro bridge checksum mismatch. Dart expects '
      '$expectedChecksum but the WASM bridge reports $actual. Run '
      '`nitrogen generate`, rebuild the WASM module (web/build_web.sh), and '
      'hot-restart the app.',
    );
  }
}