修改个人信息界面相册权限

This commit is contained in:
魏少阳 2024-04-09 16:30:41 +08:00
parent 5a2705aac2
commit 6d44fb882a
2 changed files with 28 additions and 13 deletions

View File

@ -23,6 +23,7 @@
<!--允许写设备缓存,用于问题排查--> <!--允许写设备缓存,用于问题排查-->
<uses-permission android:name="android.permission.WRITE_SETTINGS"/> <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.WRITE_EXTERNAL_STORAGE"/>
<!--允许读设备等信息,用于问题排查--> <!--允许读设备等信息,用于问题排查-->
<uses-permission android:name="android.permission.READ_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.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE"/> <uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.REORDER_TASKS"/> <uses-permission android:name="android.permission.REORDER_TASKS"/>
<application android:label="@string/app_name" android:name="android.app.Application" android:icon="@mipmap/ic_launcher"> <application android:label="@string/app_name" android:name="android.app.Application" android:icon="@mipmap/ic_launcher">
<meta-data <meta-data
android:name="flutterEmbedding" android:name="flutterEmbedding"

View File

@ -25,23 +25,19 @@ class MinePersonInfoPage extends StatefulWidget {
State<MinePersonInfoPage> createState() => _MinePersonInfoPageState(); State<MinePersonInfoPage> createState() => _MinePersonInfoPageState();
} }
class _MinePersonInfoPageState extends State<MinePersonInfoPage> with WidgetsBindingObserver { class _MinePersonInfoPageState extends State<MinePersonInfoPage>
// with WidgetsBindingObserver
{
final logic = Get.put(MinePersonInfoLogic()); final logic = Get.put(MinePersonInfoLogic());
final state = Get.find<MinePersonInfoLogic>().state; final state = Get.find<MinePersonInfoLogic>().state;
@override @override
initState() { initState() {
super.initState(); super.initState();
WidgetsBinding.instance.addObserver(this); // // WidgetsBinding.instance.addObserver(this); //
logic.getUserInfoRequest(); // logic.getUserInfoRequest();
_checkCameraPermission(); // _checkCameraPermission();
_checkPhotoPermission(); // _checkPhotoPermission();
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this); //
super.dispose();
} }
// // // //
@ -223,6 +219,17 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> with WidgetsBin
// //
showPermissionDeniedDialog(); showPermissionDeniedDialog();
} }
//
// PermissionStatus photosStatus = await Permission.photos.request();
//
// if (photosStatus.isGranted) {
// //
// state.hasPhotoPermission.value = true;
// } else {
// //
// showPermissionDeniedDialog();
// }
} }
// Future<void> requestPhotoPermission() async { // Future<void> requestPhotoPermission() async {
@ -284,8 +291,7 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> with WidgetsBin
/// ///
selectCamera() async { selectCamera() async {
XFile? photo = XFile? photo = await state.imagePicker.pickImage(source: ImageSource.camera, preferredCameraDevice: CameraDevice.rear);
await state.imagePicker.pickImage(source: ImageSource.camera, preferredCameraDevice: CameraDevice.rear);
if (photo != null) { if (photo != null) {
state.image = photo; state.image = photo;
// logic.getUpTokenRequest(); // logic.getUpTokenRequest();
@ -337,4 +343,10 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> with WidgetsBin
}); });
} }
} }
@override
void dispose() {
// WidgetsBinding.instance.removeObserver(this); //
super.dispose();
}
} }