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.
39 lines
1.1 KiB
39 lines
1.1 KiB
4 years ago
|
import 'dart:io';
|
||
|
|
||
|
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 {
|
||
|
static Future<File> pick({
|
||
|
String title,
|
||
|
}) async {
|
||
|
PickedFile file = await Get.bottomSheet(CupertinoActionSheet(
|
||
|
title: title.text.isIntrinsic.make(),
|
||
|
actions: [
|
||
|
CupertinoDialogAction(
|
||
|
onPressed: () async => Get.back(
|
||
|
result: await ImagePicker().getImage(source: ImageSource.gallery),
|
||
|
),
|
||
|
child: '相册'.text.isIntrinsic.make(),
|
||
|
),
|
||
|
CupertinoDialogAction(
|
||
|
onPressed: () async => Get.back(
|
||
|
result: await ImagePicker().getImage(source: ImageSource.camera),
|
||
|
),
|
||
|
child: '相机'.text.isIntrinsic.make(),
|
||
|
),
|
||
|
],
|
||
|
cancelButton: CupertinoDialogAction(
|
||
|
onPressed: Get.back,
|
||
|
child: '取消'.text.isIntrinsic.make(),
|
||
|
),
|
||
|
));
|
||
|
if (file != null)
|
||
|
return File(file.path);
|
||
|
else
|
||
|
return null;
|
||
|
}
|
||
|
}
|