Skip to content

Commit 43e81e6

Browse files
committed
📝 Add one frequently asked question
1 parent 66a5a9a commit 43e81e6

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

README-ZH.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ Language: [English](README.md) | 中文
9090
* [使用 `dio`](#使用-dio)
9191
* [自定义选择器](#自定义选择器)
9292
* [常见问题 ❔](#常见问题-)
93-
* [Execution failed for task ':photo_manager:compileDebugKotlin'](#execution-failed-for-task-photomanagercompiledebugkotlin)
93+
* [修改默认相册名称(将 `Recent` 改为其他)](#修改默认相册名称将-recent-改为其他)
94+
* [Execution failed for task ':photo_manager:compileDebugKotlin'](#execution-failed-for-task-photo_managercompiledebugkotlin)
9495
* [`File``Uint8List` 创建 `AssetEntity` 的方法](#从-file-或-uint8list-创建-assetentity-的方法)
9596
* [控制台提示 'Failed to find GeneratedAppGlideModule'](#控制台提示-failed-to-find-generatedappglidemodule)
9697
* [致谢](#致谢)
@@ -303,7 +304,7 @@ final List<AssetEntity>? result = await AssetPicker.pickAssets(
303304
| pathNameBuilder | `PathNameBuilder<AssetPathEntity>?` | 基于路径(相册)构建自定义名称的方法 | `null` |
304305
| assetsChangeCallback | `AssetsChangeCallback<AssetPathEntity>?` | 当系统通知资源变化时将调用的回调 | `null` |
305306
| assetsChangeRefreshPredicate | `AssetsChangeRefreshPredicate<AssetPathEntity>?` | 判断资源变化是否根据 call 和当前选中的路径进行更新 | `null` |
306-
| shouldAutoplayPreview | `bool` | 预览是否应自动播放 | `false` |
307+
| shouldAutoplayPreview | `bool` | 预览是否应自动播放 | `false` |
307308

308309
-`maxAssets` 等于 `1`(即单选模式),搭配
309310
`SpecialPickerType.noPreview` 使用会在用户点选资源换时立刻选中并返回。
@@ -453,6 +454,25 @@ Future<dio.MultipartFile> multipartFileFromAssetEntity(AssetEntity entity) async
453454

454455
## 常见问题 ❔
455456

457+
### 修改默认相册名称(将 `Recent` 改为其他)
458+
459+
在 Android 上 `Recent` 是总相册的默认名称,
460+
总相册是一个实际不存在的概念,它只是原始媒体数据的记录集合。
461+
462+
想要在 Android 上解决这个问题,你可以像这样使用 `pathNameBuilder`
463+
```dart
464+
AssetPickerConfig(
465+
pathNameBuilder: (AssetPathEntity path) => switch (path) {
466+
final p when p.isAll => '最近',
467+
// 你也可以将类似的逻辑应用在其他常见的相册上。
468+
_ => path.name,
469+
},
470+
)
471+
```
472+
473+
其他相册或者其他平台 (iOS/macOS) 上的相册会根据系统语言和配置支持的语言来进行展示。
474+
`pathNameBuilder` 可以用于任何的相册。
475+
456476
### Execution failed for task ':photo_manager:compileDebugKotlin'
457477

458478
查看 [photo_manager#561][] 了解详细的解决方法。

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ submit issues to our issue tracker first.
9292
* [With `dio`](#with-dio)
9393
* [Custom pickers](#custom-pickers)
9494
* [Frequently asked question ❔](#frequently-asked-question-)
95-
* [Execution failed for task ':photo_manager:compileDebugKotlin'](#execution-failed-for-task-photomanagercompiledebugkotlin)
95+
* [Changing the default album name (`Recent` to others)](#changing-the-default-album-name-recent-to-others)
96+
* [Execution failed for task ':photo_manager:compileDebugKotlin'](#execution-failed-for-task-photo_managercompiledebugkotlin)
9697
* [Create `AssetEntity` from `File` or `Uint8List` (rawData)](#create-assetentity-from-file-or-uint8list-rawdata)
9798
* [Glide warning 'Failed to find GeneratedAppGlideModule'](#glide-warning-failed-to-find-generatedappglidemodule)
9899
* [Contributors ✨](#contributors-)
@@ -312,7 +313,7 @@ Fields in `AssetPickerConfig`:
312313
| pathNameBuilder | `PathNameBuilder<AssetPathEntity>?` | Build customized path (album) name with the given path entity. | `null` |
313314
| assetsChangeCallback | `AssetsChangeCallback<AssetPathEntity>?` | The callback that will be called when the system notifies assets changes. | `null` |
314315
| assetsChangeRefreshPredicate | `AssetsChangeRefreshPredicate<AssetPathEntity>?` | Whether assets changing should call refresh with the given call and the current selected path. | `null` |
315-
| shouldAutoPlayPreview | `bool` | Whether the preview should auto play. | `false` |
316+
| shouldAutoPlayPreview | `bool` | Whether the preview should auto play. | `false` |
316317

317318
- When `maxAssets` equals to `1` (a.k.a. single picking mode),
318319
use `SpecialPickerType.noPreview` will immediately select asset
@@ -468,6 +469,26 @@ See [Contribute custom implementations][] for more details.
468469

469470
## Frequently asked question ❔
470471

472+
### Changing the default album name (`Recent` to others)
473+
474+
`Recent` is the fix album name for the ALL assets on Android
475+
since the all assets' album is not an actual album, it only represents all media data records.
476+
477+
To solve that on Android, use `pathNameBuilder`, for example:
478+
```dart
479+
AssetPickerConfig(
480+
pathNameBuilder: (AssetPathEntity path) => switch (path) {
481+
final p when p.isAll => '最近',
482+
// You can apply similar conditions to other common paths.
483+
_ => path.name,
484+
},
485+
)
486+
```
487+
488+
Other albums or albums on other platforms (iOS/macOS) will follow
489+
the configured system localization and supported localizations.
490+
`pathNameBuilder` is available for all albums.
491+
471492
### Execution failed for task ':photo_manager:compileDebugKotlin'
472493

473494
See [photo_manager#561][] for more details.

0 commit comments

Comments
 (0)