Skip to content

Commit a684b80

Browse files
authored
⚡️ Adapt Flutter 3.3 (#820)
1 parent d5d4c79 commit a684b80

File tree

9 files changed

+64
-51
lines changed

9 files changed

+64
-51
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ that can be found in the LICENSE file. -->
88

99
### Improvements
1010

11+
- Adapt Flutter 3.3. (#820)
1112
- Retrieve metadata for videos when empty on Android. (#819)
1213

1314
## 2.3.0-dev.1

example/lib/page/save_image_example.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'dart:io';
2-
import 'dart:typed_data';
2+
import 'dart:typed_data' as typed_data;
33

44
import 'package:flutter/material.dart';
55
import 'package:flutter/services.dart';
@@ -22,7 +22,7 @@ class _SaveMediaExampleState extends State<SaveMediaExample> {
2222
final String haveExifUrl = 'http://172.16.100.7:2393/IMG_20200107_182905.jpg';
2323

2424
final String videoUrl =
25-
'http://img.ksbbs.com/asset/Mon_1703/05cacb4e02f9d9e.mp4';
25+
'https://pic.app.kszhuangxiu.com/forum/20220423120218front2_1_788292_FhP_XBo24M5XuZzb4xPb-YPaC6Yq.mp4';
2626

2727
// final videoUrl = "http://192.168.31.252:51781/out.mov";
2828
// final videoUrl = "http://192.168.31.252:51781/out.ogv";
@@ -130,13 +130,13 @@ class _SaveMediaExampleState extends State<SaveMediaExample> {
130130
resp.listen((List<int> data) {
131131
bytes.addAll(data);
132132
}, onDone: () {
133-
final Uint8List image = Uint8List.fromList(bytes);
133+
final image = typed_data.Uint8List.fromList(bytes);
134134
saveImage(image);
135135
client.close();
136136
});
137137
}
138138

139-
Future<void> saveImage(Uint8List uint8List) async {
139+
Future<void> saveImage(typed_data.Uint8List uint8List) async {
140140
final AssetEntity? asset = await PhotoManager.editor.saveImage(
141141
uint8List,
142142
title: '${DateTime.now().millisecondsSinceEpoch}.jpg',

lib/src/filter/filter_options.dart

+12-5
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ class FilterOption {
7272
}
7373

7474
@override
75-
int get hashCode => hashValues(needTitle, sizeConstraint, durationConstraint);
75+
int get hashCode =>
76+
needTitle.hashCode ^
77+
sizeConstraint.hashCode ^
78+
durationConstraint.hashCode;
7679
}
7780

7881
/// Constraints of asset pixel width and height.
@@ -139,7 +142,11 @@ class SizeConstraint {
139142

140143
@override
141144
int get hashCode =>
142-
hashValues(minWidth, maxWidth, minHeight, maxHeight, ignoreSize);
145+
minWidth.hashCode ^
146+
maxWidth.hashCode ^
147+
minHeight.hashCode ^
148+
maxHeight.hashCode ^
149+
ignoreSize.hashCode;
143150
}
144151

145152
/// Constraints of duration.
@@ -179,7 +186,7 @@ class DurationConstraint {
179186
}
180187

181188
@override
182-
int get hashCode => hashValues(min, max, allowNullable);
189+
int get hashCode => min.hashCode ^ max.hashCode ^ allowNullable.hashCode;
183190
}
184191

185192
@immutable
@@ -229,7 +236,7 @@ class DateTimeCond {
229236
}
230237

231238
@override
232-
int get hashCode => hashValues(min, max, ignore);
239+
int get hashCode => min.hashCode ^ max.hashCode ^ ignore.hashCode;
233240
}
234241

235242
@immutable
@@ -259,5 +266,5 @@ class OrderOption {
259266
}
260267

261268
@override
262-
int get hashCode => hashValues(type, asc);
269+
int get hashCode => type.hashCode ^ asc.hashCode;
263270
}

lib/src/internal/image_provider.dart

+9-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// in the LICENSE file.
44

55
import 'dart:io';
6-
import 'dart:typed_data';
6+
import 'dart:typed_data' as typed_data;
77
import 'dart:ui' as ui;
88

99
import 'package:flutter/foundation.dart';
@@ -58,7 +58,7 @@ class AssetEntityImageProvider extends ImageProvider<AssetEntityImageProvider> {
5858
@override
5959
ImageStreamCompleter load(
6060
AssetEntityImageProvider key,
61-
DecoderCallback decode,
61+
DecoderCallback decode, // ignore: deprecated_member_use
6262
) {
6363
return MultiFrameImageStreamCompleter(
6464
codec: _loadAsync(key, decode),
@@ -83,7 +83,7 @@ class AssetEntityImageProvider extends ImageProvider<AssetEntityImageProvider> {
8383

8484
Future<ui.Codec> _loadAsync(
8585
AssetEntityImageProvider key,
86-
DecoderCallback decode,
86+
DecoderCallback decode, // ignore: deprecated_member_use
8787
) async {
8888
try {
8989
assert(key == this);
@@ -103,7 +103,7 @@ class AssetEntityImageProvider extends ImageProvider<AssetEntityImageProvider> {
103103
type = key.imageFileType;
104104
}
105105

106-
Uint8List? data;
106+
typed_data.Uint8List? data;
107107
if (isOriginal) {
108108
if (key.entity.type == AssetType.video) {
109109
data = await key.entity.thumbnailData;
@@ -204,12 +204,11 @@ class AssetEntityImageProvider extends ImageProvider<AssetEntityImageProvider> {
204204
}
205205

206206
@override
207-
int get hashCode => hashValues(
208-
entity,
209-
isOriginal,
210-
thumbnailSize,
211-
thumbnailFormat,
212-
);
207+
int get hashCode =>
208+
entity.hashCode ^
209+
isOriginal.hashCode ^
210+
thumbnailSize.hashCode ^
211+
thumbnailFormat.hashCode;
213212
}
214213

215214
/// A widget that displays an [AssetEntity] image.

lib/src/internal/plugin.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import 'dart:async';
66
import 'dart:io';
7-
import 'dart:typed_data';
7+
import 'dart:typed_data' as typed_data;
88

99
import 'package:flutter/services.dart';
1010

@@ -149,7 +149,7 @@ class PhotoManagerPlugin with BasePlugin, IosPlugin, AndroidPlugin {
149149
}
150150

151151
/// Get thumbnail of asset id.
152-
Future<Uint8List?> getThumbnail({
152+
Future<typed_data.Uint8List?> getThumbnail({
153153
required String id,
154154
required ThumbnailOption option,
155155
PMProgressHandler? progressHandler,
@@ -162,7 +162,7 @@ class PhotoManagerPlugin with BasePlugin, IosPlugin, AndroidPlugin {
162162
return _channel.invokeMethod(PMConstants.mGetThumb, params);
163163
}
164164

165-
Future<Uint8List?> getOriginBytes(
165+
Future<typed_data.Uint8List?> getOriginBytes(
166166
String id, {
167167
PMProgressHandler? progressHandler,
168168
}) {
@@ -251,7 +251,7 @@ class PhotoManagerPlugin with BasePlugin, IosPlugin, AndroidPlugin {
251251
}
252252

253253
Future<AssetEntity?> saveImage(
254-
Uint8List data, {
254+
typed_data.Uint8List data, {
255255
required String? title,
256256
String? desc,
257257
String? relativePath,

lib/src/internal/progress_handler.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class PMProgressState {
7676
}
7777

7878
@override
79-
int get hashCode => hashValues(progress, state);
79+
int get hashCode => progress.hashCode ^ state.hashCode;
8080

8181
@override
8282
String toString() => '$runtimeType($state, $progress)';

lib/src/managers/notify_manager.dart

+8-10
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,31 @@
44

55
import 'dart:async';
66

7-
import 'package:flutter/foundation.dart';
7+
import 'package:flutter/foundation.dart' as foundation;
88
import 'package:flutter/services.dart';
99

1010
import '../internal/constants.dart';
1111
import '../internal/plugin.dart';
1212

1313
/// The notify manager when assets changed.
1414
class NotifyManager {
15-
static const MethodChannel _channel = MethodChannel(
16-
'${PMConstants.channelPrefix}/notify',
17-
);
15+
static const _channel = MethodChannel('${PMConstants.channelPrefix}/notify');
1816

1917
Stream<bool> get notifyStream => _controller.stream;
20-
final StreamController<bool> _controller = StreamController<bool>.broadcast();
18+
final _controller = StreamController<bool>.broadcast();
2119

22-
final List<ValueChanged<MethodCall>> _notifyCallback =
23-
<ValueChanged<MethodCall>>[];
20+
final _notifyCallback = <foundation.ValueChanged<MethodCall>>[];
2421

2522
/// {@template photo_manager.NotifyManager.addChangeCallback}
2623
/// Add a callback for assets changing.
2724
/// {@endtemplate}
28-
void addChangeCallback(ValueChanged<MethodCall> c) => _notifyCallback.add(c);
25+
void addChangeCallback(foundation.ValueChanged<MethodCall> c) =>
26+
_notifyCallback.add(c);
2927

3028
/// {@template photo_manager.NotifyManager.removeChangeCallback}
3129
/// Remove the callback for assets changing.
3230
/// {@endtemplate}
33-
void removeChangeCallback(ValueChanged<MethodCall> c) =>
31+
void removeChangeCallback(foundation.ValueChanged<MethodCall> c) =>
3432
_notifyCallback.remove(c);
3533

3634
/// {@template photo_manager.NotifyManager.startChangeNotify}
@@ -71,7 +69,7 @@ class NotifyManager {
7169
}
7270

7371
Future<dynamic> _onChange(MethodCall m) async {
74-
_notifyCallback.toList().forEach((ValueChanged<MethodCall> c) => c.call(m));
72+
_notifyCallback.toList().forEach((c) => c.call(m));
7573
}
7674

7775
@override

lib/src/types/entity.dart

+18-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// in the LICENSE file.
44

55
import 'dart:io';
6-
import 'dart:typed_data';
6+
import 'dart:typed_data' as typed_data;
77

88
import 'package:flutter/foundation.dart';
99
import 'package:flutter/rendering.dart';
@@ -280,7 +280,12 @@ class AssetPathEntity {
280280

281281
@override
282282
int get hashCode =>
283-
hashValues(id, name, albumType, type, lastModified, isAll);
283+
id.hashCode ^
284+
name.hashCode ^
285+
albumType.hashCode ^
286+
type.hashCode ^
287+
lastModified.hashCode ^
288+
isAll.hashCode;
284289

285290
@override
286291
String toString() {
@@ -515,7 +520,7 @@ class AssetEntity {
515520
///
516521
/// **Use it with cautious** since the original data might be epic large.
517522
/// Generally use this method only for images.
518-
Future<Uint8List?> get originBytes => _getOriginBytes();
523+
Future<typed_data.Uint8List?> get originBytes => _getOriginBytes();
519524

520525
/// Obtain the thumbnail data with [PMConstants.vDefaultThumbnailSize]
521526
/// size of the asset, typically use it for preview displays.
@@ -527,7 +532,7 @@ class AssetEntity {
527532
/// See also:
528533
/// * [thumbnailDataWithSize] which is a common method to obtain thumbnails.
529534
/// * [thumbnailDataWithOption] which accepts customized [ThumbnailOption].
530-
Future<Uint8List?> get thumbnailData => thumbnailDataWithSize(
535+
Future<typed_data.Uint8List?> get thumbnailData => thumbnailDataWithSize(
531536
const ThumbnailSize.square(PMConstants.vDefaultThumbnailSize),
532537
);
533538

@@ -538,7 +543,7 @@ class AssetEntity {
538543
/// See also:
539544
/// * [thumbnailData] which obtain the thumbnail data with fixed size.
540545
/// * [thumbnailDataWithOption] which accepts customized [ThumbnailOption].
541-
Future<Uint8List?> thumbnailDataWithSize(
546+
Future<typed_data.Uint8List?> thumbnailDataWithSize(
542547
ThumbnailSize size, {
543548
ThumbnailFormat format = ThumbnailFormat.jpeg,
544549
int quality = 100,
@@ -550,7 +555,7 @@ class AssetEntity {
550555
}());
551556
// Return null if the asset is audio or others.
552557
if (type == AssetType.audio || type == AssetType.other) {
553-
return Future<Uint8List?>.value();
558+
return Future<typed_data.Uint8List?>.value();
554559
}
555560
final ThumbnailOption option;
556561
if (Platform.isIOS || Platform.isMacOS) {
@@ -579,7 +584,7 @@ class AssetEntity {
579584
/// See also:
580585
/// * [thumbnailData] which obtain the thumbnail data with fixed size.
581586
/// * [thumbnailDataWithSize] which is a common method to obtain thumbnails.
582-
Future<Uint8List?> thumbnailDataWithOption(
587+
Future<typed_data.Uint8List?> thumbnailDataWithOption(
583588
ThumbnailOption option, {
584589
PMProgressHandler? progressHandler,
585590
}) {
@@ -589,7 +594,7 @@ class AssetEntity {
589594
}());
590595
// Return null if the asset is audio or others.
591596
if (type == AssetType.audio || type == AssetType.other) {
592-
return Future<Uint8List?>.value();
597+
return Future<typed_data.Uint8List?>.value();
593598
}
594599
assert(() {
595600
option.checkAssertions();
@@ -684,7 +689,7 @@ class AssetEntity {
684689
return File(path);
685690
}
686691

687-
Future<Uint8List?> _getOriginBytes({
692+
Future<typed_data.Uint8List?> _getOriginBytes({
688693
PMProgressHandler? progressHandler,
689694
}) async {
690695
assert(
@@ -783,7 +788,7 @@ class AssetEntity {
783788
}
784789

785790
@override
786-
int get hashCode => hashValues(id, isFavorite);
791+
int get hashCode => id.hashCode ^ isFavorite.hashCode;
787792

788793
@override
789794
bool operator ==(Object other) {
@@ -805,14 +810,14 @@ class LatLng {
805810
final double? latitude;
806811
final double? longitude;
807812

808-
@override
809-
int get hashCode => hashValues(latitude, longitude);
810-
811813
@override
812814
bool operator ==(Object other) {
813815
if (other is! AssetEntity) {
814816
return false;
815817
}
816818
return latitude == other.latitude && longitude == other.longitude;
817819
}
820+
821+
@override
822+
int get hashCode => latitude.hashCode ^ longitude.hashCode;
818823
}

lib/src/types/thumbnail.dart

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// in the LICENSE file.
44

55
import 'package:flutter/foundation.dart';
6-
import 'package:flutter/rendering.dart';
76

87
import '../internal/constants.dart';
98
import '../internal/enums.dart';
@@ -43,7 +42,7 @@ class ThumbnailSize {
4342
}
4443

4544
@override
46-
int get hashCode => hashValues(width, height);
45+
int get hashCode => width.hashCode ^ height.hashCode;
4746

4847
@override
4948
String toString() => 'ThumbnailSize($width, $height)';
@@ -117,7 +116,8 @@ class ThumbnailOption {
117116
}
118117

119118
@override
120-
int get hashCode => hashValues(size, format, quality, frame);
119+
int get hashCode =>
120+
size.hashCode ^ format.hashCode ^ quality.hashCode ^ frame.hashCode;
121121

122122
@override
123123
bool operator ==(Object other) {
@@ -158,7 +158,10 @@ class _IOSThumbnailOption extends ThumbnailOption {
158158

159159
@override
160160
int get hashCode =>
161-
hashValues(super.hashCode, deliveryMode, resizeMode, resizeContentMode);
161+
super.hashCode ^
162+
deliveryMode.hashCode ^
163+
resizeMode.hashCode ^
164+
resizeContentMode.hashCode;
162165

163166
@override
164167
bool operator ==(Object other) {

0 commit comments

Comments
 (0)