sawo 0.0.1 copy "sawo: ^0.0.1" to clipboard
sawo: ^0.0.1 copied to clipboard

outdated

Passwordless and OTP-less Authentication for your website.

example/lib/main.dart

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

void main() {
  runApp(MaterialApp(
    title: 'Sawo Login Example',
    home: HomeScreen(),
  ));
}

class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Sawo login example'),
      ),
      body: Center(child: SelectionButton()),
    );
  }
}

class SelectionButton extends StatefulWidget {
  @override
  _SelectionButtonState createState() => _SelectionButtonState();
}

class _SelectionButtonState extends State<SelectionButton> {
  String user;
  Sawo sawo = new Sawo(
    apiKey: "396487cf-d11a-4cf3-8e15-067ce2509b53",
    hostname: "packages.sawolabs.com",
  );

  void payloadCallback(context, payload) {
    setState(() {
      user = payload;
    });
    print(
        "SAWO: success callback called- from the client---++++------------- $payload");

    // After the Selection Screen returns a result, hide any previous snackbars
    // and show the new result.
    Scaffold.of(context)
      ..removeCurrentSnackBar()
      ..showSnackBar(SnackBar(content: Text("$user")));
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
        Text("UserData: $user"),
        ElevatedButton(
          onPressed: () => sawo.singIn(
              context: context,
              identifierType: 'email',
              callback: payloadCallback),
          child: Text('Email Login'),
        ),
        ElevatedButton(
          onPressed: () => sawo.singIn(
              context: context,
              identifierType: 'phone_number_sms',
              callback: payloadCallback),
          child: Text('Phone Login'),
        ),
      ]),
    );
  }
}
8
likes
0
pub points
65%
popularity

Publisher

unverified uploader

Passwordless and OTP-less Authentication for your website.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, uuid, webview_flutter

More

Packages that depend on sawo