The image_picker, has the following three methods to reference when wanting to make device XFile selections:
- pickImage()
- pickVideo()
- pickMultiImage()
- pickMultiMedia() <- this is the one i want
From their own documentation:
On Android 13 and above this package uses the Android Photo Picker . On Android 12 and below use of Android Photo Picker is optional. Learn how to use it.
But unless you're on iOS, the pickMultiMedia opens the Android file system that accepts a variety of file formats (e.g. pdf, ico). And instead of opening the device gallery like it does with iOS, it opens androids file system. I put together this quick android app that demonstrates how to use the Android Photo Picker. And for whatever reason, the image_picker package doesn't use this for its android support and i want to know why. Or is there something im doing wrong. I also have no clue how to contribute to Flutter's package repositories.
import androidx.activity.result.contract.ActivityResultContracts.PickMultipleVisualMedia
class MainActivity : ComponentActivity() {
private val pickMediaLauncher = registerForActivityResult(PickMultipleVisualMedia()) {}
override fun onCreate(savedInstanceState: Bundle?) {
...
pickButton.setOnClickListener {
val request = PickVisualMediaRequest.Builder()
.setMediaType(ActivityResultContracts.PickVisualMedia.ImageAndVideo)
.build()
pickMediaLauncher.launch(request)
}
}
}