dart format

This commit is contained in:
Fabian Freund
2026-02-22 18:55:47 +01:00
parent ac80632eeb
commit 3094f68607
15 changed files with 55 additions and 84 deletions
+5 -16
View File
@@ -80,9 +80,7 @@ class _Filesystem {
/// Returns `true` if a migration was performed. /// Returns `true` if a migration was performed.
static Future<bool> _migrateMozillaDirToFiles(Directory profileDir) async { static Future<bool> _migrateMozillaDirToFiles(Directory profileDir) async {
final oldDir = Directory(p.join(profileDir.path, 'mozilla')); final oldDir = Directory(p.join(profileDir.path, 'mozilla'));
final newDir = Directory( final newDir = Directory(p.join(profileDir.path, 'files', 'mozilla'));
p.join(profileDir.path, 'files', 'mozilla'),
);
final oldType = await FileSystemEntity.type( final oldType = await FileSystemEntity.type(
oldDir.path, oldDir.path,
@@ -90,9 +88,7 @@ class _Filesystem {
); );
if (oldType == FileSystemEntityType.directory && !await newDir.exists()) { if (oldType == FileSystemEntityType.directory && !await newDir.exists()) {
await Directory( await Directory(p.join(profileDir.path, 'files')).create(recursive: true);
p.join(profileDir.path, 'files'),
).create(recursive: true);
await oldDir.rename(newDir.path); await oldDir.rename(newDir.path);
return true; return true;
} }
@@ -105,9 +101,7 @@ class _Filesystem {
for (final profileId in profileIds) { for (final profileId in profileIds) {
final oldCache = Directory(p.join(globalCacheDir.path, profileId)); final oldCache = Directory(p.join(globalCacheDir.path, profileId));
final newCache = Directory( final newCache = Directory(p.join(profileDir.path, 'cache', profileId));
p.join(profileDir.path, 'cache', profileId),
);
if (await oldCache.exists() && !await newCache.exists()) { if (await oldCache.exists() && !await newCache.exists()) {
try { try {
@@ -132,9 +126,7 @@ class _Filesystem {
Directory filesDir, Directory filesDir,
Directory profileDir, Directory profileDir,
) async { ) async {
final mozillaDir = Directory( final mozillaDir = Directory(p.join(profileDir.path, 'files', 'mozilla'));
p.join(profileDir.path, 'files', 'mozilla'),
);
await mozillaDir.create(recursive: true); await mozillaDir.create(recursive: true);
final mozillaPath = p.join(filesDir.path, 'mozilla'); final mozillaPath = p.join(filesDir.path, 'mozilla');
@@ -279,10 +271,7 @@ class _Filesystem {
} }
if (changed) { if (changed) {
await extensionsFile.writeAsString( await extensionsFile.writeAsString(jsonEncode(json), flush: true);
jsonEncode(json),
flush: true,
);
logger.i('Migrated extension paths in $profileId/extensions.json'); logger.i('Migrated extension paths in $profileId/extensions.json');
migrated = true; migrated = true;
} }
+1 -4
View File
@@ -46,9 +46,6 @@ class TorCountryPickerRoute extends GoRouteData with $TorCountryPickerRoute {
@override @override
Widget build(BuildContext context, GoRouterState state) { Widget build(BuildContext context, GoRouterState state) {
return CountryPickerScreen( return CountryPickerScreen(title: title, selectedCountryCode: $extra);
title: title,
selectedCountryCode: $extra,
);
} }
} }
+3 -9
View File
@@ -38,16 +38,10 @@ class Profile with FastEquatable {
static String getNewProfileId() => uuid.v7(); static String getNewProfileId() => uuid.v7();
Profile({ Profile({required this.id, required this.name, AuthSettings? authSettings})
required this.id, : authSettings = authSettings ?? AuthSettings.withDefaults();
required this.name,
AuthSettings? authSettings,
}) : authSettings = authSettings ?? AuthSettings.withDefaults();
factory Profile.create({ factory Profile.create({required String name, AuthSettings? authSettings}) {
required String name,
AuthSettings? authSettings,
}) {
return Profile( return Profile(
id: getNewProfileId(), id: getNewProfileId(),
name: name, name: name,
+13 -15
View File
@@ -358,21 +358,19 @@ class GenericWebsiteService extends _$GenericWebsiteService {
} }
late final Future<Result<WebPageInfo>> inFlightFetch; late final Future<Result<WebPageInfo>> inFlightFetch;
inFlightFetch = fetchPageInfo( inFlightFetch = fetchPageInfo(url: url, isImageRequest: true, proxyPort: null)
url: url, .timeout(
isImageRequest: true, const Duration(seconds: 20),
proxyPort: null, onTimeout: () => Result.failure(
).timeout( const ErrorMessage(source: 'icon', message: 'Icon fetch timeout'),
const Duration(seconds: 20), ),
onTimeout: () => Result.failure( )
const ErrorMessage(source: 'icon', message: 'Icon fetch timeout'), .whenComplete(() {
), // Only clear this entry if it is still the active in-flight request.
).whenComplete(() { if (identical(_inFlightFetches[url]?.future, inFlightFetch)) {
// Only clear this entry if it is still the active in-flight request. _inFlightFetches.remove(url);
if (identical(_inFlightFetches[url]?.future, inFlightFetch)) { }
_inFlightFetches.remove(url); });
}
});
_inFlightFetches[url] = _InFlightFetch(inFlightFetch); _inFlightFetches[url] = _InFlightFetch(inFlightFetch);
return inFlightFetch; return inFlightFetch;
@@ -64,9 +64,7 @@ class BrowserFab extends HookConsumerWidget {
heroTag: 'dock_fab', heroTag: 'dock_fab',
onPressed: () { onPressed: () {
ref ref
.read( .read(toolbarVisibilityControllerProvider(selectedTabId).notifier)
toolbarVisibilityControllerProvider(selectedTabId).notifier,
)
.forceShow(); .forceShow();
}, },
child: const Icon(MdiIcons.dockBottom), child: const Icon(MdiIcons.dockBottom),
@@ -68,7 +68,8 @@ class BrowserView extends StatefulHookConsumerWidget {
final Future<void> Function()? postInitializationStep; final Future<void> Function()? postInitializationStep;
final StreamSink<Offset>? pointerMoveEventSink; final StreamSink<Offset>? pointerMoveEventSink;
const BrowserView({super.key, const BrowserView({
super.key,
this.screenshotPeriod = const Duration(seconds: 10), this.screenshotPeriod = const Duration(seconds: 10),
this.suggestionTimeout = const Duration(seconds: 30), this.suggestionTimeout = const Duration(seconds: 30),
this.postInitializationStep, this.postInitializationStep,
@@ -52,7 +52,8 @@ class ViewTabSheetWidget extends HookConsumerWidget {
final double bottomAppBarHeight; final double bottomAppBarHeight;
final ValueChanged<bool>? onClearSiteDataExpandedChanged; final ValueChanged<bool>? onClearSiteDataExpandedChanged;
const ViewTabSheetWidget({super.key, const ViewTabSheetWidget({
super.key,
required this.initialTabState, required this.initialTabState,
required this.sheetScrollController, required this.sheetScrollController,
required this.draggableScrollableController, required this.draggableScrollableController,
@@ -70,15 +70,9 @@ bool isManifestInstallable(PwaManifest manifest) {
_validDisplayModes.contains(manifest.display!.toLowerCase()); _validDisplayModes.contains(manifest.display!.toLowerCase());
// Check that start_url is within scope // Check that start_url is within scope
final isInScope = _isStartUrlInScope( final isInScope = _isStartUrlInScope(manifest.startUrl, manifest.scope);
manifest.startUrl,
manifest.scope,
);
return hasValidName && return hasValidName && hasValidStartUrl && hasValidDisplay && isInScope;
hasValidStartUrl &&
hasValidDisplay &&
isInScope;
} }
/// Returns true if two URLs share the same origin (scheme + host + port). /// Returns true if two URLs share the same origin (scheme + host + port).
@@ -120,10 +114,12 @@ bool _isStartUrlInScope(String startUrl, String? scope) {
// Path containment: scope path must be a prefix of start_url path // Path containment: scope path must be a prefix of start_url path
// on a `/` boundary to avoid "/app" matching "/application" // on a `/` boundary to avoid "/app" matching "/application"
final scopePath = final scopePath = scopeUri.path.endsWith('/')
scopeUri.path.endsWith('/') ? scopeUri.path : '${scopeUri.path}/'; ? scopeUri.path
final startPath = : '${scopeUri.path}/';
startUri.path.endsWith('/') ? startUri.path : '${startUri.path}/'; final startPath = startUri.path.endsWith('/')
? startUri.path
: '${startUri.path}/';
return startPath.startsWith(scopePath) || startUri.path == scopeUri.path; return startPath.startsWith(scopePath) || startUri.path == scopeUri.path;
} catch (e) { } catch (e) {
@@ -59,7 +59,8 @@ class SearchScreen extends HookConsumerWidget {
/// When null, a new tab will be created. /// When null, a new tab will be created.
final String? tabId; final String? tabId;
const SearchScreen({super.key, const SearchScreen({
super.key,
required this.initialSearchText, required this.initialSearchText,
required this.tabType, required this.tabType,
this.launchedFromIntent = false, this.launchedFromIntent = false,
@@ -178,7 +178,8 @@ class ContainerChips extends HookConsumerWidget {
final ValueListenable<TextEditingValue>? searchTextListenable; final ValueListenable<TextEditingValue>? searchTextListenable;
const ContainerChips({super.key, const ContainerChips({
super.key,
required this.selectedContainer, required this.selectedContainer,
required this.onSelected, required this.onSelected,
required this.onDeleted, required this.onDeleted,
@@ -4,11 +4,7 @@ import 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
part 'sync_repository_state.g.dart'; part 'sync_repository_state.g.dart';
enum SyncEvent { enum SyncEvent { started, completed, error }
started,
completed,
error;
}
@CopyWith() @CopyWith()
class SyncRepositoryState with FastEquatable { class SyncRepositoryState with FastEquatable {
@@ -29,6 +25,12 @@ class SyncRepositoryState with FastEquatable {
}); });
@override @override
List<Object?> get hashParameters => List<Object?> get hashParameters => [
[account, remoteTabs, devices, deviceName, lastSyncEvent, lastSyncError]; account,
remoteTabs,
devices,
deviceName,
lastSyncEvent,
lastSyncError,
];
} }
@@ -148,9 +148,7 @@ class UserBackupService extends _$UserBackupService {
outputDirectory, outputDirectory,
); );
if (existingProfile == null) { if (existingProfile == null) {
throw Exception( throw Exception('Backup does not contain valid profile metadata');
'Backup does not contain valid profile metadata',
);
} }
if (existingProfile.uuidValue == filesystem.selectedProfile) { if (existingProfile.uuidValue == filesystem.selectedProfile) {
@@ -159,9 +157,7 @@ class UserBackupService extends _$UserBackupService {
); );
} }
final profileDir = filesystem.getProfileDir( final profileDir = filesystem.getProfileDir(existingProfile.uuidValue);
existingProfile.uuidValue,
);
if (await profileDir.exists()) { if (await profileDir.exists()) {
final result = await confirmOverrideCallback(); final result = await confirmOverrideCallback();
@@ -25,7 +25,8 @@ import 'package:weblibre/features/web_feed/data/models/feed_author.dart';
class AuthorsHorizontalList extends StatelessWidget { class AuthorsHorizontalList extends StatelessWidget {
late final List<Widget> _authors; late final List<Widget> _authors;
AuthorsHorizontalList({super.key, AuthorsHorizontalList({
super.key,
required List<FeedAuthor> authors, required List<FeedAuthor> authors,
Set<String> selectedTags = const {}, Set<String> selectedTags = const {},
void Function(String tagId, bool value)? onTagSelected, void Function(String tagId, bool value)? onTagSelected,
@@ -25,7 +25,8 @@ import 'package:weblibre/features/web_feed/data/models/feed_category.dart';
class TagsHorizontalList extends StatelessWidget { class TagsHorizontalList extends StatelessWidget {
late final List<Widget> _tags; late final List<Widget> _tags;
TagsHorizontalList({super.key, TagsHorizontalList({
super.key,
required List<FeedCategory> tags, required List<FeedCategory> tags,
Set<String> selectedTags = const {}, Set<String> selectedTags = const {},
void Function(String tagId, bool value)? onTagSelected, void Function(String tagId, bool value)? onTagSelected,
@@ -49,11 +49,6 @@ class SafeRawImage extends StatelessWidget {
return fallback ?? SizedBox(width: width, height: height); return fallback ?? SizedBox(width: width, height: height);
} }
return RawImage( return RawImage(image: uiImage, width: width, height: height, fit: fit);
image: uiImage,
width: width,
height: height,
fit: fit,
);
} }
} }