Getting Started

This SDK leverages Rownd’s native iOS and Android SDKs to provide a simple interface for Flutter developers to add Rownd to their apps.

Install

Begin by depending on rownd_flutter_plugin in your pubspec.yaml:

name: my_app

...

dependencies:
    rownd_flutter_plugin: ^1.2.3

If you don’t have one already, be sure to obtain an app key from the Rownd dashboard for use in the next step.

Configure

Next, instantiate the Rownd plugin and call Rownd.configure(YOUR_APP_KEY) within your application wherever you do most of your app’s initialization.

Here’s an example:

import 'package:flutter/services.dart';

import 'package:rownd_flutter_plugin/rownd.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  final _rownd = RowndPlugin();

  
  void initState() {
    super.initState();

    _rownd.configure("REPLACE_WITH_YOUR_APP_KEY");
  }

Usage

Now you’re ready to use Rownd in your app. The plugin provides a simple interface for checking the current user’s authentication status, signing in and out, and getting the current user’s profile.

A basic sign-in example might look like this:

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:rownd_flutter_plugin/rownd.dart';
import 'package:rownd_flutter_plugin/rownd_platform_interface.dart';
import 'package:rownd_flutter_plugin/state/global_state.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _rownd = RowndPlugin();

  
  void initState() {
    super.initState();

    _rownd.configure("REPLACE_WITH_YOUR_APP_KEY");
  }

  
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
        create: (_) => _rownd.state(),
        child: MaterialApp(
          home: Scaffold(
            appBar: AppBar(
              title: const Text('My example app'),
            ),
            body: Column(children: [
              Center(child: Text('Welcome to my example app!')),
              Consumer<GlobalStateNotifier>(
                builder: (_, rownd, __) => ElevatedButton(
                    onPressed: () {
                      if (rownd.state.auth?.isAuthenticated ?? false) {
                        _rownd.signOut();
                      } else {
                        RowndSignInOptions signInOpts = RowndSignInOptions();
                        signInOpts.postSignInRedirect =
                            "https://deeplink.myapp.com";
                        _rownd.requestSignIn(signInOpts);
                      }
                    },
                    child: Text((rownd.state.auth?.isAuthenticated ?? false)
                        ? 'Sign out'
                        : 'Sign in')),
              ),
            ]),
          ),
        ));
  }
}

Let’s review what’s happening here:

First, we configure Rownd with our app key as before. Then, when building our UI structure, we wrap the entire app in a ChangeNotifierProvider that provides the GlobalStateNotifier object to all of our widgets. This object is a ChangeNotifier that notifies its listeners whenever the Rownd state changes. We can use this object to listen for changes to the user’s authentication status and update our UI accordingly.

When we need access to the Rownd state, we can use the Consumer widget to listen for changes to the GlobalStateNotifier object. The Consumer widget will rebuild its child whenever the GlobalStateNotifier object notifies its listeners. In this example, we use the Consumer widget to build a button that will sign the user in or out depending on their current authentication status.

Platform-specific configuration

There are a couple of configuration settings that must be applied to the platform-specific code for your app in order for Rownd to work properly.

Android

  1. Set your app’s targetSdkVersion to 32 or higher in your app’s build.gradle file.

  2. Set your app’s minSdkVersion to 26 or higher in your app’s build.gradle file. Rownd currently does not support an API version lower than 26.

  3. Ensure any Android activities (like MainActivity) subclass FlutterFragmentActivity instead of FlutterActivity. If you’re using the default MainActivity generated by Flutter, you can simply change the superclass to FlutterFragmentActivity like this:

class MainActivity: FlutterFragmentActivity() {}
  1. Check and update your ProGuard config using the rules from our Android SDK.

API

configure(String appKey)

Configures the Rownd plugin with your app key. This must be called before any other methods.

requestSignIn(RowndSignInHint hint, RowndSignInOptions options)

Requests that the user sign in. Both options and hint parameters are optional.

RowndSignInHint

Requests a sign-in, but with a specific authentication provider (e.g., Sign in with Apple). Rownd treats this information as a hint. If the specified authentication provider is enabled within your Rownd app configuration, it will be honored. If not, Rownd will fall back to the default flow.

Supported values:

  • RowndSignInHint.appleId - Prompt user to sign in with their Apple ID
  • RowndSignInHint.google - Prompt user to sign in with their Google account
  • RowndSignInHint.passkey - Prompt user to sign in with a passkey if they’ve previously set one up

RowndSignInOptions

PropertyTypeDescription
postSignInRedirect (not recommended)StringIf you’ve followed the steps to enable Android App Links, the redirect will be handled automatically. When the user completes the authentication challenge via email or SMS, they’ll be redirected to the URL set for postSignInRedirect. If this is an Android App Link, it will redirect the user back to your app.
intentStringThis option applies only when you have opted to split the sign-up/sign-in flow via the Rownd dashboard. Valid values are .SignIn or .SignUp. If you don’t set this value, the user will be presented with the unified sign-in/sign-up flow. Please reach out to support@rownd.io to enable.

signOut()

Signs the user out.

manageAccount()

Displays the current user’s profile information, allowing them to update it.

state()

Returns a GlobalStateNotifier object that can be used to listen for changes to the Rownd state.

GlobalStateNotifier

The GlobalStateNotifier object is a ChangeNotifier that notifies its listeners whenever the Rownd state changes. It provides the following properties:

PropertyTypeDescription
authRowndAuthStateThe current user’s authentication state.
userRowndUserThe current user’s profile.