You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aku_new_community/lib/widget/picker/bee_image_picker.dart

57 lines
1.6 KiB

import 'dart:io';
import 'package:aku_new_community/utils/headers.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart';
import 'package:velocity_x/velocity_x.dart';
class BeeImagePicker {
4 years ago
static Future<File?> pick(
{required String title,
double maxWidth = 1000,
double maxHeight = 1000}) async {
4 years ago
PickedFile? file = await Get.bottomSheet(CupertinoActionSheet(
title: title.text.isIntrinsic.make(),
actions: [
CupertinoDialogAction(
onPressed: () async => Get.back(
result: await ImagePicker().getImage(
source: ImageSource.gallery,
maxHeight: maxHeight,
maxWidth: maxWidth,
),
),
child: [
Icon(CupertinoIcons.photo),
30.wb,
'相册'.text.isIntrinsic.make(),
].row(),
),
CupertinoDialogAction(
onPressed: () async => Get.back(
result: await ImagePicker().getImage(
source: ImageSource.camera,
maxHeight: maxHeight,
maxWidth: maxWidth,
),
),
child: [
Icon(CupertinoIcons.camera),
30.wb,
'相机'.text.isIntrinsic.make(),
].row(),
),
],
cancelButton: CupertinoDialogAction(
onPressed: Get.back,
child: '取消'.text.isIntrinsic.make(),
),
));
if (file != null)
return File(file.path);
else
return null;
}
}