validateKey method
Validates the inputted key and throws an error if it is invalid.
@param key The key to be verified.
Implementation
validateKey(String key) {
String? error;
if (key is String == false) {
error = 'key must be a string';
} else if (key.length == 0) {
error = 'key cannot be the empty string';
} else if (1 + _GEOHASH_PRECISION + key.length > 755) {
// Firebase can only stored child paths up to 768 characters
// The child path for this key is at the least: 'i/<geohash>key'
error = 'key is too long to be stored in Firebase';
} else if (key.contains('/[\[\].#\$\/\u0000-\u001F\u007F]/')) {
// Firebase does not allow node keys to contain the following characters
error =
"key cannot contain any of the following characters: . # /\$ ] [ /";
}
if (error != null) {
throw ('Invalid GeoFire key \'' + key + '\': ' + error);
}
}