修改个人信息界面相册权限
This commit is contained in:
parent
5a2705aac2
commit
6d44fb882a
@ -23,6 +23,7 @@
|
||||
<!--允许写设备缓存,用于问题排查-->
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
|
||||
<!--允许写入扩展存储,用于写入缓存定位数据-->
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<!--允许读设备等信息,用于问题排查-->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
@ -34,6 +35,8 @@
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||
<uses-permission android:name="android.permission.REORDER_TASKS"/>
|
||||
|
||||
|
||||
<application android:label="@string/app_name" android:name="android.app.Application" android:icon="@mipmap/ic_launcher">
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
|
||||
@ -25,23 +25,19 @@ class MinePersonInfoPage extends StatefulWidget {
|
||||
State<MinePersonInfoPage> createState() => _MinePersonInfoPageState();
|
||||
}
|
||||
|
||||
class _MinePersonInfoPageState extends State<MinePersonInfoPage> with WidgetsBindingObserver {
|
||||
class _MinePersonInfoPageState extends State<MinePersonInfoPage>
|
||||
// with WidgetsBindingObserver
|
||||
{
|
||||
final logic = Get.put(MinePersonInfoLogic());
|
||||
final state = Get.find<MinePersonInfoLogic>().state;
|
||||
|
||||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this); // 添加观察者
|
||||
logic.getUserInfoRequest();
|
||||
_checkCameraPermission();
|
||||
_checkPhotoPermission();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this); // 移除观察者
|
||||
super.dispose();
|
||||
// WidgetsBinding.instance.addObserver(this); // 添加观察者
|
||||
// logic.getUserInfoRequest();
|
||||
// _checkCameraPermission();
|
||||
// _checkPhotoPermission();
|
||||
}
|
||||
|
||||
// // 当应用生命周期状态变化时调用
|
||||
@ -223,6 +219,17 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> with WidgetsBin
|
||||
// 如果权限被拒绝,你可以选择在这里处理相应逻辑,比如显示一个提示框
|
||||
showPermissionDeniedDialog();
|
||||
}
|
||||
|
||||
// 请求相册权限
|
||||
// PermissionStatus photosStatus = await Permission.photos.request();
|
||||
//
|
||||
// if (photosStatus.isGranted) {
|
||||
// // 相册权限已被授予
|
||||
// state.hasPhotoPermission.value = true;
|
||||
// } else {
|
||||
// // 如果权限被拒绝,你可以选择在这里处理相应逻辑,比如显示一个提示框
|
||||
// showPermissionDeniedDialog();
|
||||
// }
|
||||
}
|
||||
|
||||
// Future<void> requestPhotoPermission() async {
|
||||
@ -284,8 +291,7 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> with WidgetsBin
|
||||
|
||||
///拍摄照片
|
||||
selectCamera() async {
|
||||
XFile? photo =
|
||||
await state.imagePicker.pickImage(source: ImageSource.camera, preferredCameraDevice: CameraDevice.rear);
|
||||
XFile? photo = await state.imagePicker.pickImage(source: ImageSource.camera, preferredCameraDevice: CameraDevice.rear);
|
||||
if (photo != null) {
|
||||
state.image = photo;
|
||||
// logic.getUpTokenRequest();
|
||||
@ -337,4 +343,10 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> with WidgetsBin
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// WidgetsBinding.instance.removeObserver(this); // 移除观察者
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user