如何在 Flutter 中打開圖庫 (Android) 或相冊 (iOS)。我不想從圖片庫中選擇圖片。我想要的是以編程方式打開圖庫應用程式。
我試圖搜索 Flutter 打開的圖庫應用程式。所有的結果都在教我如何使用 image_picker 包。但什么不是我想要的。
我曾嘗試使用 url_launcher 包。這是我嘗試過的(它似乎適用于 iOS,但我不確定它是否合適):
import 'package:url_launcher/url_launcher.dart';
if (Platform.isIOS) {
String _url = "photos-redirect://";
if (await canLaunch(_url)) {
launch(_url);
}
} else if (Platform.isAndroid) {
// To DO
}
uj5u.com熱心網友回復:
您的方法適用于 iOS。對于 Android,您可以使用android_intent_plus插件。
const intent = AndroidIntent(
action: 'action_view',
type: 'image/*',
flags: [Flag.FLAG_ACTIVITY_NEW_TASK],
);
intent.launch();
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/359287.html
