Skip to content

Commit dc08834

Browse files
committed
Return action result in restorePosition
1 parent bcab1ef commit dc08834

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lib/src/random_access_source.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ abstract class RandomAccessSource {
6161
Future<void> close();
6262

6363
/// Restores the position after executing the given [action].
64-
Future<void> restorePosition<T>(Future<T> Function() action) async {
64+
Future<T> restorePosition<T>(Future<T> Function() action) async {
6565
final currentPosition = await position();
6666
try {
67-
await action();
67+
return await action();
6868
} finally {
6969
await seek(currentPosition);
7070
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: random_access_source
22
description: A shared interface for common random access data.
3-
version: 4.2.0
3+
version: 4.2.1
44
repository: https://github.com/flutter-cavalry/random_access_source
55

66
environment:

test/raf_test.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,14 @@ void main() {
115115
await src.seek(10);
116116
expect(await src.position(), 10);
117117

118-
await src.restorePosition(() async {
118+
final res1 = await src.restorePosition(() async {
119119
expect(await src.position(), 10);
120120
expect(await src.readByte(), flutterIcon[10]);
121121
expect(await src.position(), 11);
122+
return 'test1';
122123
});
123124
expect(await src.position(), 10);
125+
expect(res1, 'test1');
124126

125127
try {
126128
await src.restorePosition(() async {

0 commit comments

Comments
 (0)