increase min sdk and apply new formatter

This commit is contained in:
Fabian Freund
2025-02-18 15:37:03 +01:00
parent f7885fc829
commit a1ee8bef35
266 changed files with 11329 additions and 10058 deletions
@@ -21,32 +21,31 @@ class MyAppState extends State<MyApp> {
title: const Text('Native Fragment Example'),
actions: [
MenuAnchor(
builder: (context, controller, child) => IconButton(
builder:
(context, controller, child) => IconButton(
onPressed: () {
controller.open();
},
icon: const Icon(Icons.menu)),
menuChildren: [
MenuItemButton(
onPressed: () async {
await GeckoSessionService.forActiveTab().reload();
},
child: const Text('Reload'),
icon: const Icon(Icons.menu),
),
MenuItemButton(
onPressed: () async {
await GeckoSessionService.forActiveTab().goBack();
},
child: const Text('Back'),
)
])
menuChildren: [
MenuItemButton(
onPressed: () async {
await GeckoSessionService.forActiveTab().reload();
},
child: const Text('Reload'),
),
MenuItemButton(
onPressed: () async {
await GeckoSessionService.forActiveTab().goBack();
},
child: const Text('Back'),
),
],
),
],
),
body: const SafeArea(
child: Center(
child: GeckoView(),
),
),
body: const SafeArea(child: Center(child: GeckoView())),
),
);
}
@@ -5,81 +5,21 @@ description: "Demonstrates how to use the flutter_mozilla_components plugin."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
environment:
sdk: ^3.6.0-198.0.dev
sdk: '>=3.7.0 <4.0.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
flutter_mozilla_components:
# When depending on this package from a real application you should use:
# flutter_mozilla_components: ^x.y.z
# See https://dart.dev/tools/pub/dependencies#version-constraints
# The example app is bundled with the plugin so we use a path dependency on
# the parent directory to use the current plugin's version.
path: ../
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
dev_dependencies:
integration_test:
sdk: flutter
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^5.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/to/resolution-aware-images
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/to/asset-from-package
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/to/font-from-package
@@ -18,8 +18,8 @@ void main() {
// Verify that platform version is retrieved.
expect(
find.byWidgetPredicate(
(Widget widget) => widget is Text &&
widget.data!.startsWith('Running on:'),
(Widget widget) =>
widget is Text && widget.data!.startsWith('Running on:'),
),
findsOneWidget,
);
@@ -18,8 +18,9 @@ class LoadUrlFlags {
static const LoadUrlFlags EXTERNAL = LoadUrlFlags._(1 << 2);
static const LoadUrlFlags ALLOW_POPUPS = LoadUrlFlags._(1 << 3);
static const LoadUrlFlags BYPASS_CLASSIFIER = LoadUrlFlags._(1 << 4);
static const LoadUrlFlags LOAD_FLAGS_FORCE_ALLOW_DATA_URI =
LoadUrlFlags._(1 << 5);
static const LoadUrlFlags LOAD_FLAGS_FORCE_ALLOW_DATA_URI = LoadUrlFlags._(
1 << 5,
);
static const LoadUrlFlags LOAD_FLAGS_REPLACE_HISTORY = LoadUrlFlags._(1 << 6);
static const LoadUrlFlags LOAD_FLAGS_BYPASS_LOAD_URI_DELEGATE =
LoadUrlFlags._(1 << 7);
@@ -42,12 +42,13 @@ abstract class Source {
String? packageId,
int? packageCategory,
) {
final caller = packageId != null
? ExternalPackage(
packageId: packageId,
category: PackageCategory.fromInt(packageCategory).toValue(),
)
: null;
final caller =
packageId != null
? ExternalPackage(
packageId: packageId,
category: PackageCategory.fromInt(packageCategory).toValue(),
)
: null;
switch (sourceId) {
case 1:
@@ -15,47 +15,47 @@ class BaseSelectionAction extends CustomSelectionAction {
class CallAction extends BaseSelectionAction {
CallAction(PerformAction action)
: super(
id: 'CUSTOM_CONTEXT_MENU_CALL',
title: 'Call',
pattern: SelectionPattern.phone,
performAction: action,
);
: super(
id: 'CUSTOM_CONTEXT_MENU_CALL',
title: 'Call',
pattern: SelectionPattern.phone,
performAction: action,
);
}
class EmailAction extends BaseSelectionAction {
EmailAction(PerformAction action)
: super(
id: 'CUSTOM_CONTEXT_MENU_EMAIL',
title: 'Email',
pattern: SelectionPattern.email,
performAction: action,
);
: super(
id: 'CUSTOM_CONTEXT_MENU_EMAIL',
title: 'Email',
pattern: SelectionPattern.email,
performAction: action,
);
}
class SearchAction extends BaseSelectionAction {
SearchAction(PerformAction action)
: super(
id: 'CUSTOM_CONTEXT_MENU_SEARCH',
title: 'Search',
performAction: action,
);
: super(
id: 'CUSTOM_CONTEXT_MENU_SEARCH',
title: 'Search',
performAction: action,
);
}
class PrivateSearchAction extends BaseSelectionAction {
PrivateSearchAction(PerformAction action)
: super(
id: 'CUSTOM_CONTEXT_MENU_SEARCH_PRIVATELY',
title: 'Private Search',
performAction: action,
);
: super(
id: 'CUSTOM_CONTEXT_MENU_SEARCH_PRIVATELY',
title: 'Private Search',
performAction: action,
);
}
class ShareAction extends BaseSelectionAction {
ShareAction(PerformAction action)
: super(
id: 'CUSTOM_CONTEXT_MENU_SHARE',
title: 'Share',
performAction: action,
);
: super(
id: 'CUSTOM_CONTEXT_MENU_SHARE',
title: 'Share',
performAction: action,
);
}
@@ -47,17 +47,15 @@ class GeckoAddonService extends GeckoAddonEvents {
) {
switch (actionType) {
case WebExtensionActionType.browser:
_browserExtensionSubject.addWhenMoreRecent(
timestamp,
extensionId,
(extensionId: extensionId, data: null),
);
_browserExtensionSubject.addWhenMoreRecent(timestamp, extensionId, (
extensionId: extensionId,
data: null,
));
case WebExtensionActionType.page:
_pageExtensionSubject.addWhenMoreRecent(
timestamp,
extensionId,
(extensionId: extensionId, data: null),
);
_pageExtensionSubject.addWhenMoreRecent(timestamp, extensionId, (
extensionId: extensionId,
data: null,
));
}
}
@@ -70,17 +68,15 @@ class GeckoAddonService extends GeckoAddonEvents {
) {
switch (actionType) {
case WebExtensionActionType.browser:
_browserIconSubject.addWhenMoreRecent(
timestamp,
extensionId,
(extensionId: extensionId, bytes: icon),
);
_browserIconSubject.addWhenMoreRecent(timestamp, extensionId, (
extensionId: extensionId,
bytes: icon,
));
case WebExtensionActionType.page:
_pageIconSubject.addWhenMoreRecent(
timestamp,
extensionId,
(extensionId: extensionId, bytes: icon),
);
_pageIconSubject.addWhenMoreRecent(timestamp, extensionId, (
extensionId: extensionId,
bytes: icon,
));
}
}
@@ -93,17 +89,15 @@ class GeckoAddonService extends GeckoAddonEvents {
) {
switch (actionType) {
case WebExtensionActionType.browser:
_browserExtensionSubject.addWhenMoreRecent(
timestamp,
extensionId,
(extensionId: extensionId, data: extensionData),
);
_browserExtensionSubject.addWhenMoreRecent(timestamp, extensionId, (
extensionId: extensionId,
data: extensionData,
));
case WebExtensionActionType.page:
_pageExtensionSubject.addWhenMoreRecent(
timestamp,
extensionId,
(extensionId: extensionId, data: extensionData),
);
_pageExtensionSubject.addWhenMoreRecent(timestamp, extensionId, (
extensionId: extensionId,
data: extensionData,
));
}
}
@@ -6,7 +6,7 @@ class GeckoDeleteBrowserDataService {
final GeckoDeleteBrowsingDataController _api;
GeckoDeleteBrowserDataService({GeckoDeleteBrowsingDataController? api})
: _api = api ?? _apiInstance;
: _api = api ?? _apiInstance;
Future<void> deleteTabs() {
return _api.deleteTabs();
@@ -6,7 +6,7 @@ class GeckoEngineSettingsService {
final GeckoEngineSettingsApi _api;
GeckoEngineSettingsService({GeckoEngineSettingsApi? api})
: _api = api ?? _apiInstance;
: _api = api ?? _apiInstance;
Future<void> setDefaultSettings(
GeckoEngineSettings settings, {
@@ -30,8 +30,9 @@ class GeckoEngineSettingsService {
}
Future<void> httpsOnlyMode(HttpsOnlyMode state) {
return _api
.updateRuntimeSettings(GeckoEngineSettings(httpsOnlyMode: state));
return _api.updateRuntimeSettings(
GeckoEngineSettings(httpsOnlyMode: state),
);
}
Future<void> globalPrivacyControlEnabled(bool state) {
@@ -82,11 +82,10 @@ class GeckoEventService extends GeckoStateEvents {
@override
void onHistoryStateChange(int timestamp, String id, HistoryState state) {
_historySubject.addWhenMoreRecent(
timestamp,
id,
(tabId: id, history: state),
);
_historySubject.addWhenMoreRecent(timestamp, id, (
tabId: id,
history: state,
));
}
@override
@@ -95,11 +94,10 @@ class GeckoEventService extends GeckoStateEvents {
String id,
ReaderableState state,
) {
_readerableSubject.addWhenMoreRecent(
timestamp,
id,
(tabId: id, readerable: state),
);
_readerableSubject.addWhenMoreRecent(timestamp, id, (
tabId: id,
readerable: state,
));
}
@override
@@ -108,50 +106,47 @@ class GeckoEventService extends GeckoStateEvents {
String id,
SecurityInfoState state,
) {
_securityInfoSubject.addWhenMoreRecent(
timestamp,
id,
(tabId: id, securityInfo: state),
);
_securityInfoSubject.addWhenMoreRecent(timestamp, id, (
tabId: id,
securityInfo: state,
));
}
@override
void onIconChange(int timestamp, String id, Uint8List? bytes) {
_iconChangeSubject
.addWhenMoreRecent(timestamp, id, (tabId: id, bytes: bytes));
_iconChangeSubject.addWhenMoreRecent(timestamp, id, (
tabId: id,
bytes: bytes,
));
}
@override
void onIconUpdate(int timestamp, String url, Uint8List bytes) {
_iconUpdateSubject
.addWhenMoreRecent(timestamp, url, (url: url, bytes: bytes));
_iconUpdateSubject.addWhenMoreRecent(timestamp, url, (
url: url,
bytes: bytes,
));
}
@override
void onThumbnailChange(int timestamp, String id, Uint8List? bytes) {
_thumbnailSubject.addWhenMoreRecent(
timestamp,
id,
(tabId: id, bytes: bytes),
);
_thumbnailSubject.addWhenMoreRecent(timestamp, id, (
tabId: id,
bytes: bytes,
));
}
@override
void onFindResults(int timestamp, String id, List<FindResultState?> results) {
_findResultsSubject.addWhenMoreRecent(
timestamp,
id,
(tabId: id, results: results.nonNulls.toList()),
);
_findResultsSubject.addWhenMoreRecent(timestamp, id, (
tabId: id,
results: results.nonNulls.toList(),
));
}
@override
void onTabAdded(int timestamp, String tabId) {
_tabAddedSubject.addWhenMoreRecent(
timestamp,
null,
tabId,
);
_tabAddedSubject.addWhenMoreRecent(timestamp, null, tabId);
}
GeckoEventService.setUp({
@@ -7,11 +7,11 @@ class GeckoFindInPageService {
final String? tabId;
GeckoFindInPageService({required this.tabId, GeckoFindApi? api})
: _api = api ?? _apiInstance;
: _api = api ?? _apiInstance;
GeckoFindInPageService.forActiveTab({GeckoFindApi? api})
: _api = api ?? _apiInstance,
tabId = null;
: _api = api ?? _apiInstance,
tabId = null;
Future<void> findAll(String text) {
return _api.findAll(tabId, text);
@@ -12,16 +12,17 @@ class GeckoPrefService {
}
Future<Map<String, Object>> applyPrefs(Map<String, Object> prefs) {
final buffer = prefs.entries.map((pref) {
final value = switch (pref.value) {
final bool x => '$x',
final int x => '$x',
final String x => '"$x"',
_ => throw Exception('Unknow pref type')
};
final buffer =
prefs.entries.map((pref) {
final value = switch (pref.value) {
final bool x => '$x',
final int x => '$x',
final String x => '"$x"',
_ => throw Exception('Unknow pref type'),
};
return 'user_pref("${pref.key}", $value);';
}).join();
return 'user_pref("${pref.key}", $value);';
}).join();
return _apiInstance.applyPrefs(buffer);
}
@@ -29,11 +29,12 @@ class GeckoReaderableService extends ReaderViewController {
ReaderViewEvents? readerEvents,
BinaryMessenger? binaryMessenger,
String messageChannelSuffix = '',
}) : _events = readerEvents ??
ReaderViewEvents(
binaryMessenger: binaryMessenger,
messageChannelSuffix: messageChannelSuffix,
) {
}) : _events =
readerEvents ??
ReaderViewEvents(
binaryMessenger: binaryMessenger,
messageChannelSuffix: messageChannelSuffix,
) {
ReaderViewController.setUp(
this,
binaryMessenger: binaryMessenger,
@@ -22,8 +22,8 @@ class GeckoSelectionActionService extends GeckoSelectionActionEvents {
BinaryMessenger? binaryMessenger,
String messageChannelSuffix = '',
GeckoSelectionActionController? api,
}) : _api = api ?? _apiInstance,
_actions = [] {
}) : _api = api ?? _apiInstance,
_actions = [] {
GeckoSelectionActionEvents.setUp(
this,
binaryMessenger: binaryMessenger,
@@ -10,11 +10,11 @@ class GeckoSessionService {
final GeckoSessionApi _api;
GeckoSessionService({required String this.tabId, GeckoSessionApi? api})
: _api = api ?? _apiInstance;
: _api = api ?? _apiInstance;
GeckoSessionService.forActiveTab({GeckoSessionApi? api})
: _api = api ?? _apiInstance,
tabId = null;
: _api = api ?? _apiInstance,
tabId = null;
Future<void> loadUrl({
required Uri url,
@@ -43,10 +43,7 @@ class GeckoSessionService {
}
Future<void> reload({LoadUrlFlags flags = LoadUrlFlags.NONE}) {
return _api.reload(
tabId: tabId,
flags: flags.toValue(),
);
return _api.reload(tabId: tabId, flags: flags.toValue());
}
Future<void> stopLoading() {
@@ -54,31 +51,19 @@ class GeckoSessionService {
}
Future<void> goBack({bool userInteraction = true}) {
return _api.goBack(
tabId: tabId,
userInteraction: userInteraction,
);
return _api.goBack(tabId: tabId, userInteraction: userInteraction);
}
Future<void> goForward({bool userInteraction = true}) {
return _api.goForward(
tabId: tabId,
userInteraction: userInteraction,
);
return _api.goForward(tabId: tabId, userInteraction: userInteraction);
}
Future<void> goToHistoryIndex({required int index}) {
return _api.goToHistoryIndex(
index: index,
tabId: tabId,
);
return _api.goToHistoryIndex(index: index, tabId: tabId);
}
Future<void> requestDesktopSite({required bool enable}) {
return _api.requestDesktopSite(
enable: enable,
tabId: tabId,
);
return _api.requestDesktopSite(enable: enable, tabId: tabId);
}
Future<void> exitFullscreen() {
@@ -110,9 +95,7 @@ class GeckoSessionService {
return _api.translateRestore(tabId: tabId);
}
Future<void> crashRecovery({
List<String>? tabIds,
}) {
Future<void> crashRecovery({List<String>? tabIds}) {
return _api.crashRecovery(tabIds: tabIds);
}
@@ -3,11 +3,7 @@ import 'package:rxdart/rxdart.dart';
final _lastEventTimes = <Subject, Map<dynamic, int>>{};
extension SubjectAddRecent<T> on Subject<T> {
void addWhenMoreRecent(
int timestamp,
dynamic identifier,
T value,
) {
void addWhenMoreRecent(int timestamp, dynamic identifier, T value) {
_lastEventTimes[this] ??= {};
if ((_lastEventTimes[this]?[identifier] ?? 0) < timestamp) {
@@ -23,8 +23,9 @@ class GeckoView extends StatefulWidget {
}
class _GeckoViewState extends State<GeckoView> {
static const platform =
MethodChannel('me.movenext.flutter_mozilla_components/trim_memory');
static const platform = MethodChannel(
'me.movenext.flutter_mozilla_components/trim_memory',
);
final browserService = GeckoBrowserService();
@@ -46,10 +47,7 @@ class _GeckoViewState extends State<GeckoView> {
Widget build(BuildContext context) {
return PlatformViewLink(
viewType: 'eu.lensai/gecko',
surfaceFactory: (
context,
controller,
) {
surfaceFactory: (context, controller) {
return AndroidViewSurface(
controller: controller as AndroidViewController,
gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
@@ -58,12 +56,12 @@ class _GeckoViewState extends State<GeckoView> {
},
onCreatePlatformView: (PlatformViewCreationParams params) {
return PlatformViewsService.initExpensiveAndroidView(
id: params.id,
viewType: 'eu.lensai/gecko',
layoutDirection: TextDirection.ltr,
creationParams: {},
creationParamsCodec: const StandardMessageCodec(),
)
id: params.id,
viewType: 'eu.lensai/gecko',
layoutDirection: TextDirection.ltr,
creationParams: {},
creationParamsCodec: const StandardMessageCodec(),
)
..addOnPlatformViewCreatedListener((value) async {
params.onPlatformViewCreated(value);
File diff suppressed because it is too large Load Diff
@@ -209,10 +209,7 @@ class RecoverableTab {
/// A [TabState] instance containing basic tab state.
final TabState state;
const RecoverableTab({
this.engineSessionStateJson,
required this.state,
});
const RecoverableTab({this.engineSessionStateJson, required this.state});
}
/// A restored browser state, read from disk.
@@ -223,10 +220,7 @@ class RecoverableBrowserState {
/// The ID of the selected tab in [tabs]. Or `null` if no selection was restored.
final String? selectedTabId;
const RecoverableBrowserState({
required this.tabs,
this.selectedTabId,
});
const RecoverableBrowserState({required this.tabs, this.selectedTabId});
}
/// Indicates what location the tabs should be restored at
@@ -257,11 +251,7 @@ enum IconType {
/// Supported sizes.
///
/// We are trying to limit the supported sizes in order to optimize our caching strategy.
enum IconSize {
defaultSize,
launcher,
launcherAdaptive,
}
enum IconSize { defaultSize, launcher, launcherAdaptive }
/// A request to load an [Icon].
class IconRequest {
@@ -346,12 +336,7 @@ enum IconSource {
disk,
}
enum CookieSameSiteStatus {
noRestriction,
lax,
strict,
unspecified;
}
enum CookieSameSiteStatus { noRestriction, lax, strict, unspecified }
class CookiePartitionKey {
final String topLevelSite;
@@ -539,30 +524,13 @@ class TabContent {
);
}
enum TrackingProtectionPolicy {
none,
recommended,
strict,
custom,
}
enum TrackingProtectionPolicy { none, recommended, strict, custom }
enum HttpsOnlyMode {
disabled,
privateOnly,
enabled,
}
enum HttpsOnlyMode { disabled, privateOnly, enabled }
enum ColorScheme {
system,
light,
dark,
}
enum ColorScheme { system, light, dark }
enum CookieBannerHandlingMode {
disabled,
rejectAll,
rejectOrAcceptAll,
}
enum CookieBannerHandlingMode { disabled, rejectAll, rejectOrAcceptAll }
enum WebContentIsolationStrategy {
isolateNothing,
@@ -674,8 +642,9 @@ class AutocompleteResult {
dartOptions: DartOptions(),
kotlinOut:
'android/src/main/kotlin/eu/lensai/flutter_mozilla_components/pigeons/Gecko.g.kt',
kotlinOptions:
KotlinOptions(package: 'eu.lensai.flutter_mozilla_components.pigeons'),
kotlinOptions: KotlinOptions(
package: 'eu.lensai.flutter_mozilla_components.pigeons',
),
dartPackageName: 'flutter_mozilla_components',
),
)
@@ -759,9 +728,7 @@ abstract class GeckoSessionApi {
required String? tabId, //If null = current tab
});
void crashRecovery({
required List<String>? tabIds,
});
void crashRecovery({required List<String>? tabIds});
void purgeHistory();
@@ -1037,10 +1004,7 @@ abstract class GeckoSuggestionEvents {
@FlutterApi()
abstract class GeckoTabContentEvents {
void onContentUpdate(
int timestamp,
TabContent content,
);
void onContentUpdate(int timestamp, TabContent content);
}
@HostApi()
@@ -4,7 +4,7 @@ version: 0.0.1
homepage:
environment:
sdk: ^3.6.0-198.0.dev
sdk: '>=3.7.0 <4.0.0'
flutter: '>=3.3.0'
dependencies: