image_picker小部件在打开画廊和照相机时不请求权限.我应该做什么以便请求权限尽管我知道image_picker软件包确实隐式请求权限?但在我的情况下,它没有.我已经尝试了每一个解决方案,我发现在互联网上.没有一个能解决我的问题.
pubspec.yml
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
# image_picker: ^0.8.5+3
image_picker: ^0.8.5+3
AndroidMenifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flutter_application_1">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
</manifest>
<!-- <application
android:name="io.flutter.app.FlutterApplication"
android:label="xxxxxx"
android:icon="@mipmap/launcher_icon">
<activity>
android:name="io.flutter.app.FlutterApplication"
android:requestLegacyExternalStorage="true"
</activity>
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> -->
4条答案
按热度按时间k7fdbhmy1#
使用permission_handler包:
试试这个:
ma8fv8wu2#
kxkpmulp3#
如果您向“AndroidManifest.xml”文件添加权限,则当您尝试使用图像拾取器时将自动询问权限。我使用相机和拾取器库,因此我将这些权限放在“AndroidManifest.xml”中。
y1aodyip4#
你不需要请求画廊的权限,只需要请求相机的权限,你会自动获得画廊的权限,你可以使用它。