【Flutter】path_providerでファイル操作

Flutter

path_providerとは

path_providerは、Flutterアプリケーションでファイルシステム上の一般的に使用される場所を見つけるためのプラグインです。

path_provider | Flutter package
Flutter plugin for getting commonly used locations on host platform file systems, such as the temp and app data director...

使い方

インストール方法

path_provider install | Flutter package
Flutter plugin for getting commonly used locations on host platform file systems, such as the temp and app data director...

基本的な使用方法

一時ディレクトリの取得

アプリケーションの一時ファイルを保存するためのディレクトリを取得します。

final Directory tempDir = await getTemporaryDirectory();

アプリケーションのドキュメントディレクトリの取得

アプリケーションの永続的なデータを保存するためのディレクトリを取得します。

final Directory appDocumentsDir = await getApplicationDocumentsDirectory();

ダウンロードディレクトリの取得

ユーザーのダウンロードディレクトリを取得します。
プラットフォームによってはサポートされていない場合があります。

final Directory? downloadsDir = await getDownloadsDirectory();

サポートフォームは以下で確認できます。

path_provider | Flutter package
Flutter plugin for getting commonly used locations on host platform file systems, such as the temp and app data director...
タイトルとURLをコピーしました