-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Expand file tree
/
Copy pathcloud_functions_web.dart
More file actions
71 lines (57 loc) · 2.57 KB
/
cloud_functions_web.dart
File metadata and controls
71 lines (57 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// ignore_for_file: require_trailing_commas
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:cloud_functions_platform_interface/cloud_functions_platform_interface.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_core_web/firebase_core_web.dart';
import 'package:firebase_core_web/firebase_core_web_interop.dart'
as core_interop;
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
import 'https_callable_web.dart';
import 'interop/functions.dart' as functions_interop;
import 'src/cloud_functions_version.dart';
/// Web implementation of [FirebaseFunctionsPlatform].
class FirebaseFunctionsWeb extends FirebaseFunctionsPlatform {
static const String _libraryName = 'flutter-fire-fn';
/// The entry point for the [FirebaseFunctionsWeb] class.
FirebaseFunctionsWeb({FirebaseApp? app, required String region})
: super(app, region);
/// Stub initializer to allow the [registerWith] to create an instance without
/// registering the web delegates or listeners.
FirebaseFunctionsWeb._()
: _webFunctions = null,
super(null, 'us-central1');
/// Instance of functions from the web plugin
functions_interop.Functions? _webFunctions;
/// Lazily initialize [_webFunctions] on first method call
functions_interop.Functions get _delegate {
return _webFunctions ??= functions_interop.getFunctionsInstance(
core_interop.app(app?.name), region);
}
/// Create the default instance of the [FirebaseFunctionsPlatform] as a [FirebaseFunctionsWeb]
static void registerWith(Registrar registrar) {
FirebaseCoreWeb.registerLibraryVersion(_libraryName, packageVersion);
FirebaseCoreWeb.registerService('functions');
FirebaseFunctionsPlatform.instance = FirebaseFunctionsWeb.instance;
}
/// Returns an instance of [FirebaseFunctionsWeb].
static FirebaseFunctionsWeb get instance {
return FirebaseFunctionsWeb._();
}
@override
FirebaseFunctionsPlatform delegateFor(
{FirebaseApp? app, required String region}) {
return FirebaseFunctionsWeb(app: app, region: region);
}
@override
HttpsCallablePlatform httpsCallable(
String? origin, String name, HttpsCallableOptions options) {
return HttpsCallableWeb(this, _delegate, origin, name, options, null);
}
@override
HttpsCallablePlatform httpsCallableWithUri(
String? origin, Uri uri, HttpsCallableOptions options) {
return HttpsCallableWeb(this, _delegate, origin, null, options, uri);
}
}