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

outdated

Passwordless and OTP-less Authentication for your website. It helps you to authenticate user via their email or phone number.

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> {
  // Sawo configuration object
  var config = {};
  // user payload
  String user;
  void payloadCallback(context, payload) {
    if (payload == null || (payload is String && payload.length == 0)) {
      payload = "Login Failed :(";
    }
    setState(() {
      user = payload;
    });
  }

  void toogleState(typedata, text) => setState(() {
        config[typedata] = text;
      });

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
        TextField(
          onChanged: (text) {
            toogleState("apiKey", text);
          },
          decoration:
              InputDecoration(hintText: 'API Key', labelText: 'API Key'),
        ),
        TextField(
          onChanged: (text) {
            toogleState("secretKey", text);
          },
          decoration:
              InputDecoration(hintText: 'SecretKey', labelText: 'SecretKey'),
        ),
        Text("UserData :- $user"),
        ElevatedButton(
          onPressed: () {
            Sawo(
              apiKey: config["apiKey"],
              secretKey: config["secretKey"],
            ).signIn(
              context: context,
              identifierType: 'email',
              callback: payloadCallback,
            );
          },
          child: Text('Email Login'),
        ),
        ElevatedButton(
          onPressed: () {
            Sawo(
              apiKey: config["apiKey"],
              secretKey: config["secretKey"],
            ).signIn(
              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. It helps you to authenticate user via their email or phone number.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, uuid, webview_flutter

More

Packages that depend on sawo