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

outdated

A flutter plugin built to use Amazon's official Login With Amazon platform packages

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:login_with_amazon/login_with_amazon.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

const _scopes = {
  'profile': null,
  'alexa:all': {
    'productID': 'SomeProductId',
    'productInstanceAttributes': {
      'deviceSerialNumber': 'serialNumberHere',
    },
  },
  'dash:replenish': {
    'device_model': 'SomeDeviceModel',
    'serial': 'serialNumberHere',
    'is_test_device': true
  },
};

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  List<Widget> authRespose = [];
  String accessToken = '';
  String logResult = '';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              RaisedButton(
                onPressed: () async {
                  try {
                    final result = await LoginWithAmazon.login(_scopes);
                    setState(() {
                      logResult = result.containsKey("accessToken")
                          ? "Logged In"
                          : "Cancelled";
                      authRespose = result.entries.map((entry) {
                        return Text("${entry.key}: ${entry.value}");
                      }).toList();
                    });
                  } catch (e) {
                    setState(() {
                      logResult = "Cancelled";
                    });
                  }
                },
                child: Text("Login"),
              ),
              RaisedButton(
                onPressed: () async {
                  final result = await LoginWithAmazon.getAccessToken(_scopes);
                  setState(() {
                    accessToken = result;
                  });
                },
                child: Text("Get Access Token"),
              ),
              RaisedButton(
                onPressed: () async {
                  await LoginWithAmazon.logout();
                  setState(() {
                    logResult = 'Logged Out';
                  });
                },
                child: Text("Logout"),
              ),
              Text('LogResult: $logResult'),
              Text('AccessToken: $accessToken'),
              ...authRespose
            ],
          ),
        ),
      ),
    );
  }
}
5
likes
0
pub points
0%
popularity

Publisher

verified publisherweplenish.com

A flutter plugin built to use Amazon's official Login With Amazon platform packages

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on login_with_amazon