Skip to content

Commit db8ddf5

Browse files
committed
[firebase_functions] Add Firebase Cloud Functions plugin
1 parent fa24af4 commit db8ddf5

20 files changed

+488
-0
lines changed

.github/labeler.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
- packages/device_info_plus/**/*
1212
"p: firebase_core":
1313
- packages/firebase_core/**/*
14+
"p: firebase_functions":
15+
- packages/firebase_functions/**/*
1416
"p: flutter_app_badger":
1517
- packages/flutter_app_badger/**/*
1618
"p: flutter_secure_storage":

.github/recipe.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ plugins:
2727
google_sign_in: []
2828
image_picker: []
2929
firebase_core: []
30+
firebase_functions: []
3031
tizen_log: []
3132
tizen_notification: []
3233
wearable_rotary: []

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The _"non-endorsed"_ status means that the plugin is not endorsed by the origina
2020
| [**connectivity_plus_tizen**](packages/connectivity_plus) | [connectivity_plus](https://github.com/fluttercommunity/plus_plugins/tree/main/packages/connectivity_plus) (1st-party) | [![pub package](https://img.shields.io/pub/v/connectivity_plus_tizen.svg)](https://pub.dev/packages/connectivity_plus_tizen) | No |
2121
| [**device_info_plus_tizen**](packages/device_info_plus) | [device_info_plus](https://github.com/fluttercommunity/plus_plugins/tree/main/packages/device_info_plus) (1st-party) | [![pub package](https://img.shields.io/pub/v/device_info_plus_tizen.svg)](https://pub.dev/packages/device_info_plus_tizen) | No |
2222
| [**firebase_core_tizen**](packages/firebase_core) | [firebase_core](https://github.com/firebase/flutterfire/tree/master/packages/firebase_core) | [![pub package](https://img.shields.io/pub/v/firebase_core_tizen.svg)](https://pub.dev/packages/firebase_core_tizen) | No |
23+
| [**firebase_functions_tizen**](packages/firebase_functions) | [firebase_functions](https://github.com/firebase/flutterfire/tree/master/packages/cloud_functions) | [![pub package](https://img.shields.io/pub/v/firebase_functions_tizen.svg)](https://pub.dev/packages/firebase_functions_tizen) | No |
2324
| [**flutter_app_badger_tizen**](packages/flutter_app_badger) | [flutter_app_badger](https://github.com/g123k/flutter_app_badger) (3rd-party) | [![pub package](https://img.shields.io/pub/v/flutter_app_badger_tizen.svg)](https://pub.dev/packages/flutter_app_badger_tizen) | No |
2425
| [**flutter_secure_storage_tizen**](packages/flutter_secure_storage) | [flutter_secure_storage](https://github.com/mogol/flutter_secure_storage) (3rd-party) | [![pub package](https://img.shields.io/pub/v/flutter_secure_storage_tizen.svg)](https://pub.dev/packages/flutter_secure_storage_tizen) | No |
2526
| [**flutter_tts_tizen**](packages/flutter_tts) | [flutter_tts](https://github.com/dlutton/flutter_tts) (3rd-party) | [![pub package](https://img.shields.io/pub/v/flutter_tts_tizen.svg)](https://pub.dev/packages/flutter_tts_tizen) | No |
@@ -61,6 +62,7 @@ The _"non-endorsed"_ status means that the plugin is not endorsed by the origina
6162
| [**connectivity_plus_tizen**](packages/connectivity_plus) | 4.0 | ✔️ | ⚠️ | ✔️ | ✔️ | Returns incorrect connection status |
6263
| [**device_info_plus_tizen**](packages/device_info_plus) | 4.0 | ✔️ | ✔️ | ✔️ | ✔️ |
6364
| [**firebase_core**](packages/firebase_core) | 4.0 | ✔️ | ✔️ | ✔️ | ✔️ |
65+
| [**firebase_functions**](packages/firebase_functions) | 4.0 | ✔️ | ✔️ | ✔️ | ✔️ |
6466
| [**flutter_app_badger_tizen**](packages/flutter_app_badger) | 4.0 | ✔️ | ✔️ ||| API not supported |
6567
| [**flutter_secure_storage_tizen**](packages/flutter_secure_storage) | 4.0 | ✔️ | ✔️ | ✔️ | ✔️ |
6668
| [**flutter_tts_tizen**](packages/flutter_tts) | 4.0 | ✔️ | ✔️ | ✔️ | ✔️ |
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26+
/pubspec.lock
27+
**/doc/api/
28+
.dart_tool/
29+
.packages
30+
build/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.1.0
2+
3+
* Initial release.

packages/firebase_functions/LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD-3-Clause
2+
------------
3+
4+
Copyright (c) 2016-present Invertase Limited <[email protected]> & Contributors
5+
6+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11+
12+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15+
16+
17+
Creative Commons Attribution 3.0 License
18+
----------------------------------------
19+
20+
Copyright (c) 2016-present Invertase Limited <[email protected]> & Contributors
21+
22+
Documentation and other instructional materials provided for this project
23+
(including on a separate documentation repository or it's documentation website) are
24+
licensed under the Creative Commons Attribution 3.0 License. Code samples/blocks
25+
contained therein are licensed under the BSD-3-Clause License (the "License"), as above.
26+
27+
You may obtain a copy of the Creative Commons Attribution 3.0 License at
28+
29+
https://creativecommons.org/licenses/by/3.0/

packages/firebase_functions/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# firebase_functions_tizen
2+
3+
A new Flutter plugin project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter
8+
[plug-in package](https://flutter.dev/developing-packages/),
9+
a specialized package that includes platform-specific implementation code for
10+
Android and/or iOS.
11+
12+
For help getting started with Flutter development, view the
13+
[online documentation](https://flutter.dev/docs), which offers tutorials,
14+
samples, guidance on mobile development, and a full API reference.
15+
16+
The plugin project was generated without specifying the `--platforms` flag, no platforms are currently supported.
17+
To add platforms, run `flutter create -t plugin --platforms <platforms> .` in this directory.
18+
You can also find a detailed instruction on how to add platforms in the `pubspec.yaml` at https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
# Additional information about this file can be found at
4+
# https://dart.dev/guides/language/analysis-options
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
**/ios/Flutter/.last_build_id
26+
.dart_tool/
27+
.flutter-plugins
28+
.flutter-plugins-dependencies
29+
.packages
30+
.pub-cache/
31+
.pub/
32+
/build/
33+
34+
# Web related
35+
lib/generated_plugin_registrant.dart
36+
37+
# Symbolication related
38+
app.*.symbols
39+
40+
# Obfuscation related
41+
app.*.map.json
42+
43+
# Android Studio will place build artifacts here
44+
/android/app/debug
45+
/android/app/profile
46+
/android/app/release
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# example
2+
3+
A new Flutter project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13+
14+
For help getting started with Flutter, view our
15+
[online documentation](https://flutter.dev/docs), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// ignore_for_file: require_trailing_commas, public_member_api_docs, library_private_types_in_public_api
2+
// Copyright 2019 The Chromium Authors. All rights reserved.
3+
// Use of this source code is governed by a BSD-style license that can be
4+
// found in the LICENSE file.
5+
6+
import 'dart:core';
7+
8+
import 'package:cloud_functions/cloud_functions.dart';
9+
import 'package:firebase_core/firebase_core.dart';
10+
import 'package:flutter/material.dart';
11+
12+
FirebaseOptions get firebaseOptions => const FirebaseOptions(
13+
apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0',
14+
authDomain: 'react-native-firebase-testing.firebaseapp.com',
15+
databaseURL: 'https://react-native-firebase-testing.firebaseio.com',
16+
projectId: 'react-native-firebase-testing',
17+
storageBucket: 'react-native-firebase-testing.appspot.com',
18+
messagingSenderId: '448618578101',
19+
appId: '1:448618578101:web:0b650370bb29e29cac3efc',
20+
measurementId: 'G-F79DJ0VFGS',
21+
);
22+
23+
late FirebaseFunctions functions;
24+
25+
Future<void> main() async {
26+
WidgetsFlutterBinding.ensureInitialized();
27+
await Firebase.initializeApp(options: firebaseOptions);
28+
functions = FirebaseFunctions.instance
29+
..useFunctionsEmulator('localhost', 5001);
30+
runApp(MyApp());
31+
}
32+
33+
class MyApp extends StatefulWidget {
34+
MyApp({Key? key}) : super(key: key);
35+
@override
36+
_MyAppState createState() => _MyAppState();
37+
}
38+
39+
class _MyAppState extends State<MyApp> {
40+
List fruit = [];
41+
42+
@override
43+
void initState() {
44+
super.initState();
45+
}
46+
47+
@override
48+
Widget build(BuildContext context) {
49+
return MaterialApp(
50+
home: Scaffold(
51+
appBar: AppBar(
52+
title: const Text('Firebase Functions Example'),
53+
),
54+
body: Center(
55+
child: ListView.builder(
56+
itemCount: fruit.length,
57+
itemBuilder: (context, index) {
58+
return ListTile(
59+
title: Text('${fruit[index]}'),
60+
);
61+
})),
62+
floatingActionButton: Builder(
63+
builder: (context) => FloatingActionButton.extended(
64+
onPressed: () async {
65+
// See index.js in the functions folder for the example function we
66+
// are using for this example
67+
final callable = functions.httpsCallable('listFruit',
68+
options: HttpsCallableOptions(
69+
timeout: const Duration(seconds: 5)));
70+
71+
await callable().then((v) {
72+
setState(() {
73+
fruit.clear();
74+
// ignore: avoid_dynamic_calls
75+
v.data.forEach((f) {
76+
fruit.add(f);
77+
});
78+
});
79+
}).catchError((e) {
80+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
81+
content: Text('ERROR: $e'),
82+
));
83+
});
84+
},
85+
label: const Text('Call Function'),
86+
icon: const Icon(Icons.cloud),
87+
backgroundColor: Colors.deepOrange,
88+
),
89+
),
90+
),
91+
);
92+
}
93+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: firebase_functions_tizen_example
2+
description: An example application demonstrating calls to Firebase Functions.
3+
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
4+
5+
version: 1.0.0
6+
7+
environment:
8+
sdk: ">=2.12.0 <3.0.0"
9+
10+
dependencies:
11+
cloud_functions:
12+
firebase_core:
13+
firebase_core_tizen:
14+
path: ../../firebase_core
15+
firebase_functions_tizen:
16+
path: ../
17+
flutter:
18+
sdk: flutter
19+
20+
flutter:
21+
uses-material-design: true
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
flutter/
2+
.vs/
3+
*.user
4+
bin/
5+
obj/
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Tizen.Flutter.Embedding;
2+
3+
namespace Runner
4+
{
5+
public class App : FlutterApplication
6+
{
7+
protected override void OnCreate()
8+
{
9+
base.OnCreate();
10+
11+
GeneratedPluginRegistrant.RegisterPlugins(this);
12+
}
13+
14+
static void Main(string[] args)
15+
{
16+
var app = new App();
17+
app.Run(args);
18+
}
19+
}
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Tizen.NET.Sdk/1.1.7">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>tizen40</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<ProjectReference Include="$(FlutterEmbeddingPath)" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<FlutterEphemeral Include="flutter\ephemeral\**\*" />
14+
<TizenTpkUserIncludeFiles Include="@(FlutterEphemeral)">
15+
<TizenTpkSubDir>%(RecursiveDir)</TizenTpkSubDir>
16+
</TizenTpkUserIncludeFiles>
17+
</ItemGroup>
18+
19+
</Project>
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="org.tizen.firebase_functions_tizen_example" version="1.0.0" api-version="4.0" xmlns="http://tizen.org/ns/packages">
3+
<profile name="common"/>
4+
<ui-application appid="org.tizen.firebase_functions_tizen_example" exec="Runner.dll" type="dotnet" multiple="false" nodisplay="false" taskmanage="true">
5+
<label>firebase_functions_tizen_example</label>
6+
<icon>ic_launcher.png</icon>
7+
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true"/>
8+
</ui-application>
9+
<tv-info api-version="8.8.0">
10+
<infolink>T-INFOLINK2021-1000</infolink>
11+
</tv-info>
12+
<feature name="http://tizen.org/feature/screen.size.all"/>
13+
<privileges>
14+
<privilege>http://tizen.org/privilege/internet</privilege>
15+
</privileges>
16+
</manifest>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// ignore_for_file: require_trailing_commas
2+
3+
import 'package:cloud_functions/cloud_functions.dart';
4+
import 'package:firebase_core_dart/firebase_core_dart.dart' as core_dart;
5+
import 'package:firebase_functions_dart/firebase_functions_dart.dart'
6+
as functions_dart;
7+
8+
/// Given a [FirebaseApp], a [core_dart.FirebaseApp] is returned.
9+
core_dart.FirebaseApp app([String? name]) {
10+
return name != null ? core_dart.Firebase.app(name) : core_dart.Firebase.app();
11+
}
12+
13+
/// Given a dart error, a [FirebaseFunctionsException] is returned.
14+
FirebaseFunctionsException convertFirebaseFunctionsException(
15+
functions_dart.FirebaseFunctionsException exception,
16+
[StackTrace? stackTrace]) {
17+
return FirebaseFunctionsException(
18+
code: exception.code,
19+
message: exception.message!,
20+
stackTrace: stackTrace,
21+
details: exception.details,
22+
);
23+
}

0 commit comments

Comments
 (0)