locality_social_cloud_friendlist 1.3.0 copy "locality_social_cloud_friendlist: ^1.3.0" to clipboard
locality_social_cloud_friendlist: ^1.3.0 copied to clipboard

A simple FriendList for FriendsList-Syndication based on Locality Social Cloud. Send, receive and accept FriendRequests.

example/locality_social_cloud_friendlist_example.dart

import 'package:flutter_test/flutter_test.dart';
import 'package:locality_social_cloud/api/locality_social_cloud.dart';
import 'package:locality_social_cloud_friendlist/friend_list.dart';
import 'package:locality_social_cloud_friendlist/friend_list_facade.dart';

class Logger {
  void log(String message) {
    // ADD A PRINT STATEMENT HERE
  }

  void info(String message) {
    log('INFO: $message');
  }

  void error(String message) {
    log('ERROR: $message');
  }

  void debug(String message) {
    log('DEBUG: $message');
  }
}

void main() {
  final Logger logger = Logger(); // Create an instance of the logger

  test('adds one to input values', () async {
    LocalitySocialCloud? localitySocialCloud = await LocalitySocialCloud.up(
        appId: 'YOUR_APP_ID',
        // usually ends with '='; Has NO whitespace at the end.
        appSecret: 'YOUR_APP_SECRET',
        username: "APP_USER_USERNAME",
        password: "APP_USER_PASSWORD",
        onError: (AuthError authError) {
          // HANDLE AUTH ERROR ....
        });

    LoggedInUser loggedInUser = localitySocialCloud!.loggedInUser!;
    LocalityUser user1 = loggedInUser.user;

    LocalityUser user2 = (await LocalitySocialCloud.auth('testuser2', 'pwd2'))
        .loggedInUser!
        .user;

    FriendList friendList1 = FriendListFacade.getFriendListOfUser(user1);
    FriendList friendList2 = FriendListFacade.getFriendListOfUser(user2);

    friendList1.addListener(() {
      logger.info(
          "These are all friends in the friendlist 1 after one throttled UI update: ");
      for (var element in friendList1.friendRequests) {
        logger.info(element.toString());
      }
    });

    friendList2.addListener(() {
      logger.info(
          "These are all friends in the friendlist 2 after one throttled UI update: ");
      for (var element in friendList2.friendRequests) {
        logger.info(element.toString());
      }
    });

    friendList1.timeline.whenSynchronized(() {
      logger.info("The timelines are now synchronized of friendlist1.");
      logger.info(
          "Now we know whether the target user is our friend and we can send him a friend request if he is not.");
      if (!friendList1.sentFriendRequestToUser(user2)) {
        logger.info("Sending friend request ... ");
        FriendListFacade.sendFriendRequest(user1, user2);
      }
    });

    friendList2.timeline.whenSynchronized(() {
      logger.info("The timelines are now synchronized of friendlist2.");
      logger.info(
          "Now we know whether the target user is our friend and we can send him a friend request if he is not.");
      if (!friendList2.sentFriendRequestToUser(user1)) {
        logger.info("Sending friend request ... ");
        FriendListFacade.sendFriendRequest(user2, user1);
      }
    });

    await Future.delayed(const Duration(milliseconds: 3000));
  });
}
4
likes
160
points
36
downloads

Documentation

API reference

Publisher

verified publisherlocality.media

Weekly Downloads

A simple FriendList for FriendsList-Syndication based on Locality Social Cloud. Send, receive and accept FriendRequests.

Homepage
Repository
View/report issues

License

MIT (license)

Dependencies

crypto, flutter, locality_social_cloud

More

Packages that depend on locality_social_cloud_friendlist