new: Providers

This commit is contained in:
lollipopkit
2023-09-14 15:13:11 +08:00
parent eb158e63a2
commit c07958fa73
29 changed files with 206 additions and 218 deletions

View File

@@ -6,13 +6,10 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:plain_notification_token/plain_notification_token.dart';
import 'package:share_plus/share_plus.dart';
import 'package:toolbox/data/res/provider.dart';
import '../../data/provider/app.dart';
import '../../locator.dart';
import 'platform.dart';
final _app = locator<AppProvider>();
Future<bool> shareFiles(BuildContext context, List<String> filePaths) async {
for (final filePath in filePaths) {
if (!await File(filePath).exists()) {
@@ -25,10 +22,10 @@ Future<bool> shareFiles(BuildContext context, List<String> filePaths) async {
} else {
text = '${filePaths.length} ${S.of(context)!.files}';
}
_app.moveBg = false;
Providers.app.moveBg = false;
// ignore: deprecated_member_use
await Share.shareFiles(filePaths, subject: 'ServerBox -> $text');
_app.moveBg = true;
Providers.app.moveBg = true;
return filePaths.isNotEmpty;
}
@@ -37,9 +34,9 @@ void copy2Clipboard(String text) {
}
Future<String?> pickOneFile() async {
_app.moveBg = false;
Providers.app.moveBg = false;
final result = await FilePicker.platform.pickFiles(type: FileType.any);
_app.moveBg = true;
Providers.app.moveBg = true;
return result?.files.single.path;
}