Compare commits

...

10 Commits

Author SHA1 Message Date
steevedevops
cf06426301 Changes to be committed:
modified:   android/build.gradle
	modified:   android/src/main/kotlin/com/morbit/photogallery/PhotoGalleryPlugin.kt
2025-04-29 14:10:22 -03:00
Abdulraheem Ahmad
9c6648f162 fixing kotlin reference isue 2025-04-09 23:40:29 +01:00
Abdulraheem Ahmad
aad761dc3d fixing kotlin reference isue 2025-04-09 23:21:40 +01:00
Abdulraheem Ahmad
5e3df961e6
Update AndroidManifest.xml 2024-08-30 06:07:51 +01:00
Abdulraheem Ahmad
441b95e20e
Update build.gradle 2024-08-29 12:35:57 +01:00
Wenqi Li
96f487bf99 update .gitignore 2024-05-23 22:59:53 +08:00
Wenqi Li
e026f68e80 remove library identifier 2024-03-27 03:42:32 +08:00
Wenqi Li
924dc92946 reformat code 2024-03-25 21:17:22 +08:00
Wenqi Li
4be94e2058 release version 2.2.1 2024-03-25 03:40:53 +08:00
Wenqi Li
e8c1d71d0a Upgrade flutter_lints dependency. Lint code according to the use_string_in_part_of_directives rule. 2024-03-25 03:38:36 +08:00
24 changed files with 428 additions and 101 deletions

60
.gitignore vendored
View File

@ -8,6 +8,7 @@
.buildlog/ .buildlog/
.history .history
.svn/ .svn/
migrate_working_dir/
# IntelliJ related # IntelliJ related
*.iml *.iml
@ -15,61 +16,14 @@
*.iws *.iws
.idea/ .idea/
# Visual Studio Code related # The .vscode folder contains launch configuration and tasks you configure in
.vscode/ # VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related # Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/ **/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/ .dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
pubspec.lock
build/ build/
# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/Flutter/flutter_export_environment.sh
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

View File

@ -1,3 +1,9 @@
# 2.2.1
Upgrade ```flutter_lints``` dependency, and then lint code according to the ```public_member_api_docs``` and ```use_string_in_part_of_directives``` rule.
Make ```AlbumPageState``` widget private.
## 2.2.0 ## 2.2.0
Add GitHub Actions configuration to automatically publish to ```pub.dev``` from ```Github```. Add GitHub Actions configuration to automatically publish to ```pub.dev``` from ```Github```.

1
android/.gitignore vendored
View File

@ -6,3 +6,4 @@
.DS_Store .DS_Store
/build /build
/captures /captures
.cxx

View File

