verifyNativeVersion static method
void
verifyNativeVersion()
Throws TdVersionMismatchException if the native TDLib isn't the one this package's API was generated for.
Implementation
static void verifyNativeVersion() {
String option(String name) {
final value = execute(GetOption(name: name));
return value is OptionValueString ? value.value : '';
}
final version = option('version');
final commit = option('commit_hash');
// Builds made outside a git checkout report e.g. "GITDIR-NOTFOUND";
// only the version can be checked then.
final knownCommit = RegExp(r'^[0-9a-f]{40}$').hasMatch(commit);
if (version != tdlibVersion ||
(knownCommit && !tdlibCompatibleCommits.contains(commit))) {
throw TdVersionMismatchException(
nativeVersion: version,
nativeCommit: commit,
);
}
}