mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
Remove SFTP download
This commit is contained in:
15
lib/core/extension/numx.dart
Normal file
15
lib/core/extension/numx.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
extension NumX on num {
|
||||
String get convertBytes {
|
||||
const suffix = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
double value = toDouble();
|
||||
int squareTimes = 0;
|
||||
for (; value / 1024 > 1 && squareTimes < suffix.length - 1; squareTimes++) {
|
||||
value /= 1024;
|
||||
}
|
||||
var finalValue = value.toStringAsFixed(1);
|
||||
if (finalValue.endsWith('.0')) {
|
||||
finalValue = finalValue.replaceFirst('.0', '');
|
||||
}
|
||||
return '$finalValue ${suffix[squareTimes]}';
|
||||
}
|
||||
}
|
||||
12
lib/core/path.dart
Normal file
12
lib/core/path.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
Future<Directory> get sftpDownloadDir async {
|
||||
final docDir = await getApplicationDocumentsDirectory();
|
||||
final dir = Directory('${docDir.path}/sftp');
|
||||
if (!dir.existsSync()) {
|
||||
dir.createSync();
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
Reference in New Issue
Block a user