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;
|
|
}
|