getOrganization method

Future<void> getOrganization(
  1. String id
)

Fetches the organization details based on the ID. id is the organization ID.

Implementation

Future<void> getOrganization(String id) async {
  try {
    final doc = await databases.getDocument(
      databaseId: AppConstants.appwriteDatabaseId,
      collectionId: AppConstants.userCollectionId,
      documentId: id,
    );

    final data = doc.data;
    setState(() {
      organization = Organization.fromMap(data);
      organization!.deviceCode = id;
      isEditOrg = false;
    });
    // setOrg!(organization!);
    setDeviceAssociations(id);
  } catch (e) {
    Fluttertoast.showToast(msg: 'No organization found');
    setState(() => isEditOrg = false);
  }
}