katana_functions_firebase 1.1.6 katana_functions_firebase: ^1.1.6 copied to clipboard
Provides an adapter for use with Firebase Functions. Provides an interface to execute server-side processing in a type-safe manner. Actual processing on the server side is done by importing a separate adapter.
Katana Functions
[YouTube] | [Packages] | [Twitter] | [LinkedIn]
Adapter plug-ins for server integration such as Cloud Functions for Firebase.
It is possible to work with @mathrunet/masamune to secure client-side implementations.
Installation #
Import the following packages
flutter pub add katana_functions
If you use Cloud Functions for Firebase, import the following packages as well.
flutter pub add katana_functions_firebase
Implementation #
Advance preparation #
Always place the FunctionsAdapterScope
widget near the root of the app.
Pass a FunctionsAdapter such as RuntimeFunctionsAdapter
as the parameter of adapter.
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return FunctionsAdapterScope(
adapter: const RuntimeFunctionsAdapter(),
child: MaterialApp(
home: const FunctionsPage(),
title: "Flutter Demo",
theme: ThemeData(
primarySwatch: Colors.blue,
),
),
);
}
}
Using Functions #
Create a Functions object as shown below and call the corresponding method.
If the corresponding method is not implemented on the server side, an error is returned.
final functions = Functions();
await functions.sendNotification(
title: "Title",
text: "Push Notifications",
target: "TopicName",
);
FunctionsAdapter #
The following FunctionsAdapter
is available
RuntimeFunctionsAdapter
:FunctionsAdapter that completes without server processing and without error. available as a stub.FirebaseFunctionsAdapter
:FunctionsAdapter for using FirebaseFunctions, available by defining a Function using @mathrunet/mathamune.