refFromURL method

DatabaseReference refFromURL(
  1. String url
)

Returns a DatabaseReference representing the location in the Database corresponding to the provided Firebase URL.

Implementation

DatabaseReference refFromURL(String url) {
  if (!url.startsWith('https://')) {
    throw ArgumentError.value(url, 'must be a valid URL', 'url');
  }

  Uri uri = Uri.parse(url);
  String? currentDatabaseUrl = databaseURL ?? app.options.databaseURL;
  if (currentDatabaseUrl != null) {
    if (uri.origin != currentDatabaseUrl) {
      throw ArgumentError.value(
        url,
        'must equal the current FirebaseDatabase instance databaseURL',
        'url',
      );
    }
  }

  if (uri.pathSegments.isNotEmpty) {
    return DatabaseReference._(_delegate.ref(uri.path));
  }
  return DatabaseReference._(_delegate.ref());
}