Encrypted messaging app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
588 B

  1. import 'dart:io';
  2. import 'dart:typed_data';
  3. import 'package:path_provider/path_provider.dart';
  4. Future<String> get _localPath async {
  5. final directory = await getApplicationDocumentsDirectory();
  6. return directory.path;
  7. }
  8. Future<File> _localFile(String fileName) async {
  9. final path = await _localPath;
  10. return File('$path/$fileName');
  11. }
  12. Future<File> writeImage(String fileName, Uint8List data) async {
  13. final file = await _localFile(fileName);
  14. // Write the file
  15. return file.writeAsBytes(data);
  16. }
  17. String getExtension(String fileName) {
  18. return fileName.split('.').last;
  19. }