changeAvatar static method

Future<String?> changeAvatar()

Warning: Please do not use Completer.

We must use the back data way to get the result if you use the Completer will always waiting when not select picture and use system back event and it will be makes ButtonController.to.run error.

Implementation

static Future<String?> changeAvatar() async {
  return showModalBottomSheet(
    context: Get.context!,
    builder: (BuildContext context) {
      return SafeArea(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            ListTile(
              leading: const Icon(Icons.photo_library),
              title: Text('Select from Gallery'.tr),
              onTap: () async {
                // Logic to select image from gallery
                final String? result = await pickImage(ImageSource.gallery);
                Get.back(result: result);
              },
            ),
            ListTile(
              leading: const Icon(Icons.camera),
              title: Text('Open Camera'.tr),
              onTap: () async {
                // Logic to open camera
                final String? result = await pickImage(ImageSource.camera);
                Get.back(result: result);
              },
            ),
          ],
        ),
      );
    },
  );
}