amazon_cognito_identity_dart_2 0.1.25+1 copy "amazon_cognito_identity_dart_2: ^0.1.25+1" to clipboard
amazon_cognito_identity_dart_2: ^0.1.25+1 copied to clipboard

outdated

Unofficial Amazon Cognito Identity Provider Dart SDK, to add user sign-up / sign-in to your mobile and web apps with AWS Cloud Services. Based on amazon-cognito-identity-dart

example/lib/main.dart

import 'dart:async';
import 'dart:convert';

import 'package:amazon_cognito_identity_dart_2/sig_v4.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:secure_counter/screens/home_screen.dart';

class Counter {
  int count;
  Counter(this.count);

  factory Counter.fromJson(json) {
    return Counter(json['count']);
  }
}

class CounterService {
  AwsSigV4Client awsSigV4Client;
  CounterService(this.awsSigV4Client);

  /// Retrieve user's previous count from Lambda + DynamoDB
  Future<Counter> getCounter() async {
    final signedRequest =
        SigV4Request(awsSigV4Client, method: 'GET', path: '/counter');
    final response =
        await http.get(signedRequest.url, headers: signedRequest.headers);
    return Counter.fromJson(json.decode(response.body));
  }

  /// Increment user's count in DynamoDB
  Future<Counter> incrementCounter() async {
    final signedRequest =
        SigV4Request(awsSigV4Client, method: 'PUT', path: '/counter');
    final response =
        await http.put(signedRequest.url, headers: signedRequest.headers);
    return Counter.fromJson(json.decode(response.body));
  }
}

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

class SecureCounterApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Cognito on Flutter',
      theme: ThemeData(
        primarySwatch: Colors.orange,
      ),
      home: HomePage(title: 'Cognito on Flutter'),
    );
  }
}
193
likes
0
pub points
97%
popularity

Publisher

unverified uploader

Unofficial Amazon Cognito Identity Provider Dart SDK, to add user sign-up / sign-in to your mobile and web apps with AWS Cloud Services. Based on amazon-cognito-identity-dart

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

convert, crypto, http

More

Packages that depend on amazon_cognito_identity_dart_2