Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: The param end of PhotoManager.getAssetListRange not right #966

Merged
merged 3 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ that can be found in the LICENSE file. -->
- Fix namespace on Android.
- Remove the package definition from the manifest.
- Use `math.pow(2^63)-1` to make Web compile work again.
- Fix: the `end` of `PhotoManager.getAssetListRange` is handled incorrectly.(#962)
CaiJingLong marked this conversation as resolved.
Show resolved Hide resolved

## 2.7.0

Expand Down
88 changes: 88 additions & 0 deletions example/lib/page/developer/issues_page/issue_962.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import 'package:flutter/material.dart';
import 'package:photo_manager/photo_manager.dart';

import 'issue_index_page.dart';

class Issue962 extends StatefulWidget {
const Issue962({Key? key}) : super(key: key);

@override
State<Issue962> createState() => _Issue962State();
}

class _Issue962State extends State<Issue962> with IssueBase<Issue962> {
int start = 0;
int end = 5;

ValueNotifier<String> logNotifier = ValueNotifier<String>('');

void onChange() async {
if (start >= end) {
logNotifier.value = 'start must less than end';
return;
}

final assetList = await PhotoManager.getAssetListRange(
start: start,
end: end,
filterOption: FilterOptionGroup(
imageOption: const FilterOption(needTitle: true),
videoOption: const FilterOption(needTitle: true),
orders: [
const OrderOption(type: OrderOptionType.createDate),
],
),
);

logNotifier.value = 'The assetList count: ${assetList.length}';
}

final node = FocusScopeNode();

@override
void dispose() {
node.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return buildScaffold([
TextFormField(
initialValue: start.toString(),
decoration: const InputDecoration(
labelText: 'start',
),
onChanged: (value) {
start = int.tryParse(value) ?? 0;
onChange();
},
),
TextFormField(
initialValue: end.toString(),
decoration: const InputDecoration(
labelText: 'end',
),
onChanged: (value) {
end = int.tryParse(value) ?? 0;
onChange();
},
),
buildButton('Reproduct issue 962', onChange),
AnimatedBuilder(
animation: logNotifier,
builder: (context, w) {
return Text(
logNotifier.value,
style: const TextStyle(
fontSize: 12,
),
);
},
),
]);
}

@override
int get issueNumber => 962;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:url_launcher/url_launcher.dart';

import 'issue_734.dart';
import 'issue_918.dart';
import 'issue_962.dart';

class IssuePage extends StatelessWidget {
const IssuePage({
Expand All @@ -23,6 +24,7 @@ class IssuePage extends StatelessWidget {
children: <Widget>[
Issue734Page(),
Issue918Page(),
Issue962(),
],
),
);
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/core/PMManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ - (NSUInteger)getAssetCountWithType:(int)type option:(NSObject<PMBaseFilter> *)f
PHFetchResult<PHAsset *> *result = [PHAsset fetchAssetsWithOptions:options];

NSUInteger endOffset = end;
if (endOffset < result.count) {
if (endOffset > result.count) {
endOffset = result.count;
}

Expand Down
Loading