hui-z / image_gallery_saver

flutter中用于保存图片到相册的Plugin
MIT License
275 stars 377 forks source link

image_gallery_saver.dart may need to import 'dart:typed_data' #264

Closed Howard2595 closed 11 months ago

Howard2595 commented 1 year ago

When I run the project, the console throws an error like 'Error: Type 'Uint8List' not found.'.

I later found that the 'image_gallery_saver.dart' file did not include the 'dart:typed_data' import statement at the top.

Similar to the code below.

import 'dart:async';
import 'dart:typed_data';

import 'package:flutter/services.dart';

class ImageGallerySaver {
  // ... Omitting relevant code
  static FutureOr<dynamic> saveImage(Uint8List imageBytes,
      {int quality = 80,
      String? name,
      bool isReturnImagePathOfIOS = false}) async {
      // ... Omitting relevant code
  }
  // ... Omitting relevant code
}

Hope you can consider.

woodwen commented 1 year ago

The import of 'dart:typed_data' is unnecessary because all of the used elements are also provided by the import of 'package:flutter/services.dart'

Howard2595 commented 1 year ago

Hi @woodwen , Thanks for your reply.

I'm not sure about the latest version of Flutter, is it okay to directly import 'package:flutter/services.dart'? However, it doesn't work with my current Flutter version (v2.10.0).

woodwen commented 1 year ago

The current development version of image_gallery_saver uses flutter 3.10.5. Each subsequent flutter version upgrade will be marked in the readme.

Howard2595 commented 1 year ago

Hi @woodwen, I didn't find any specific Min Dart SDK requirements on pub.package, and I noticed that in the pubspec.yaml file, it's written as flutter: ">=1.17.0", which doesn't restrict users from using older versions of Flutter. So, can we consider adding 'dart:typed_data' for now, and later, after restricting the Flutter version, we can remove it?

maruzimuslih commented 1 year ago

Hi @woodwen , i have the same issue here. I use 2.10.1 flutter version, and i can't build my app. I think @Howard2595 suggestion is good and reasonable. Hopefully you can consider it. Thank you

Go-oG commented 11 months ago

We're waiting for the PR270 merger when that issue will be resolved