如何在通知托盘中显示上传进度条flutter

hmae6n7t  于 2023-03-04  发布在  Flutter
关注(0)|答案(1)|浏览(163)

我正在使用一个需要上传大文件的应用程序。我不想在应用程序中显示进度,我想在通知托盘中显示它,完成后在通知托盘中显示成功,同时上传到Firebase Firestore...
上传的功能..

Future<bool> imageBannerPick(BuildContext context, ImageSource source) async {
  final pickedFile = await picker.pickImage(source: source);
  if (pickedFile == null) {
    return false;
  }
  File image = File(pickedFile.path);

  String uploadString = await uploadingFile(uploadFile: image);
  //storing the string to your profile
  await firestore.collection('users').doc(auth.currentUser?.uid).update({
    'backBannerPicture': uploadString,
  });
  return true;
}
ztyzrc3y

ztyzrc3y1#

static Future<void> showProgressNotification(
      int progress, int maxProgress) async {
    await Future<void>.delayed(const Duration(seconds: 1), () async {
      final AndroidNotificationDetails androidPlatformChannelSpecifics =
          AndroidNotificationDetails('progress channel', 'progress channel',
              channelShowBadge: false,
              importance: Importance.max,
              priority: Priority.high,
              onlyAlertOnce: true,
              showProgress: true,
              maxProgress: maxProgress,
              progress: progress);
      final NotificationDetails platformChannelSpecifics =
          NotificationDetails(android: androidPlatformChannelSpecifics);
      await _notificationsPlugin.show(
          0, 'Upload ', 'image uploaded', platformChannelSpecifics,
          payload: 'item x');
    });
  }

  static cancelnotifivcation() async {
    await _notificationsPlugin.cancel(0);
  }

相关问题