Skip to content

An open-source cross-platform alternative to AirDrop

style: format files

Tien Do Nam234248b393b5
diff --git a/lib/pages/about_page.dart b/lib/pages/about_page.dart
index 7682b22c..730cf7e4 100644
--- a/lib/pages/about_page.dart
+++ b/lib/pages/about_page.dart
@@ -14,7 +14,8 @@ final _body = '''
Currently, this app is available on Android, iOS, macOS, Windows and Linux. You can find all download options on the official homepage.
*The operating system may still gather usage data.
- '''.splitMapJoin(
+ '''
+ .splitMapJoin(
RegExp(r'^', multiLine: true),
onMatch: (_) => '\n',
onNonMatch: (n) => n.trim(),
diff --git a/lib/pages/changelog_page.dart b/lib/pages/changelog_page.dart
index b5f05ae7..ff14c8d7 100644
--- a/lib/pages/changelog_page.dart
+++ b/lib/pages/changelog_page.dart
@@ -22,7 +22,7 @@ class ChangelogPage extends StatelessWidget {
return Markdown(
data: data.data!,
);
- }
+ },
),
);
}
diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart
index 41655eac..f36da814 100644
--- a/lib/pages/home_page.dart
+++ b/lib/pages/home_page.dart
@@ -95,13 +95,19 @@ class _HomePageState extends ConsumerState<HomePage> {
onDestinationSelected: _goToPage,
extended: sizingInformation.isDesktop,
backgroundColor: Theme.of(context).cardColorWithElevation,
- leading: sizingInformation.isDesktop ? Column(
- children: const [
- SizedBox(height: 20),
- Text('LocalSend', style: TextStyle(fontSize: 32, fontWeight: FontWeight.bold), textAlign: TextAlign.center,),
- SizedBox(height: 20),
- ],
- ) : null,
+ leading: sizingInformation.isDesktop
+ ? Column(
+ children: const [
+ SizedBox(height: 20),
+ Text(
+ 'LocalSend',
+ style: TextStyle(fontSize: 32, fontWeight: FontWeight.bold),
+ textAlign: TextAlign.center,
+ ),
+ SizedBox(height: 20),
+ ],
+ )
+ : null,
destinations: HomeTab.values.map((tab) {
return NavigationRailDestination(
icon: Icon(tab.icon),
@@ -142,13 +148,15 @@ class _HomePageState extends ConsumerState<HomePage> {
],
),
),
- bottomNavigationBar: sizingInformation.isMobile ? NavigationBar(
- selectedIndex: _currentTab.index,
- onDestinationSelected: _goToPage,
- destinations: HomeTab.values.map((tab) {
- return NavigationDestination(icon: Icon(tab.icon), label: tab.label);
- }).toList(),
- ) : null,
+ bottomNavigationBar: sizingInformation.isMobile
+ ? NavigationBar(
+ selectedIndex: _currentTab.index,
+ onDestinationSelected: _goToPage,
+ destinations: HomeTab.values.map((tab) {
+ return NavigationDestination(icon: Icon(tab.icon), label: tab.label);
+ }).toList(),
+ )
+ : null,
);
},
),
diff --git a/lib/pages/receive_options_page.dart b/lib/pages/receive_options_page.dart
index 64069fd3..e7d7a4a5 100644
--- a/lib/pages/receive_options_page.dart
+++ b/lib/pages/receive_options_page.dart
@@ -103,9 +103,7 @@ class _ReceiveOptionsPageState extends ConsumerState<ReceiveOptionsPage> {
softWrap: false,
),
Text(
- '${!selectState.containsKey(file.file.id)
- ? t.general.skipped
- : (selectState[file.file.id] == file.file.fileName ? t.general.unchanged : t.general.renamed)} - ${file.file.size.asReadableFileSize}',
+ '${!selectState.containsKey(file.file.id) ? t.general.skipped : (selectState[file.file.id] == file.file.fileName ? t.general.unchanged : t.general.renamed)} - ${file.file.size.asReadableFileSize}',
style: TextStyle(
color: !selectState.containsKey(file.file.id)
? Colors.grey
@@ -120,18 +118,20 @@ class _ReceiveOptionsPageState extends ConsumerState<ReceiveOptionsPage> {
mainAxisSize: MainAxisSize.min,
children: [
CustomIconButton(
- onPressed: selectState[file.file.id] == null ? null : () async {
- final result = await showDialog<String>(
- context: context,
- builder: (_) => FileNameInputDialog(
- originalName: file.file.fileName,
- initialName: selectState[file.file.id]!,
- ),
- );
- if (result != null) {
- ref.read(selectedReceivingFilesProvider.notifier).rename(file.file.id, result);
- }
- },
+ onPressed: selectState[file.file.id] == null
+ ? null
+ : () async {
+ final result = await showDialog<String>(
+ context: context,
+ builder: (_) => FileNameInputDialog(
+ originalName: file.file.fileName,
+ initialName: selectState[file.file.id]!,
+ ),
+ );
+ if (result != null) {
+ ref.read(selectedReceivingFilesProvider.notifier).rename(file.file.id, result);
+ }
+ },
child: const Icon(Icons.edit),
),
Checkbox(
diff --git a/lib/pages/receive_page.dart b/lib/pages/receive_page.dart
index 9de0ad08..036df196 100644
--- a/lib/pages/receive_page.dart
+++ b/lib/pages/receive_page.dart
@@ -127,7 +127,9 @@ class _ReceivePageState extends ConsumerState<ReceivePage> {
),
const SizedBox(height: 40),
Text(
- _message != null ? (_isLink ? t.receivePage.subTitleLink : t.receivePage.subTitleMessage) : t.receivePage.subTitle(n: receiveState.files.length),
+ _message != null
+ ? (_isLink ? t.receivePage.subTitleLink : t.receivePage.subTitleMessage)
+ : t.receivePage.subTitle(n: receiveState.files.length),
style: smallUi ? null : Theme.of(context).textTheme.headline6,
textAlign: TextAlign.center,
),
@@ -199,24 +201,22 @@ class _ReceivePageState extends ConsumerState<ReceivePage> {
label: Text(t.receiveOptionsPage.title),
),
),
- if (receiveState.status == SessionStatus.canceledBySender)
- ...[
- Padding(
- padding: const EdgeInsets.only(bottom: 20),
- child: Text(t.receivePage.canceled, style: const TextStyle(color: Colors.orange), textAlign: TextAlign.center),
- ),
- Center(
- child: ElevatedButton.icon(
- onPressed: () {
- ref.read(serverProvider.notifier).closeSession();
- context.pop();
- },
- icon: const Icon(Icons.check_circle),
- label: Text(t.general.close),
- ),
+ if (receiveState.status == SessionStatus.canceledBySender) ...[
+ Padding(
+ padding: const EdgeInsets.only(bottom: 20),
+ child: Text(t.receivePage.canceled, style: const TextStyle(color: Colors.orange), textAlign: TextAlign.center),
+ ),
+ Center(
+ child: ElevatedButton.icon(
+ onPressed: () {
+ ref.read(serverProvider.notifier).closeSession();
+ context.pop();
+ },
+ icon: const Icon(Icons.check_circle),
+ label: Text(t.general.close),
),
- ]
- else if (_message != null)
+ ),
+ ] else if (_message != null)
Center(
child: TextButton.icon(
style: TextButton.styleFrom(
@@ -252,13 +252,15 @@ class _ReceivePageState extends ConsumerState<ReceivePage> {
backgroundColor: Theme.of(context).buttonTheme.colorScheme!.primary,
foregroundColor: Theme.of(context).buttonTheme.colorScheme!.onPrimary,
),
- onPressed: selectedFiles.isEmpty ? null : () {
- _accept(ref, receiveState);
- context.pushAndRemoveUntilImmediately(
- removeUntil: ReceivePage,
- builder: () => const ProgressPage(),
- );
- },
+ onPressed: selectedFiles.isEmpty
+ ? null
+ : () {
+ _accept(ref, receiveState);
+ context.pushAndRemoveUntilImmediately(
+ removeUntil: ReceivePage,
+ builder: () => const ProgressPage(),
+ );
+ },
icon: const Icon(Icons.check_circle),
label: Text(t.general.accept),
),
@@ -267,7 +269,7 @@ class _ReceivePageState extends ConsumerState<ReceivePage> {
],
),
);
- }
+ },
),
),
),
diff --git a/lib/pages/selected_files_page.dart b/lib/pages/selected_files_page.dart
index a047221a..db8a0ffd 100644
--- a/lib/pages/selected_files_page.dart
+++ b/lib/pages/selected_files_page.dart
@@ -57,9 +57,7 @@ class SelectedFilesPage extends ConsumerWidget {
splashFactory: NoSplash.splashFactory,
highlightColor: Colors.transparent,
hoverColor: Colors.transparent,
- onTap: file.path != null
- ? () => OpenFilex.open(file.path)
- : null,
+ onTap: file.path != null ? () => OpenFilex.open(file.path) : null,
child: Card(
child: Padding(
padding: const EdgeInsets.all(10),
diff --git a/lib/pages/tabs/receive_tab.dart b/lib/pages/tabs/receive_tab.dart
index 361a3ae4..2346649f 100644
--- a/lib/pages/tabs/receive_tab.dart
+++ b/lib/pages/tabs/receive_tab.dart
@@ -69,7 +69,9 @@ class _ReceiveTagState extends ConsumerState<ReceiveTab> with AutomaticKeepAlive
duration: const Duration(milliseconds: 300),
delay: const Duration(milliseconds: 500),
child: Text(
- serverState == null ? t.general.offline : networkInfo?.localIps.map((ip) => '#${ip.visualId}').toSet().join(' ') ?? '?',
+ serverState == null
+ ? t.general.offline
+ : networkInfo?.localIps.map((ip) => '#${ip.visualId}').toSet().join(' ') ?? '?',
style: const TextStyle(fontSize: 24),
),
),
@@ -85,10 +87,12 @@ class _ReceiveTagState extends ConsumerState<ReceiveTab> with AutomaticKeepAlive
padding: const EdgeInsets.only(bottom: 20, top: 10),
child: Center(
child: ElevatedButton(
- style: settings.quickSave ? ElevatedButton.styleFrom(
- backgroundColor: Theme.of(context).buttonTheme.colorScheme!.primary,
- foregroundColor: Theme.of(context).buttonTheme.colorScheme!.onPrimary,
- ) : null,
+ style: settings.quickSave
+ ? ElevatedButton.styleFrom(
+ backgroundColor: Theme.of(context).buttonTheme.colorScheme!.primary,
+ foregroundColor: Theme.of(context).buttonTheme.colorScheme!.onPrimary,
+ )
+ : null,
onPressed: () {
ref.read(settingsProvider.notifier).setQuickSave(!settings.quickSave);
if (!settings.quickSave) {
@@ -139,8 +143,7 @@ class _ReceiveTagState extends ConsumerState<ReceiveTab> with AutomaticKeepAlive
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- if (networkInfo?.localIps.isEmpty ?? true)
- Text(t.general.unknown),
+ if (networkInfo?.localIps.isEmpty ?? true) Text(t.general.unknown),
...?networkInfo?.localIps.map((ip) => Text(ip)),
],
),
diff --git a/lib/provider/network/server_provider.dart b/lib/provider/network/server_provider.dart
index 8549fd56..c25d1812 100644
--- a/lib/provider/network/server_provider.dart
+++ b/lib/provider/network/server_provider.dart
@@ -155,8 +155,7 @@ class ServerNotifier extends StateNotifier<ServerState?> {
if (settings.quickSave) {
// accept all files
selection = {
- for (final f in dto.files.values)
- f.id: f.fileName,
+ for (final f in dto.files.values) f.id: f.fileName,
};
} else {
// ignore: use_build_context_synchronously
@@ -248,10 +247,13 @@ class ServerNotifier extends StateNotifier<ServerState?> {
// begin of actual file transfer
state = state?.copyWith(
receiveState: receiveState.copyWith(
- files: {...receiveState.files}..update(fileId, (_) => receivingFile.copyWith(
- status: FileStatus.sending,
- token: null, // remove token to reject further uploads of the same file
- )),
+ files: {...receiveState.files}..update(
+ fileId,
+ (_) => receivingFile.copyWith(
+ status: FileStatus.sending,
+ token: null, // remove token to reject further uploads of the same file
+ ),
+ ),
startTime: receiveState.startTime ?? DateTime.now().millisecondsSinceEpoch,
),
);
@@ -434,10 +436,15 @@ extension on ReceiveState {
required String? path,
required bool savedToGallery,
}) {
- return copyWith(files: {...files}..update(fileId, (file) => file.copyWith(
- status: status,
- path: path,
- savedToGallery: savedToGallery,
- )));
+ return copyWith(
+ files: {...files}..update(
+ fileId,
+ (file) => file.copyWith(
+ status: status,
+ path: path,
+ savedToGallery: savedToGallery,
+ ),
+ ),
+ );
}
}
diff --git a/lib/provider/network_info_provider.dart b/lib/provider/network_info_provider.dart
index 981efa81..fc57ca71 100644
--- a/lib/provider/network_info_provider.dart
+++ b/lib/provider/network_info_provider.dart
@@ -27,7 +27,7 @@ class NetworkInfoNotifier extends StateNotifier<NetworkInfo?> {
state = await _getInfo();
});
} else {
- _subscription = Connectivity().onConnectivityChanged.listen((_) async {
+ _subscription = Connectivity().onConnectivityChanged.listen((_) async {
state = await _getInfo();
});
}
@@ -92,4 +92,4 @@ extension ListIpExt on List<String> {
return scoreB.compareTo(scoreA);
});
}
-}
\ No newline at end of file
+}
diff --git a/lib/provider/progress_provider.dart b/lib/provider/progress_provider.dart
index 9cca6ba4..69a627a0 100644
--- a/lib/provider/progress_provider.dart
+++ b/lib/provider/progress_provider.dart
@@ -5,7 +5,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
/// It is implemented as [ChangeNotifier] for performance reasons.
final progressProvider = ChangeNotifierProvider((ref) => ProgressNotifier());
-class ProgressNotifier extends ChangeNotifier {
+class ProgressNotifier extends ChangeNotifier {
final _progressMap = <String, double>{}; // file id -> 0..1
void setProgress(String fileId, double progress) {
diff --git a/lib/util/file_picker.dart b/lib/util/file_picker.dart
index 88ee3757..28472825 100644
--- a/lib/util/file_picker.dart
+++ b/lib/util/file_picker.dart
@@ -35,9 +35,9 @@ enum FilePickerOption {
final result = await FilePicker.platform.pickFiles(allowMultiple: true);
if (result != null) {
ref.read(selectedSendingFilesProvider.notifier).addFiles(
- files: result.files,
- converter: CrossFileConverters.convertPlatformFile,
- );
+ files: result.files,
+ converter: CrossFileConverters.convertPlatformFile,
+ );
}
break;
case FilePickerOption.media:
@@ -49,9 +49,9 @@ enum FilePickerOption {
);
if (result != null) {
ref.read(selectedSendingFilesProvider.notifier).addFiles(
- files: result,
- converter: CrossFileConverters.convertAssetEntity,
- );
+ files: result,
+ converter: CrossFileConverters.convertAssetEntity,
+ );
}
break;
case FilePickerOption.text:
diff --git a/lib/util/task_runner.dart b/lib/util/task_runner.dart
index c8104e0e..b58b704d 100644
--- a/lib/util/task_runner.dart
+++ b/lib/util/task_runner.dart
@@ -23,7 +23,7 @@ class TaskRunner<T> {
bool? stayAlive,
this.onFinish,
}) : _queue = Queue()..addAll(initialTasks ?? []),
- _stayAlive = stayAlive ?? initialTasks == null || initialTasks.isEmpty {
+ _stayAlive = stayAlive ?? initialTasks == null || initialTasks.isEmpty {
_fireRunners();
}
diff --git a/lib/widget/animations/initial_fade_transition.dart b/lib/widget/animations/initial_fade_transition.dart
index fc4fd241..aa2a39ad 100644
--- a/lib/widget/animations/initial_fade_transition.dart
+++ b/lib/widget/animations/initial_fade_transition.dart
@@ -18,7 +18,6 @@ class InitialFadeTransition extends StatefulWidget {
}
class _InitialFadeTransitionState extends State<InitialFadeTransition> {
-
double _opacity = 0;
@override
diff --git a/lib/widget/life_cycle_watcher.dart b/lib/widget/life_cycle_watcher.dart
index e6fb6048..728fea7f 100644
--- a/lib/widget/life_cycle_watcher.dart
+++ b/lib/widget/life_cycle_watcher.dart
@@ -10,7 +10,7 @@ class LifeCycleWatcher extends StatefulWidget {
State<LifeCycleWatcher> createState() => _LifeCycleWatcherState();
}
-class _LifeCycleWatcherState extends State<LifeCycleWatcher> with WidgetsBindingObserver {
+class _LifeCycleWatcherState extends State<LifeCycleWatcher> with WidgetsBindingObserver {
@override
Widget build(BuildContext context) {
return widget.child;
diff --git a/lib/widget/list_tile/custom_list_tile.dart b/lib/widget/list_tile/custom_list_tile.dart
index 4c0ffe25..94015b26 100644
--- a/lib/widget/list_tile/custom_list_tile.dart
+++ b/lib/widget/list_tile/custom_list_tile.dart
@@ -49,8 +49,7 @@ class CustomListTile extends StatelessWidget {
],
),
),
- if (trailing != null)
- trailing!,
+ if (trailing != null) trailing!,
],
),
),
diff --git a/lib/widget/responsive_list_view.dart b/lib/widget/responsive_list_view.dart
index 1c10a50c..47329382 100644
--- a/lib/widget/responsive_list_view.dart
+++ b/lib/widget/responsive_list_view.dart
@@ -29,16 +29,17 @@ class ResponsiveListView extends StatelessWidget {
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: maxWidth),
child: ResponsiveBuilder(
- breakpoints: defaultBreakpoints,
- builder: (context, sizingInformation) {
- return Padding(
- padding: sizingInformation.isDesktop ? desktopPadding : padding,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: children,
- ),
- );
- }),
+ breakpoints: defaultBreakpoints,
+ builder: (context, sizingInformation) {
+ return Padding(
+ padding: sizingInformation.isDesktop ? desktopPadding : padding,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: children,
+ ),
+ );
+ },
+ ),
),
),
);
diff --git a/test/unit/provider/network_info_provider_test.dart b/test/unit/provider/network_info_provider_test.dart
index 350cd9f1..793eb07d 100644
--- a/test/unit/provider/network_info_provider_test.dart
+++ b/test/unit/provider/network_info_provider_test.dart
@@ -12,11 +12,11 @@ void main() {
});
test('should sort primary first', () {
- expect(rankIpAddresses(['123.456', '222.1', '321.222'], '123.123'), ['123.123','123.456', '321.222', '222.1']);
+ expect(rankIpAddresses(['123.456', '222.1', '321.222'], '123.123'), ['123.123', '123.456', '321.222', '222.1']);
});
test('should sort primary first and remove duplicates', () {
- expect(rankIpAddresses(['123.456', '123.123', '222.1', '222.1', '321.222'], '123.123'), ['123.123','123.456', '321.222', '222.1']);
+ expect(rankIpAddresses(['123.456', '123.123', '222.1', '222.1', '321.222'], '123.123'), ['123.123', '123.456', '321.222', '222.1']);
});
});
}