Masamune logo

Katana Functions

Follow on Twitter Follow on Threads Maintained with Melos

GitHub Sponsor


[GitHub](https://github.com/mathrunet) | [YouTube](https://www.youtube.com/c/mathrunetchannel) | [Packages](https://pub.dev/publishers/mathru.net/packages) | [Twitter](https://twitter.com/mathru) | [Threads](https://threads.net/@mathrunet) | [LinkedIn](https://www.linkedin.com/in/mathrunet/) | [mathru.net](https://mathru.net)


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.

GitHub Sponsors

Sponsors are always welcome. Thank you for your support!

https://github.com/sponsors/mathrunet

Libraries

katana_functions_firebase
Provides an adapter for use with Firebase Functions. Provides an interface to execute server-side processing in a type-safe manner.