@ -2,7 +2,7 @@ group 'com.morbit.photogallery'
version '1.0-SNAPSHOT' version '1.0-SNAPSHOT'
buildscript { buildscript {
ext.kotlin_version = '1.7.10' ext.kotlin_version = '1.9.0'
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
@ -25,6 +25,8 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
android { android {
namespace 'com.morbit.photogallery'
compileSdkVersion 33 compileSdkVersion 33
compileOptions { compileOptions {
@ -41,7 +43,7 @@ android {
} }
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 21
} }
lintOptions { lintOptions {
@ -51,4 +53,4 @@ android {
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
} }

View File

@ -1 +1 @@
<manifest package="com.morbit.photogallery"></manifest> <manifest></manifest>

View File

@ -19,7 +19,7 @@ import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.MethodCallHandler import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result import io.flutter.plugin.common.MethodChannel.Result
import io.flutter.plugin.common.PluginRegistry.Registrar // import io.flutter.plugin.common.PluginRegistry.Registrar
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
@ -39,14 +39,6 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
// them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called // them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called
// depending on the user's project. onAttachedToEngine or registerWith must both be defined // depending on the user's project. onAttachedToEngine or registerWith must both be defined
// in the same class. // in the same class.
@JvmStatic
fun registerWith(registrar: Registrar) {
val channel = MethodChannel(registrar.messenger(), "photo_gallery")
val plugin = PhotoGalleryPlugin()
plugin.context = registrar.activeContext()
channel.setMethodCallHandler(plugin)
}
const val imageType = "image" const val imageType = "image"
const val videoType = "video" const val videoType = "video"

12
example/.gitignore vendored
View File

@ -8,6 +8,7 @@
.buildlog/ .buildlog/
.history .history
.svn/ .svn/
migrate_working_dir/
# IntelliJ related # IntelliJ related
*.iml *.iml
@ -22,22 +23,21 @@
# Flutter/Dart/Pub related # Flutter/Dart/Pub related
**/doc/api/ **/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/ .dart_tool/
.flutter-plugins .flutter-plugins
.flutter-plugins-dependencies .flutter-plugins-dependencies
.packages
.pub-cache/ .pub-cache/
.pub/ .pub/
/build/ /build/
# Web related
lib/generated_plugin_registrant.dart
# Symbolication related # Symbolication related
app.*.symbols app.*.symbols
# Obfuscation related # Obfuscation related
app.*.map.json app.*.map.json
# Exceptions to above rules. # Android Studio will place build artifacts here
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages /android/app/debug
/android/app/profile
/android/app/release

View File

@ -5,3 +5,9 @@ gradle-wrapper.jar
/gradlew.bat /gradlew.bat
/local.properties /local.properties
GeneratedPluginRegistrant.java GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks

View File

@ -1,3 +1,4 @@
**/dgph
*.mode1v3 *.mode1v3
*.mode2v3 *.mode2v3
*.moved-aside *.moved-aside
@ -18,6 +19,7 @@ Flutter/App.framework
Flutter/Flutter.framework Flutter/Flutter.framework
Flutter/Flutter.podspec Flutter/Flutter.podspec
Flutter/Generated.xcconfig Flutter/Generated.xcconfig
Flutter/ephemeral/
Flutter/app.flx Flutter/app.flx
Flutter/app.zip Flutter/app.zip
Flutter/flutter_assets/ Flutter/flutter_assets/

View File

@ -43,7 +43,8 @@ class _MyAppState extends State<MyApp> {
Future<bool> _promptPermissionSetting() async { Future<bool> _promptPermissionSetting() async {
if (Platform.isIOS) { if (Platform.isIOS) {
if (await Permission.photos.request().isGranted || await Permission.storage.request().isGranted) { if (await Permission.photos.request().isGranted ||
await Permission.storage.request().isGranted) {
return true; return true;
} }
} }
@ -84,7 +85,9 @@ class _MyAppState extends State<MyApp> {
...?_albums?.map( ...?_albums?.map(
(album) => GestureDetector( (album) => GestureDetector(
onTap: () => Navigator.of(context).push( onTap: () => Navigator.of(context).push(
MaterialPageRoute(builder: (context) => AlbumPage(album)), MaterialPageRoute(
builder: (context) => AlbumPage(album),
),
), ),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
@ -96,7 +99,8 @@ class _MyAppState extends State<MyApp> {
width: gridWidth, width: gridWidth,
child: FadeInImage( child: FadeInImage(
fit: BoxFit.cover, fit: BoxFit.cover,
placeholder: MemoryImage(kTransparentImage), placeholder:
MemoryImage(kTransparentImage),
image: AlbumThumbnailProvider( image: AlbumThumbnailProvider(
album: album, album: album,
highQuality: true, highQuality: true,
@ -308,7 +312,9 @@ class _VideoProviderState extends State<VideoProvider> {
TextButton( TextButton(
onPressed: () { onPressed: () {
setState(() { setState(() {
_controller!.value.isPlaying ? _controller!.pause() : _controller!.play(); _controller!.value.isPlaying
? _controller!.pause()
: _controller!.play();
}); });
}, },
child: Icon( child: Icon(

329
example/pubspec.lock Normal file
View File

@ -0,0 +1,329 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
characters:
dependency: transitive
description:
name: characters
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
clock:
dependency: transitive
description:
name: clock
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
url: "https://pub.dev"
source: hosted
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.18.0"
csslib:
dependency: transitive
description:
name: csslib
sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d
url: "https://pub.dev"
source: hosted
version: "1.0.6"
fake_async:
dependency: transitive
description:
name: fake_async
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
url: "https://pub.dev"
source: hosted
version: "1.3.1"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
html:
dependency: transitive
description:
name: html
sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a"
url: "https://pub.dev"
source: hosted
version: "0.15.4"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.dev"
source: hosted
version: "2.0.1"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.dev"
source: hosted
version: "2.0.1"
matcher:
dependency: transitive
description:
name: matcher
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.8.0"
meta:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.11.0"
path:
dependency: transitive
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
permission_handler:
dependency: "direct main"
description:
name: permission_handler
sha256: bc56bfe9d3f44c3c612d8d393bd9b174eb796d706759f9b495ac254e4294baa5
url: "https://pub.dev"
source: hosted
version: "10.4.5"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
sha256: "59c6322171c29df93a22d150ad95f3aa19ed86542eaec409ab2691b8f35f9a47"
url: "https://pub.dev"
source: hosted
version: "10.3.6"
permission_handler_apple:
dependency: transitive
description:
name: permission_handler_apple
sha256: "99e220bce3f8877c78e4ace901082fb29fa1b4ebde529ad0932d8d664b34f3f5"
url: "https://pub.dev"
source: hosted
version: "9.1.4"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
sha256: "6760eb5ef34589224771010805bea6054ad28453906936f843a8cc4d3a55c4a4"
url: "https://pub.dev"
source: hosted
version: "3.12.0"
permission_handler_windows:
dependency: transitive
description:
name: permission_handler_windows
sha256: cc074aace208760f1eee6aa4fae766b45d947df85bc831cde77009cdb4720098
url: "https://pub.dev"
source: hosted
version: "0.1.3"
photo_gallery:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "2.2.1"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
version: "2.1.8"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_span:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
transparent_image:
dependency: "direct main"
description:
name: transparent_image
sha256: e8991d955a2094e197ca24c645efec2faf4285772a4746126ca12875e54ca02f
url: "https://pub.dev"
source: hosted
version: "2.0.1"
vector_math:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
video_player:
dependency: "direct main"
description:
name: video_player
sha256: afc65f4b8bcb2c188f64a591f84fb471f4f2e19fc607c65fd8d2f8fedb3dec23
url: "https://pub.dev"
source: hosted
version: "2.8.3"
video_player_android:
dependency: transitive
description:
name: video_player_android
sha256: "4dd9b8b86d70d65eecf3dcabfcdfbb9c9115d244d022654aba49a00336d540c2"
url: "https://pub.dev"
source: hosted
version: "2.4.12"
video_player_avfoundation:
dependency: transitive
description:
name: video_player_avfoundation
sha256: "309e3962795e761be010869bae65c0b0e45b5230c5cee1bec72197ca7db040ed"
url: "https://pub.dev"
source: hosted
version: "2.5.6"
video_player_platform_interface:
dependency: transitive
description:
name: video_player_platform_interface
sha256: "236454725fafcacf98f0f39af0d7c7ab2ce84762e3b63f2cbb3ef9a7e0550bc6"
url: "https://pub.dev"
source: hosted
version: "6.2.2"
video_player_web:
dependency: transitive
description:
name: video_player_web
sha256: "41245cef5ef29c4585dbabcbcbe9b209e34376642c7576cabf11b4ad9289d6e4"
url: "https://pub.dev"
source: hosted
version: "2.3.0"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "13.0.0"
web:
dependency: transitive
description:
name: web
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
url: "https://pub.dev"
source: hosted
version: "0.5.1"
sdks:
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.19.0"

1
ios/.gitignore vendored
View File

@ -34,4 +34,5 @@ Icon?
.tags* .tags*
/Flutter/Generated.xcconfig /Flutter/Generated.xcconfig
/Flutter/ephemeral/
/Flutter/flutter_export_environment.sh /Flutter/flutter_export_environment.sh

View File

@ -1,5 +1,3 @@
library photogallery;
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'dart:ui' as ui; import 'dart:ui' as ui;
@ -33,7 +31,9 @@ class PhotoGallery {
'mediumType': mediumTypeToJson(mediumType), 'mediumType': mediumTypeToJson(mediumType),
'hideIfEmpty': hideIfEmpty, 'hideIfEmpty': hideIfEmpty,
}); });
return json.map<Album>((album) => Album.fromJson(album, mediumType, newest)).toList(); return json
.map<Album>((album) => Album.fromJson(album, mediumType, newest))
.toList();
} }
/// List all available media in a specific album, support pagination of media /// List all available media in a specific album, support pagination of media

View File

@ -1,4 +1,4 @@
part of photogallery; part of '../../photo_gallery.dart';
/// A medium type. /// A medium type.
enum MediumType { enum MediumType {

View File

@ -1,4 +1,4 @@
part of photogallery; part of '../../photo_gallery.dart';
/// Fetches the given album thumbnail from the gallery. /// Fetches the given album thumbnail from the gallery.
class AlbumThumbnailProvider extends ImageProvider<AlbumThumbnailProvider> { class AlbumThumbnailProvider extends ImageProvider<AlbumThumbnailProvider> {
@ -33,7 +33,10 @@ class AlbumThumbnailProvider extends ImageProvider<AlbumThumbnailProvider> {
); );
} }
Future<ui.Codec> _loadAsync(AlbumThumbnailProvider key, ImageDecoderCallback decode) async { Future<ui.Codec> _loadAsync(
AlbumThumbnailProvider key,
ImageDecoderCallback decode,
) async {
assert(key == this); assert(key == this);
late ui.ImmutableBuffer buffer; late ui.ImmutableBuffer buffer;
try { try {
@ -47,7 +50,9 @@ class AlbumThumbnailProvider extends ImageProvider<AlbumThumbnailProvider> {
); );
buffer = await ui.ImmutableBuffer.fromUint8List(Uint8List.fromList(data)); buffer = await ui.ImmutableBuffer.fromUint8List(Uint8List.fromList(data));
} catch (e) { } catch (e) {
buffer = await ui.ImmutableBuffer.fromAsset("packages/photo_gallery/images/grey.bmp"); buffer = await ui.ImmutableBuffer.fromAsset(
"packages/photo_gallery/images/grey.bmp",
);
} }
return decode(buffer); return decode(buffer);
} }

View File

@ -1,4 +1,4 @@
part of photogallery; part of '../../photo_gallery.dart';
/// Fetches the given image from the gallery. /// Fetches the given image from the gallery.
class PhotoProvider extends ImageProvider<PhotoProvider> { class PhotoProvider extends ImageProvider<PhotoProvider> {
@ -25,11 +25,15 @@ class PhotoProvider extends ImageProvider<PhotoProvider> {
); );
} }
Future<ui.Codec> _loadAsync(PhotoProvider key, ImageDecoderCallback decode) async { Future<ui.Codec> _loadAsync(
PhotoProvider key,
ImageDecoderCallback decode,
) async {
assert(key == this); assert(key == this);
final file = await PhotoGallery.getFile( final file = await PhotoGallery.getFile(
mediumId: mediumId, mediumType: MediumType.image, mimeType: mimeType); mediumId: mediumId, mediumType: MediumType.image, mimeType: mimeType);
ui.ImmutableBuffer buffer = await ui.ImmutableBuffer.fromFilePath(file.path); ui.ImmutableBuffer buffer =
await ui.ImmutableBuffer.fromFilePath(file.path);
return decode(buffer); return decode(buffer);
} }

View File

@ -1,4 +1,4 @@
part of photogallery; part of '../../photo_gallery.dart';
/// Fetches the given medium thumbnail from the gallery. /// Fetches the given medium thumbnail from the gallery.
class ThumbnailProvider extends ImageProvider<ThumbnailProvider> { class ThumbnailProvider extends ImageProvider<ThumbnailProvider> {
@ -37,7 +37,10 @@ class ThumbnailProvider extends ImageProvider<ThumbnailProvider> {
); );
} }
Future<ui.Codec> _loadAsync(ThumbnailProvider key, ImageDecoderCallback decode) async { Future<ui.Codec> _loadAsync(
ThumbnailProvider key,
ImageDecoderCallback decode,
) async {
assert(key == this); assert(key == this);
late ui.ImmutableBuffer buffer; late ui.ImmutableBuffer buffer;
try { try {
@ -50,7 +53,9 @@ class ThumbnailProvider extends ImageProvider<ThumbnailProvider> {
); );
buffer = await ui.ImmutableBuffer.fromUint8List(Uint8List.fromList(data)); buffer = await ui.ImmutableBuffer.fromUint8List(Uint8List.fromList(data));
} catch (e) { } catch (e) {
buffer = await ui.ImmutableBuffer.fromAsset("packages/photo_gallery/images/grey.bmp"); buffer = await ui.ImmutableBuffer.fromAsset(
"packages/photo_gallery/images/grey.bmp",
);
} }
return decode(buffer); return decode(buffer);
} }

View File

@ -1,4 +1,4 @@
part of photogallery; part of '../../photo_gallery.dart';
/// A album in the gallery. /// A album in the gallery.
@immutable @immutable

View File

@ -1,4 +1,4 @@
part of photogallery; part of '../../photo_gallery.dart';
/// A list of media with pagination support. /// A list of media with pagination support.
@immutable @immutable
@ -33,7 +33,7 @@ class MediaPage {
album: album, album: album,
skip: end, skip: end,
take: items.length, take: items.length,
lightWeight: lightWeight lightWeight: lightWeight,
); );
} }

View File

@ -1,4 +1,4 @@
part of photogallery; part of '../../photo_gallery.dart';
/// A medium in the gallery. /// A medium in the gallery.
/// ///

View File

@ -1,6 +1,6 @@
name: photo_gallery name: photo_gallery
description: A Flutter plugin that retrieves images and videos from mobile native gallery. description: A Flutter plugin that retrieves images and videos from mobile native gallery.
version: 2.2.0 version: 2.2.1
repository: https://github.com/Firelands128/photo_gallery repository: https://github.com/Firelands128/photo_gallery
environment: environment:
@ -20,7 +20,7 @@ dev_dependencies:
# activated in the `analysis_options.yaml` file located at the root of your # activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint # package. See that file for information about deactivating specific lint
# rules and activating additional ones. # rules and activating additional ones.
flutter_lints: ^2.0.0 flutter_lints: ^3.0.0
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # following page: https://dart.dev/tools/pub/pubspec

View File

@ -13,14 +13,16 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
setUp(() { setUp(() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
channel, channel,
mockMethodCallHandler, mockMethodCallHandler,
); );
}); });
tearDown(() { tearDown(() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
channel, channel,
null, null,
); );
@ -30,7 +32,10 @@ void main() {
MediumType mediumType = MediumType.image; MediumType mediumType = MediumType.image;
bool newest = true; bool newest = true;
var result = await PhotoGallery.listAlbums(mediumType: mediumType); var result = await PhotoGallery.listAlbums(mediumType: mediumType);
var expected = Generator.generateAlbums(mediumType: mediumType, newest: newest); var expected = Generator.generateAlbums(
mediumType: mediumType,
newest: newest,
);
expect(result, expected); expect(result, expected);
}); });

View File

@ -25,7 +25,10 @@ class Generator {
]; ];
} }
static List<Album> generateAlbums({MediumType? mediumType, bool newest = true}) { static List<Album> generateAlbums({
MediumType? mediumType,
bool newest = true,
}) {
return Generator.generateAlbumsJson(mediumType: mediumType, newest: newest) return Generator.generateAlbumsJson(mediumType: mediumType, newest: newest)
.map<Album>((x) => Album.fromJson(x, mediumType, newest)) .map<Album>((x) => Album.fromJson(x, mediumType, newest))
.toList(); .toList();
@ -42,7 +45,10 @@ class Generator {
var items = []; var items = [];
int index = skip; int index = skip;
while (index < skip + take) { while (index < skip + take) {
items.add(generateMediaJson(mediumId: index.toString(), mediumType: mediumType)); items.add(generateMediaJson(
mediumId: index.toString(),
mediumType: mediumType,
));
index++; index++;
} }

View File

@ -8,7 +8,10 @@ Future<dynamic> mockMethodCallHandler(MethodCall call) async {
if (call.method == "listAlbums") { if (call.method == "listAlbums") {
MediumType? mediumType = jsonToMediumType(call.arguments['mediumType']); MediumType? mediumType = jsonToMediumType(call.arguments['mediumType']);
bool newest = call.arguments['newest']; bool newest = call.arguments['newest'];
dynamic albums = Generator.generateAlbumsJson(mediumType: mediumType, newest: newest); dynamic albums = Generator.generateAlbumsJson(
mediumType: mediumType,
newest: newest,
);
return albums; return albums;
} else if (call.method == "listMedia") { } else if (call.method == "listMedia") {
String albumId = call.arguments['albumId']; String albumId = call.arguments['albumId'];