簡體   English   中英

在Flutter中打開Image Gallery(相冊)申請

[英]Open Image Gallery (Photo Album) Application in Flutter

Flutter中如何打開圖庫(Android)或相冊(iOS)。我不想從圖庫中選擇圖像。 我想要的是以編程方式打開圖片庫應用程序。

我試圖搜索 Flutter 打開圖片庫應用程序。 所有的結果都在教我如何使用 image_picker package。但是這不是我想要的。

我嘗試使用 url_launcher package。這是我嘗試過的(它似乎適用於 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
}

您可以使用open_file插件。 它同時支持 Android 和 IOS。

import 'package:open_file/open_file.dart';

OpenFile.open(${imagePath});

您的方法適用於 iOS。 對於 Android,您可以使用android_intent_plus插件。

const intent = AndroidIntent(
  action: 'action_view',
  type: 'image/*',
  flags: [Flag.FLAG_ACTIVITY_NEW_TASK],
);
intent.launch();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM