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

import 'dart:io';
import 'dart:typed_data';
import 'package:path_provider/path_provider.dart';
Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;
}
Future<File> _localFile(String fileName) async {
final path = await _localPath;
return File('$path/$fileName');
}
Future<File> writeImage(String fileName, Uint8List data) async {
final file = await _localFile(fileName);
// Write the file
return file.writeAsBytes(data);
}
String getExtension(String fileName) {
return fileName.split('.').last;
}