Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.dart text eol=lf
*.yaml text eol=lf
*.yml text eol=lf
33 changes: 33 additions & 0 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: flutter analysis

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
submodules: recursive

- uses: subosito/flutter-action@v2
with:
channel: stable

- name: Install dependencies
run: flutter pub get

- name: Check formatting
run: dart format --output=none --set-exit-if-changed lib test

- name: Analyze project source
run: flutter analyze lib test

- name: Run tests
run: flutter test
2 changes: 1 addition & 1 deletion lib/models/global_stat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class GlobalStat {
int uploadSpeed = 0;
int totalCompletedLength = 0;
int totalLength = 0;
}
}
6 changes: 4 additions & 2 deletions lib/pages/builtin_instance_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import '../services/builtin_instance_service.dart';
import '../services/instance_manager.dart';
import '../services/settings_service.dart';
import '../services/tracker_sync_service.dart';
import '../utils/logging.dart';
import 'components/builtin_settings_apply_hint_card.dart';
import 'download_page/components/directory_picker.dart';

Expand All @@ -22,6 +23,7 @@ class BuiltinInstanceSettingsPage extends StatefulWidget {

class _BuiltinInstanceSettingsPageState
extends State<BuiltinInstanceSettingsPage> {
final _logger = taggedLogger('BuiltinInstanceSettingsPage');
bool _hasChanges = false;
bool _isSaving = false;
bool _isResettingSession = false;
Expand Down Expand Up @@ -1062,7 +1064,7 @@ class _BuiltinInstanceSettingsPageState

_showSettingsSnackBar(l10n.settingsSaved);
} catch (e, stackTrace) {
this.e(
_logger.e(
'Failed to save built-in instance settings',
error: e,
stackTrace: stackTrace,
Expand Down Expand Up @@ -1092,7 +1094,7 @@ class _BuiltinInstanceSettingsPageState
_syncNormalizedDraft(settings);
await _refreshBuiltinInstanceSnapshot();
} catch (e, stackTrace) {
this.e(
_logger.e(
'Failed to persist built-in instance settings before applying',
error: e,
stackTrace: stackTrace,
Expand Down
12 changes: 9 additions & 3 deletions lib/pages/download_page/models/download_task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,18 @@ class DownloadTask {
uploadLengthBytes: json['uploadLengthBytes'] ?? 0,
downloadSpeedBytes: json['downloadSpeedBytes'] ?? 0,
uploadSpeedBytes: json['uploadSpeedBytes'] ?? 0,
files: json['files'] != null ? List<Map<String, dynamic>>.from(json['files']) : null,
files: json['files'] != null
? List<Map<String, dynamic>>.from(json['files'])
: null,
bittorrentInfo: json['bittorrentInfo'],
trackers: json['trackers'] != null ? List<String>.from(json['trackers']) : null,
trackers: json['trackers'] != null
? List<String>.from(json['trackers'])
: null,
uris: json['uris'] != null ? List<String>.from(json['uris']) : null,
errorMessage: json['errorMessage'],
startTime: json['startTime'] != null ? DateTime.tryParse(json['startTime']) : null,
startTime: json['startTime'] != null
? DateTime.tryParse(json['startTime'])
: null,
bitfield: json['bitfield'],
infoHash: json['infoHash'],
pieceLength: json['pieceLength'],
Expand Down
27 changes: 12 additions & 15 deletions lib/pages/instance_page/components/instance_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ class _InstanceDialogState extends State<InstanceDialog> {
super.dispose();
}

bool get _usesHttpTransport =>
_protocol == 'http' || _protocol == 'https';
bool get _usesHttpTransport => _protocol == 'http' || _protocol == 'https';

String _nameHint(AppLocalizations l10n) {
return l10n.instanceNameAutoHint(_fallbackInstanceName());
Expand Down Expand Up @@ -176,7 +175,9 @@ class _InstanceDialogState extends State<InstanceDialog> {
: _name.trim();

return Aria2Instance(
id: widget.instance?.id ?? DateTime.now().millisecondsSinceEpoch.toString(),
id:
widget.instance?.id ??
DateTime.now().millisecondsSinceEpoch.toString(),
name: resolvedName,
type: InstanceType.remote,
protocol: _protocol,
Expand Down Expand Up @@ -253,10 +254,7 @@ class _InstanceDialogState extends State<InstanceDialog> {
}
}

Widget _buildSecretField(
BuildContext context,
AppLocalizations l10n,
) {
Widget _buildSecretField(BuildContext context, AppLocalizations l10n) {
return TextField(
controller: _secretController,
obscureText: !_showSecret,
Expand Down Expand Up @@ -300,9 +298,9 @@ class _InstanceDialogState extends State<InstanceDialog> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.all(_dialogPadding).copyWith(
bottom: _fieldSpacing,
),
padding: const EdgeInsets.all(
_dialogPadding,
).copyWith(bottom: _fieldSpacing),
child: Text(
widget.instance == null ? l10n.addInstance : l10n.editInstance,
style: theme.textTheme.headlineMedium,
Expand Down Expand Up @@ -357,10 +355,7 @@ class _InstanceDialogState extends State<InstanceDialog> {
const SizedBox(height: 12),
SegmentedButton<String>(
segments: const [
ButtonSegment(
value: 'http',
label: Text('HTTP'),
),
ButtonSegment(value: 'http', label: Text('HTTP')),
ButtonSegment(
value: 'https',
label: Text('HTTPS'),
Expand Down Expand Up @@ -490,7 +485,9 @@ class _InstanceDialogState extends State<InstanceDialog> {
mainAxisSize: MainAxisSize.min,
children: [
OutlinedButton.icon(
onPressed: _isTestingConnection ? null : _testConnection,
onPressed: _isTestingConnection
? null
: _testConnection,
style: OutlinedButton.styleFrom(
minimumSize: const Size(0, 40),
padding: const EdgeInsets.symmetric(horizontal: 16),
Expand Down
4 changes: 1 addition & 3 deletions lib/pages/settings_page/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,7 @@ class _SettingsPageState extends State<SettingsPage>
fl.CardX(
child: Padding(
padding: const EdgeInsets.all(13),
child: fl.SimpleMarkdown(
data: _buildAboutMarkdown(l10n),
),
child: fl.SimpleMarkdown(data: _buildAboutMarkdown(l10n)),
),
),
],
Expand Down