rook_users 0.5.2 copy "rook_users: ^0.5.2" to clipboard
rook_users: ^0.5.2 copied to clipboard

discontinued
PlatformAndroidiOS

Register Health Connect and Apple Health users in ROOK servers.

example/README.md

Example with a dedicated widget #

rook_user_status.dart #

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

class RookUserStatus extends StatefulWidget {
  const RookUserStatus({Key? key}) : super(key: key);

  @override
  State<RookUserStatus> createState() => _RookUserStatusState();
}

class _RookUserStatusState extends State<RookUserStatus> {
  final RookUsersManager manager = RookUsersManager(
    Secrets.rookUrl,
    Secrets.clientUUID,
    Secrets.secretKey,
  );

  bool loading = false;
  bool registered = false;
  RookUser? rookUser;
  String? error;

  @override
  void initState() {
    initialize();

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(10),
      alignment: Alignment.center,
      child: loading
          ? const CircularProgressIndicator()
          : Column(
        children: [
          if (registered)
            Row(
              children: [
                const Icon(Icons.verified_rounded),
                const SizedBox(width: 10),
                Expanded(
                  child: Text(
                    '${rookUser?.type.name.toUpperCase()} USER: ${rookUser?.id} is registered!',
                  ),
                ),
              ],
            ),
          if (!registered) Text('Error: $error'),
          if (!registered) const SizedBox(height: 20),
          if (!registered)
            ElevatedButton(
              onPressed: initialize,
              child: const Text('Try again'),
            ),
        ],
      ),
    );
  }

  void initialize() async {
    setState(() => loading = true);
    try {
      await Future.delayed(const Duration(seconds: 1));

      final user = await manager.registerRookUser(
        Secrets.userID,
        UserType.healthConnect,
      );

      setState(() {
        loading = false;
        registered = true;
        rookUser = user;
        error = null;
      });
    } catch (e) {
      setState(() {
        loading = false;
        registered = false;
        error = 'Error: $e';
      });
    }
  }
}

Example with demo app #

  1. Download the project from our repository.

  2. In the lib folder create a secrets.dart file with a Secrets class and add the following constants:

class Secrets {
  static String rookAuthUrl = 'rookAuthUrl';
  static String userID = 'userID';
  static String clientUUID = 'clientUUID';
  static String secretKey = 'secretKey';
  static String rookUrl = 'rookUrl';
}
  • userID is defined by you, so feel free to use the same ID your app uses to identify it's users.
  1. Run flutter pub get
0
likes
155
points
29
downloads

Publisher

verified publisherrook-connect.com

Weekly Downloads

Register Health Connect and Apple Health users in ROOK servers.

Homepage

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter, flutter_secure_storage, http, jwt_decode, logging, shared_preferences

More

Packages that depend on rook_users