Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Add a Windows desktop build with the web layout, built on GitHub

Barnabasf5db3d2c4b08
diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml
new file mode 100644
index 00000000..cc05b40b
--- /dev/null
+++ b/.github/workflows/windows-build.yml
@@ -0,0 +1,55 @@
+name: Windows Desktop Build
+
+# Builds the Windows desktop app from whichever branch the run is started on
+# and uploads the runner folder as a workflow artifact. Nothing is signed and
+# nothing goes to a release: download the zip from the run page, unpack it
+# anywhere and start absorb.exe.
+
+on:
+ workflow_dispatch:
+
+jobs:
+ build:
+ name: Build Windows app
+ runs-on: windows-latest
+ timeout-minutes: 90
+
+ steps:
+ - uses: actions/checkout@v5
+
+ - uses: subosito/flutter-action@v2
+ with:
+ channel: stable
+ flutter-version: 3.47.0
+ cache: true
+
+ - name: Read version
+ id: version
+ shell: bash
+ run: |
+ full=$(grep -E '^version:' pubspec.yaml | sed -E 's/^version:[[:space:]]*//' | tr -d '\r')
+ echo "name=absorb-${full/+/-}-windows" >> "$GITHUB_OUTPUT"
+
+ - name: Build
+ run: flutter build windows --release
+
+ # The runner folder needs the VC++ runtime next to the exe on machines
+ # that never installed the redistributable.
+ - name: Add the VC++ runtime DLLs
+ shell: pwsh
+ run: |
+ $out = "build\windows\x64\runner\Release"
+ $crt = Get-ChildItem "C:\Program Files\Microsoft Visual Studio\2022\*\VC\Redist\MSVC\*\x64\Microsoft.VC143.CRT" -Directory -ErrorAction SilentlyContinue | Select-Object -Last 1
+ foreach ($dll in "msvcp140.dll", "vcruntime140.dll", "vcruntime140_1.dll") {
+ $src = if ($crt) { Join-Path $crt.FullName $dll } else { "C:\Windows\System32\$dll" }
+ if (-not (Test-Path $src)) { $src = "C:\Windows\System32\$dll" }
+ Copy-Item $src $out
+ }
+ Get-ChildItem $out | Select-Object Name, Length
+
+ - uses: actions/upload-artifact@v4
+ with:
+ name: ${{ steps.version.outputs.name }}
+ path: build/windows/x64/runner/Release
+ if-no-files-found: error
+ retention-days: 14
diff --git a/.metadata b/.metadata
index e39b9c73..0f16d6f9 100644
--- a/.metadata
+++ b/.metadata
@@ -21,6 +21,9 @@ migration:
- platform: web
create_revision: 559ffa3f75e7402d65a8def9c28389a9b2e6fe42
base_revision: 559ffa3f75e7402d65a8def9c28389a9b2e6fe42
+ - platform: windows
+ create_revision: 4cf24164269a5ebf0c16a028a00727d0e77bbb05
+ base_revision: 4cf24164269a5ebf0c16a028a00727d0e77bbb05
# User provided section
diff --git a/lib/main.dart b/lib/main.dart
index 7a221f13..6caf09b3 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -191,7 +191,7 @@ Future<void> applyAppearanceFromPrefs() async {
/// pinned to portrait; otherwise all orientations are allowed (the default).
/// Safe to call any time the setting changes.
Future<void> applyOrientationLock() async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
final lock = await PlayerSettings.getLockPortrait();
await SystemChrome.setPreferredOrientations(lock
? const [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]
@@ -206,13 +206,13 @@ Future<void> applyOrientationLock() async {
void main() async {
if (!AppPlatform.isWeb) HttpOverrides.global = _CertOverrides();
final widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
- final setupLinkStream = AppPlatform.isWeb ? null : AppLinks().uriLinkStream;
+ final setupLinkStream = AppPlatform.lacksPhonePlugins ? null : AppLinks().uriLinkStream;
// These calls use platform channels that require an Activity. When Android
// Auto cold-starts the app for the MediaBrowserService, no Activity exists
// and these calls can hang forever - blocking runApp() and freezing on the
// splash screen. Wrap in try-catch with a timeout so we always reach runApp().
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
try {
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
} catch (_) {}
@@ -277,7 +277,7 @@ void main() async {
};
// Remove native splash — Flutter will render the AuthGate splash immediately
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
try {
FlutterNativeSplash.remove();
} catch (_) {}
@@ -451,7 +451,7 @@ class AbsorbApp extends StatelessWidget {
title: 'Absorb',
debugShowCheckedModeBanner: false,
scrollBehavior:
- AppPlatform.isWeb ? const _AppScrollBehavior() : null,
+ AppPlatform.lacksPhonePlugins ? const _AppScrollBehavior() : null,
locale: overrideLocale,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
@@ -531,7 +531,7 @@ class AbsorbApp extends StatelessWidget {
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
),
- constraints: AppPlatform.isWeb
+ constraints: AppPlatform.lacksPhonePlugins
? const BoxConstraints(maxWidth: 640)
: null,
),
@@ -590,7 +590,7 @@ class AbsorbApp extends StatelessWidget {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
),
- constraints: AppPlatform.isWeb
+ constraints: AppPlatform.lacksPhonePlugins
? const BoxConstraints(maxWidth: 640)
: null,
),
@@ -742,7 +742,7 @@ class _AuthGateState extends State<AuthGate> {
} catch (_) {}
// Background new-episode notifications: re-register the periodic job
// (self-healing after OEM kills) and wire up notification taps.
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
EpisodeNotificationService.syncRegistration();
EpisodeNotificationService.initTapHandling();
}
@@ -776,7 +776,7 @@ class _AuthGateState extends State<AuthGate> {
// Downloads must be loaded before the audio handler so getChildren()
// can serve the Android Auto browse tree immediately.
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
debugPrint('[Init] DownloadService... (${sw.elapsedMilliseconds}ms)');
try {
await DownloadService().init().timeout(const Duration(seconds: 8));
@@ -798,7 +798,7 @@ class _AuthGateState extends State<AuthGate> {
// the UI has bootstrapped the current item) through the existing
// home-widget restore path. Registered as a static callback to avoid a
// circular import between AudioPlayerService and HomeWidgetService.
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
AudioPlayerService.onColdStartPlayRequested =
HomeWidgetService().resumeLastPlayedIfAvailable;
// A headset press may have cold-launched this process into the background
@@ -808,7 +808,7 @@ class _AuthGateState extends State<AuthGate> {
}
debugPrint('[Init] AudioPlayerService done (${sw.elapsedMilliseconds}ms)');
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
try {
await Permission.notification.request();
} catch (e) {
@@ -833,7 +833,7 @@ class _AuthGateState extends State<AuthGate> {
// fold it into the offline ledger so the normal flush ships it.
await ProgressSyncService().migrateOrphanStreamingTime();
await LocalSessionService().init();
- if (!AppPlatform.isWeb) await EqualizerService().init();
+ if (!AppPlatform.lacksPhonePlugins) await EqualizerService().init();
await SleepTimerService().loadAutoSleepSettings();
// Watch for settings changes and pull the synced copy on the way in.
await SettingsSyncService().startIfEnabled();
@@ -856,7 +856,7 @@ class _AuthGateState extends State<AuthGate> {
// (so we get real UIKit system icon types like `.play`, `.search`).
// Depends on AudioPlayerService + HomeWidgetService so they're ready
// when the shortcut handler fires.
- if (!AppPlatform.isWeb) await QuickActionsService().init();
+ if (!AppPlatform.lacksPhonePlugins) await QuickActionsService().init();
} catch (e) {
debugPrint('[Init] Service init failed: $e');
}
diff --git a/lib/providers/_lp_core.dart b/lib/providers/_lp_core.dart
index b9e2f918..19b1e60d 100644
--- a/lib/providers/_lp_core.dart
+++ b/lib/providers/_lp_core.dart
@@ -312,7 +312,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
// ── Offline mode ──
Future<void> setManualOffline(bool value) async {
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
_manualOffline = false;
_networkOffline = false;
return;
@@ -352,7 +352,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
}
Future<void> restoreOfflineMode() async {
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
_manualOffline = false;
_networkOffline = false;
return;
@@ -416,7 +416,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
}
void setNetworkOffline(bool offline) {
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
_networkOffline = false;
AudioPlayerService().setKnownOffline(false);
return;
@@ -463,7 +463,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
}
void _buildOfflineSections() {
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
_personalizedSections = [];
_errorMessage = null;
_isLoading = false;
@@ -588,7 +588,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
}
void _injectDownloadedSection() {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
final isPodcast = isPodcastLibrary;
final allDownloads = DownloadService().downloadedItems;
final downloads = allDownloads.where((dl) {
@@ -1667,7 +1667,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
registerUpdatedAt(id, ts.toInt());
// Mirror into AA/CarPlay so the next browse-tree refresh hands out a
// ts-suffixed cover URI and the native cover cache can invalidate.
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
AndroidAutoService.notifyItemUpdated(id, ts.toInt());
}
}
@@ -2627,7 +2627,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
List<String>? keys,
Map<String, Map<String, dynamic>>? meta,
}) async {
- if (AppPlatform.isWeb || _api == null || isOffline) return false;
+ if (AppPlatform.lacksPhonePlugins || _api == null || isOffline) return false;
final wifiOnly = await PlayerSettings.getWifiOnlyDownloads();
if (wifiOnly) {
final connectivity = await Connectivity().checkConnectivity();
@@ -2711,7 +2711,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
}
Future<void> catchUpSubscribedPodcasts() async {
- if (AppPlatform.isWeb ||
+ if (AppPlatform.lacksPhonePlugins ||
_subscribedPodcasts.isEmpty ||
_api == null ||
isOffline) {
@@ -2738,7 +2738,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
}
void _catchUpRollingDownloads() async {
- if (AppPlatform.isWeb ||
+ if (AppPlatform.lacksPhonePlugins ||
_api == null ||
isOffline ||
_rollingDownloadSeries.isEmpty) {
@@ -2792,7 +2792,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
}
void _checkRollingDownloads(String playingKey) async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
final api = _api;
if (api == null || isOffline) return;
// With the "auto series download" default on, a book in a series enables
@@ -3072,7 +3072,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
// queue auto-download that never fired looked identical to one that never
// ran. Each return now names the gate that stopped it. Strip before beta.
Future<void> _checkQueueAutoDownloads(String playingKey) async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
try {
final self = this as LibraryProvider;
final planGeneration = ++_queueDownloadPlanGeneration;
@@ -3383,7 +3383,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
}
Future<void> _catchUpQueueAutoDownloads() async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
final itemId = AudioPlayerService().currentItemId;
if (itemId == null) {
debugPrint(
@@ -3399,7 +3399,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
Future<void> syncQueueAutoDownloads() => _catchUpQueueAutoDownloads();
void _checkAutoDownloadOnStream(String playingKey) async {
- if (AppPlatform.isWeb || _api == null || isOffline) {
+ if (AppPlatform.lacksPhonePlugins || _api == null || isOffline) {
return;
}
final enabled = await PlayerSettings.getAutoDownloadOnStream();
@@ -3432,7 +3432,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
}
Future<void> _rollingDownloadBook(String bookId, int count) async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
var data = _itemDataWithSeries(bookId);
var (seriesId, currentSeq) =
data != null ? _StateMixin._extractSeries(data) : (null, null);
@@ -3522,7 +3522,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
}
Future<void> _rollingDownloadPodcast(String compoundKey, int count) async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
final showId = compoundKey.substring(0, 36);
final episodeId = compoundKey.substring(37);
diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart
index c821ff82..69a9db41 100644
--- a/lib/providers/auth_provider.dart
+++ b/lib/providers/auth_provider.dart
@@ -347,7 +347,7 @@ class AuthProvider extends ChangeNotifier {
/// to call unconditionally — the service is a no-op on non-Android
/// platforms and when no watch is connected.
void _pushSessionToWear() {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
final url = _serverUrl;
final token = _accessToken;
if (url == null || token == null) return;
@@ -562,7 +562,7 @@ class AuthProvider extends ChangeNotifier {
);
}
_serverReachable = reachable;
- if (AppPlatform.isWeb && !reachable) {
+ if (AppPlatform.lacksPhonePlugins && !reachable) {
_accessToken = null;
_refreshToken = null;
_isLegacyToken = false;
@@ -830,7 +830,7 @@ class AuthProvider extends ChangeNotifier {
await _onAccountActivated();
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
await HomeWidgetService().clearStats();
HomeWidgetService().refreshStats(force: true);
_pushSessionToWear();
@@ -922,7 +922,7 @@ class AuthProvider extends ChangeNotifier {
await _onAccountActivated();
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
await HomeWidgetService().clearStats();
HomeWidgetService().refreshStats(force: true);
_pushSessionToWear();
@@ -1036,7 +1036,7 @@ class AuthProvider extends ChangeNotifier {
await _onAccountActivated();
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
await HomeWidgetService().clearStats();
HomeWidgetService().refreshStats(force: true);
_pushSessionToWear();
@@ -1049,7 +1049,7 @@ class AuthProvider extends ChangeNotifier {
/// Load local server settings from PlayerSettings.
Future<void> _loadLocalServerSettings() async {
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
_localServerEnabled = false;
_localServerUrl = '';
_useLocalServer = false;
@@ -1075,7 +1075,7 @@ class AuthProvider extends ChangeNotifier {
/// local URL with the new account's token, producing 401s.
Future<void> _onAccountActivated() async {
PlayerSettings.notifySettingsChanged();
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
await EqualizerService().reloadForActiveAccount();
}
@@ -1114,7 +1114,7 @@ class AuthProvider extends ChangeNotifier {
/// Check if the configured local server is reachable.
/// Called on WiFi connectivity changes by LibraryProvider.
Future<void> checkLocalServer() async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
if (!_localServerEnabled || _localServerUrl.isEmpty || _serverUrl == null)
return;
final wasLocal = _useLocalServer;
@@ -1171,7 +1171,7 @@ class AuthProvider extends ChangeNotifier {
required bool enabled,
required String url,
}) async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
final normalizedUrl = normalizeServerUrl(url);
_localServerEnabled = enabled;
_localServerUrl = normalizedUrl;
@@ -1212,7 +1212,7 @@ class AuthProvider extends ChangeNotifier {
}
} catch (_) {}
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
AndroidAutoService().clearCache();
CarPlayService().clearAndRefresh();
}
@@ -1220,7 +1220,7 @@ class AuthProvider extends ChangeNotifier {
// Drop the per-library search index so the next account can't reuse it.
BookSearchIndex().clear();
- if (!AppPlatform.isWeb) await HomeWidgetService().clearStats();
+ if (!AppPlatform.lacksPhonePlugins) await HomeWidgetService().clearStats();
// Clear cached session metadata for this user (track URLs would be invalid
// on next login anyway)
@@ -1285,7 +1285,7 @@ class AuthProvider extends ChangeNotifier {
await prefs.remove('default_library_id');
} catch (_) {}
- if (!AppPlatform.isWeb) WearAuthService.instance.clear();
+ if (!AppPlatform.lacksPhonePlugins) WearAuthService.instance.clear();
notifyListeners();
}
@@ -1306,7 +1306,7 @@ class AuthProvider extends ChangeNotifier {
}
} catch (_) {}
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
AndroidAutoService().clearCache();
CarPlayService().clearAndRefresh();
}
@@ -1336,7 +1336,7 @@ class AuthProvider extends ChangeNotifier {
// Reload EQ settings from the new account's scope. Without this the
// EqualizerService singleton keeps the previous account's in-memory
// state and would write it back into the new scope on any change.
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
await EqualizerService().reloadForActiveAccount();
}
@@ -1380,7 +1380,7 @@ class AuthProvider extends ChangeNotifier {
}
} catch (_) {}
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
await HomeWidgetService().clearStats();
HomeWidgetService().refreshStats(force: true);
}
diff --git a/lib/providers/library_provider.dart b/lib/providers/library_provider.dart
index c473a7fa..5711ee25 100644
--- a/lib/providers/library_provider.dart
+++ b/lib/providers/library_provider.dart
@@ -62,7 +62,7 @@ class LibraryProvider extends ChangeNotifier
AudioPlayerService.setOnPeekNextItemCallback(peekNextQueueItemForPreBuffer);
AudioPlayerService.setOnPlayStartedCallback((key, duration) async {
await _prepareAbsorbingForPlayback(key, duration);
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
// Auto-download the book/episode you're listening to kicks off quickly so
// it doesn't feel broken; the short wait still skips it if you stop or
// switch right away. Rolling/queue look-ahead stays deferred to keep the
@@ -104,7 +104,7 @@ class LibraryProvider extends ChangeNotifier
}
void updateAuth(AuthProvider auth) {
- if (!AppPlatform.isWeb && !_listeningToDownloads) {
+ if (!AppPlatform.lacksPhonePlugins && !_listeningToDownloads) {
_listeningToDownloads = true;
DownloadService().addListener(_onDownloadsChanged);
}
@@ -207,7 +207,7 @@ class LibraryProvider extends ChangeNotifier
_buildProgressMap(auth);
- if (!AppPlatform.isWeb && !auth.serverReachable) {
+ if (!AppPlatform.lacksPhonePlugins && !auth.serverReachable) {
debugPrint('[Library] Server not reachable — going offline');
_networkOffline = true;
_buildOfflineSections();
@@ -222,7 +222,7 @@ class LibraryProvider extends ChangeNotifier
ProgressSyncService().flushPendingSync(api: _api!);
ProgressSyncService().flushOfflineListeningTime(api: _api!);
LocalSessionService().flushPending(api: _api!);
- if (!AppPlatform.isWeb) DownloadService().enrichMetadata(_api!);
+ if (!AppPlatform.lacksPhonePlugins) DownloadService().enrichMetadata(_api!);
// Start proactive reachability verification so the cloud icon
// reflects actual server state, not just the initial login result.
_startHealthCheckTimer();
@@ -408,7 +408,7 @@ class LibraryProvider extends ChangeNotifier
await _loadSectionPrefs();
notifyListeners();
await loadPersonalizedView(force: true);
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
AndroidAutoService().refresh(force: true);
CarPlayService().refreshTemplates();
}
@@ -430,7 +430,7 @@ class LibraryProvider extends ChangeNotifier
await _loadSectionPrefs();
notifyListeners();
await loadPersonalizedView();
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
AndroidAutoService().refresh(force: true);
CarPlayService().refreshTemplates();
}
diff --git a/lib/screens/app_shell.dart b/lib/screens/app_shell.dart
index 8fab8947..9508f93a 100644
--- a/lib/screens/app_shell.dart
+++ b/lib/screens/app_shell.dart
@@ -259,7 +259,7 @@ class _AppShellState extends State<AppShell>
void _startServerTaskRefreshTimer() {
_serverTaskRefreshTimer?.cancel();
_serverTaskRefreshTimer = null;
- if (!mounted || !AppPlatform.isWeb) return;
+ if (!mounted || !AppPlatform.lacksPhonePlugins) return;
final auth = context.read<AuthProvider>();
if (!auth.isAdmin || auth.apiService == null || _serverTaskTracker == null) {
return;
@@ -527,7 +527,7 @@ class _AppShellState extends State<AppShell>
super.initState();
_instance = this;
EreaderVolumeNav.ensureHandler();
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
_serverTaskTracker = ServerTaskTracker();
_serverUpdateController.addListener(_onServerUpdateChanged);
}
@@ -537,7 +537,7 @@ class _AppShellState extends State<AppShell>
_onDesktopExitGuardChanged,
);
unawaited(_loadDesktopSidebarPreference());
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
_currentIndex = 0;
} else if (!widget.startOnAbsorbing) {
_loadStartScreen();
@@ -562,7 +562,7 @@ class _AppShellState extends State<AppShell>
context.read<LibraryProvider>().addListener(_onLibraryChanged);
_loadPodcastTabPrefs();
PlayerSettings.settingsChanged.addListener(_loadPodcastTabPrefs);
- if (!AppPlatform.isWeb) WelcomeSheet.showIfNeeded(context);
+ if (!AppPlatform.lacksPhonePlugins) WelcomeSheet.showIfNeeded(context);
_checkForUpdate();
}
@@ -640,7 +640,7 @@ class _AppShellState extends State<AppShell>
static const _isGithubBuild = bool.fromEnvironment('GITHUB_BUILD');
void _checkForUpdate() async {
- if (AppPlatform.isWeb || !_isGithubBuild) return;
+ if (AppPlatform.lacksPhonePlugins || !_isGithubBuild) return;
final includePreReleases = await PlayerSettings.getIncludePreReleases();
final info = await UpdateCheckerService.check(
includePreReleases: includePreReleases,
@@ -662,7 +662,7 @@ class _AppShellState extends State<AppShell>
_cast.removeListener(_onCastChanged);
_serverTaskRefreshTimer?.cancel();
_serverTaskTracker?.dispose();
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
_serverUpdateController.removeListener(_onServerUpdateChanged);
}
PlayerSettings.settingsChanged.removeListener(_loadPodcastTabPrefs);
@@ -775,7 +775,7 @@ class _AppShellState extends State<AppShell>
}
Future<void> _maybeAutoExpand() async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
// Only auto-open the full-screen player from the Absorbing tab - starting
// playback from elsewhere (another tab, the nav long-press) shouldn't
// yank the user into the player.
@@ -894,7 +894,7 @@ class _AppShellState extends State<AppShell>
context.read<LibraryProvider>().onAppForegrounded();
SleepTimerService().onAppForegrounded();
AudioPlayerService.onAppForegrounded();
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
HomeWidgetService().onAppForegrounded();
ReviewService.onAppForegrounded();
}
@@ -913,7 +913,7 @@ class _AppShellState extends State<AppShell>
context.read<LibraryProvider>().onAppBackgrounded();
SleepTimerService().onAppBackgrounded();
AudioPlayerService.onAppBackgrounded();
- if (!AppPlatform.isWeb) HomeWidgetService().onAppBackgrounded();
+ if (!AppPlatform.lacksPhonePlugins) HomeWidgetService().onAppBackgrounded();
unawaited(SettingsSyncService().onAppBackgrounded());
}
@@ -992,7 +992,7 @@ class _AppShellState extends State<AppShell>
_lastRefresh = now;
lib.refresh();
// Keep Android Auto / CarPlay browse tree in sync
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
AndroidAutoService().refresh();
CarPlayService().refreshTemplates();
}
@@ -1001,7 +1001,7 @@ class _AppShellState extends State<AppShell>
@override
Widget build(BuildContext context) {
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
final taskAccess = context.select<AuthProvider, (bool, Object?)>(
(auth) => (auth.isAdmin, auth.apiService),
);
@@ -1009,7 +1009,7 @@ class _AppShellState extends State<AppShell>
}
return LayoutBuilder(
builder: (context, constraints) {
- final workspaceTier = AppPlatform.isWeb
+ final workspaceTier = AppPlatform.lacksPhonePlugins
? workspaceLayoutTierForWidth(constraints.maxWidth)
: WorkspaceLayoutTier.mobile;
final desktopRequested = workspaceTier != WorkspaceLayoutTier.mobile;
@@ -1045,7 +1045,7 @@ class _AppShellState extends State<AppShell>
void _handleBack(bool didPop, Object? _) {
if (didPop) return;
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
final pane = _paneNavigatorKey.currentState;
if (pane != null && pane.canPop()) {
unawaited(pane.maybePop());
diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart
index 6f2613fe..146b70cc 100644
--- a/lib/screens/home_screen.dart
+++ b/lib/screens/home_screen.dart
@@ -761,7 +761,7 @@ class HomeScreenState extends State<HomeScreen>
),
),
),
- if (!desktop && !AppPlatform.isWeb)
+ if (!desktop && !AppPlatform.lacksPhonePlugins)
const SliverToBoxAdapter(
child: FeatureHint(
prefKey: 'hint_continue_listening_gestures',
@@ -1123,7 +1123,7 @@ class _ContinueListeningCardState extends State<_ContinueListeningCard> {
final cs = Theme.of(context).colorScheme;
final tt = Theme.of(context).textTheme;
final l = AppLocalizations.of(context)!;
- final gesturePolicy = MediaCardGesturePolicy(isWeb: AppPlatform.isWeb);
+ final gesturePolicy = MediaCardGesturePolicy(isWeb: AppPlatform.lacksPhonePlugins);
final item = widget.item;
final lib = widget.lib;
diff --git a/lib/screens/login_screen.dart b/lib/screens/login_screen.dart
index a2629034..383da666 100644
--- a/lib/screens/login_screen.dart
+++ b/lib/screens/login_screen.dart
@@ -102,7 +102,7 @@ class _LoginScreenState extends State<LoginScreen>
if (!mounted) return;
final auth = context.read<AuthProvider>();
final account = widget.prefillAccount;
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
final serverUrl = serverUrlFromWebOrigin(Uri.base);
if (serverUrl != null) {
_setInitialHeaders(account?.customHeaders ?? auth.customHeaders);
@@ -129,7 +129,7 @@ class _LoginScreenState extends State<LoginScreen>
}
void _prefillLogin(String serverUrl, String username) {
- final resolvedServerUrl = AppPlatform.isWeb
+ final resolvedServerUrl = AppPlatform.lacksPhonePlugins
? serverUrlFromWebOrigin(Uri.base) ?? serverUrl
: serverUrl;
final uri = Uri.tryParse(resolvedServerUrl);
@@ -164,7 +164,7 @@ class _LoginScreenState extends State<LoginScreen>
final info = await PackageInfo.fromPlatform();
if (mounted) setState(() => _appVersion = 'v${info.version}');
} catch (_) {}
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
try {
final trust = await PlayerSettings.getTrustAllCerts();
if (mounted) setState(() => _trustAllCerts = trust);
@@ -182,14 +182,14 @@ class _LoginScreenState extends State<LoginScreen>
_apiKeyController.dispose();
_usernameFocus.dispose();
for (final (k, v) in _headerControllers) { k.dispose(); v.dispose(); }
- if (!AppPlatform.isWeb) OidcService().cancel();
+ if (!AppPlatform.lacksPhonePlugins) OidcService().cancel();
super.dispose();
}
String _lastValidatedServer = '';
String get _resolvedServerUrl {
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
return serverUrlFromWebOrigin(Uri.base) ?? '';
}
@@ -274,7 +274,7 @@ class _LoginScreenState extends State<LoginScreen>
}
});
- if (ok && !AppPlatform.isWeb) {
+ if (ok && !AppPlatform.lacksPhonePlugins) {
OidcService.checkOidcEnabled(fullUrl, customHeaders: headers).then((config) {
if (mounted && _resolvedServerUrl == fullUrl) {
setState(() => _oidcConfig = config);
@@ -355,7 +355,7 @@ class _LoginScreenState extends State<LoginScreen>
}
Future<void> _handleOidcLogin() async {
- if (AppPlatform.isWeb || !_serverValid) return;
+ if (AppPlatform.lacksPhonePlugins || !_serverValid) return;
setState(() {
_isOidcLoading = true;
@@ -548,7 +548,7 @@ class _LoginScreenState extends State<LoginScreen>
Padding(
padding: const EdgeInsets.only(left: 4, bottom: 16),
child: Text(
- AppPlatform.isWeb ? l.loginSignIn : l.loginConnectToServer,
+ AppPlatform.lacksPhonePlugins ? l.loginSignIn : l.loginConnectToServer,
style: tt.titleSmall?.copyWith(
color: cs.onSurfaceVariant.withValues(alpha: 0.7),
fontWeight: FontWeight.w500,
@@ -557,7 +557,7 @@ class _LoginScreenState extends State<LoginScreen>
),
// Server URL
- if (!AppPlatform.isWeb) _buildInputField(
+ if (!AppPlatform.lacksPhonePlugins) _buildInputField(
controller: _serverController,
label: l.loginServerAddress,
hint: l.loginServerHint,
@@ -736,7 +736,7 @@ class _LoginScreenState extends State<LoginScreen>
),
),
),
- if (!AppPlatform.isWeb) ...[
+ if (!AppPlatform.lacksPhonePlugins) ...[
const SizedBox(height: 8),
const Divider(height: 1),
const SizedBox(height: 4),
@@ -968,7 +968,7 @@ class _LoginScreenState extends State<LoginScreen>
try {
final result = await FilePicker.platform.pickFiles(
type: FileType.any,
- withData: AppPlatform.isWeb,
+ withData: AppPlatform.lacksPhonePlugins,
);
if (result == null || result.files.isEmpty) return;
@@ -1394,7 +1394,7 @@ class _LoginScreenState extends State<LoginScreen>
duration: const Duration(milliseconds: 350),
curve: Curves.easeOutCubic,
alignment: Alignment.topCenter,
- child: !AppPlatform.isWeb &&
+ child: !AppPlatform.lacksPhonePlugins &&
_serverValid && _oidcConfig != null && _oidcConfig!.enabled
? _buildOidcButton(cs, tt)
: const SizedBox.shrink(),
diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dart
index e1ba6e88..ff97942f 100644
--- a/lib/services/audio_player_service.dart
+++ b/lib/services/audio_player_service.dart
@@ -2884,7 +2884,7 @@ class AudioPlayerService extends ChangeNotifier {
// Configure streaming cache if enabled
final cacheSizeMb = await PlayerSettings.getStreamingCacheSizeMb();
debugPrint('[Player] Streaming cache setting: $cacheSizeMb MB');
- if (!AppPlatform.isWeb && cacheSizeMb > 0) {
+ if (!AppPlatform.lacksPhonePlugins && cacheSizeMb > 0) {
try {
await AudioPlayer.configureStreamingCache(cacheSizeMb);
debugPrint('[Player] Streaming cache configured: $cacheSizeMb MB');
@@ -2964,7 +2964,7 @@ class AudioPlayerService extends ChangeNotifier {
/// Check if BT audio (A2DP/SCO) is currently connected via native AudioManager.
static Future<bool> _isBluetoothAudioConnected() async {
- if (AppPlatform.isWeb) return false;
+ if (AppPlatform.lacksPhonePlugins) return false;
try {
final result = await _eqChannel.invokeMethod<bool>(
'isBluetoothAudioConnected',
@@ -2986,7 +2986,7 @@ class AudioPlayerService extends ChangeNotifier {
static bool get wasNoisyPause => _noisyPause;
static Future<void> _configureAudioSession() async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
final session = await AudioSession.instance;
_duckBriefInterruptions =
AppPlatform.isAndroid &&
@@ -4015,7 +4015,7 @@ class AudioPlayerService extends ChangeNotifier {
}
static Future<bool?> _setAudioSessionActive(bool active) async {
- if (AppPlatform.isWeb) return null;
+ if (AppPlatform.lacksPhonePlugins) return null;
return (await AudioSession.instance).setActive(active);
}
@@ -4073,7 +4073,7 @@ class AudioPlayerService extends ChangeNotifier {
unawaited(
_progressSync.addTimeSaved(streamingSeconds, _player?.speed ?? 1.0),
);
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
unawaited(
HomeWidgetService().addLocalListeningSeconds(streamingSeconds),
);
@@ -5355,7 +5355,7 @@ class AudioPlayerService extends ChangeNotifier {
// screen shows artwork even when the user is offline. Fall back to the
// remote HTTP URL when there's no local cover (streaming).
String? effectiveCoverUrl;
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
effectiveCoverUrl = coverUrl;
} else if (AppPlatform.isIOS) {
final localCover = DownloadService().getInfo(itemId).localCoverPath;
@@ -6096,7 +6096,7 @@ class AudioPlayerService extends ChangeNotifier {
unawaited(
_progressSync.addTimeSaved(secs, _player?.speed ?? 1.0),
);
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
unawaited(HomeWidgetService().addLocalListeningSeconds(secs));
}
if (online) await LocalSessionService().pushActive(api: _api!);
@@ -6108,7 +6108,7 @@ class AudioPlayerService extends ChangeNotifier {
_progressSync.addTimeSaved(secs, _player?.speed ?? 1.0),
);
// Widget ticks forward even when the server is unreachable.
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
unawaited(HomeWidgetService().addLocalListeningSeconds(secs));
}
_lastServerSync = DateTime.now();
@@ -6672,7 +6672,7 @@ class AudioPlayerService extends ChangeNotifier {
if (ok && elapsed > 0) {
// Tick the StatsWidget forward locally so "today" stays fresh between
// 15-min authoritative refreshes (which Android Doze throttles).
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
unawaited(HomeWidgetService().addLocalListeningSeconds(elapsed));
}
}
diff --git a/lib/services/download_service.dart b/lib/services/download_service.dart
index 07fbe66e..32f151fb 100644
--- a/lib/services/download_service.dart
+++ b/lib/services/download_service.dart
@@ -621,7 +621,7 @@ class DownloadService extends ChangeNotifier {
_queue.map((q) => _downloads[q.itemId]).whereType<DownloadInfo>().toList();
Future<void> init() {
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
_initialized = true;
return Future.value();
}
@@ -1335,7 +1335,7 @@ class DownloadService extends ChangeNotifier {
// that block, since the user asked for it back.
bool automatic = false,
}) async {
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
return 'Downloads are not available in the browser.';
}
if (shouldStart?.call() == false) return null;
diff --git a/lib/utils/app_platform.dart b/lib/utils/app_platform.dart
index 7d5c7ee7..7f561639 100644
--- a/lib/utils/app_platform.dart
+++ b/lib/utils/app_platform.dart
@@ -12,4 +12,9 @@ abstract final class AppPlatform {
static bool get isDesktop => isMacOS || isWindows || isLinux;
static bool get isMobile => isAndroid || isIOS;
+
+ /// The phone's plugins - audio engine, downloads, widgets, car, cast,
+ /// notifications - exist on Android and iOS only. The browser and, for now,
+ /// the desktop OSes run without them and take the web code paths.
+ static bool get lacksPhonePlugins => isWeb || isDesktop;
}
diff --git a/lib/utils/desktop_workspace.dart b/lib/utils/desktop_workspace.dart
index 04659dbc..b9f46e31 100644
--- a/lib/utils/desktop_workspace.dart
+++ b/lib/utils/desktop_workspace.dart
@@ -88,7 +88,7 @@ NavigatorState contentNavigator(BuildContext context) =>
/// MediaQuery whose size is overridden to the content pane, which would
/// disagree with the shell's own breakpoint between 960 and ~1208px.
bool isDesktopWorkspace(BuildContext context) {
- if (!AppPlatform.isWeb) return false;
+ if (!AppPlatform.lacksPhonePlugins) return false;
if (DesktopWorkspaceScope.isActive(context)) return true;
// Subscribe to size changes so callers rebuild on window resize.
MediaQuery.sizeOf(context);
diff --git a/lib/widgets/absorbing_shared.dart b/lib/widgets/absorbing_shared.dart
index 5231a828..8cc7d18d 100644
--- a/lib/widgets/absorbing_shared.dart
+++ b/lib/widgets/absorbing_shared.dart
@@ -228,7 +228,7 @@ class _DownloadWideButtonState extends State<DownloadWideButton> {
@override void initState() {
super.initState();
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
_dl = DownloadService()..addListener(_rebuild);
}
}
diff --git a/lib/widgets/book_card.dart b/lib/widgets/book_card.dart
index bf9b92bd..342c703f 100644
--- a/lib/widgets/book_card.dart
+++ b/lib/widgets/book_card.dart
@@ -232,7 +232,7 @@ class BookCard extends StatelessWidget {
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: () => _handleTap(context),
- onLongPress: AppPlatform.isWeb || selectionMode
+ onLongPress: AppPlatform.lacksPhonePlugins || selectionMode
? null
: () => _onLongPress(context),
borderRadius: BorderRadius.circular(16),
@@ -381,7 +381,7 @@ class BookCard extends StatelessWidget {
aspectRatio: coverAspectRatio,
child: _PressableCard(
onTap: () => _handleTap(context),
- onLongPress: AppPlatform.isWeb || selectionMode
+ onLongPress: AppPlatform.lacksPhonePlugins || selectionMode
? null
: () => _onLongPress(context),
borderRadius: 12,
diff --git a/lib/widgets/book_detail_sheet.dart b/lib/widgets/book_detail_sheet.dart
index 646cebd4..d652570a 100644
--- a/lib/widgets/book_detail_sheet.dart
+++ b/lib/widgets/book_detail_sheet.dart
@@ -862,7 +862,7 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
else
const SizedBox(height: 20),
const SizedBox(height: 12),
- if (isEbookOnly && AppPlatform.isWeb)
+ if (isEbookOnly && AppPlatform.lacksPhonePlugins)
SizedBox(height: 52, child: FilledButton.icon(
onPressed: null,
icon: const Icon(Icons.menu_book_rounded, size: 24),
@@ -1043,11 +1043,11 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
// Primary action row: Download | Fully Absorb | ebook download (ebook-only)
const SizedBox(height: 12),
Row(children: [
- if (AppPlatform.isWeb && auth.canDownload) ...[
+ if (AppPlatform.lacksPhonePlugins && auth.canDownload) ...[
Expanded(child: _webDownloadButton(context, cs, l, auth)),
const SizedBox(width: 8),
],
- if (!isEbookOnly && !AppPlatform.isWeb) ...[
+ if (!isEbookOnly && !AppPlatform.lacksPhonePlugins) ...[
Expanded(child: DownloadWideButton(itemId: widget.itemId, coverUrl: _coverUrl, title: title, author: authorName, accent: accent)),
const SizedBox(width: 8),
],
@@ -1079,7 +1079,7 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
]),
),
)),
- if (!AppPlatform.isWeb && isEbookOnly && ebookFile != null && canReadEbook(ebookFile)) ...[
+ if (!AppPlatform.lacksPhonePlugins && isEbookOnly && ebookFile != null && canReadEbook(ebookFile)) ...[
const SizedBox(width: 8),
// For ebook-only books the big button above is already "Read", so this
// slot is the offline download (matching the audiobook download
@@ -1433,7 +1433,7 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
if (!isEbookOnly)
Row(children: [
Expanded(child: _quickAbsorbButton(context, cs, tt, auth, accent, onAccent, title, authorName, duration, chapters, isFinished, progress)),
- if (!AppPlatform.isWeb) ...[
+ if (!AppPlatform.lacksPhonePlugins) ...[
const SizedBox(width: 10),
Expanded(child: DownloadWideButton(itemId: widget.itemId, coverUrl: _coverUrl, title: title, author: authorName, accent: accent)),
],
@@ -1518,17 +1518,17 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
if (!lib.isOffline && !lib.isPodcastLibrary && auth.isAdmin) {
add(Icons.collections_bookmark_rounded, l.addToCollection, () => CollectionPickerSheet.show(context, widget.itemId));
}
- if (!AppPlatform.isWeb && ebookFile != null && canReadEbook(ebookFile)) {
+ if (!AppPlatform.lacksPhonePlugins && ebookFile != null && canReadEbook(ebookFile)) {
add(Icons.menu_book_rounded, l.readEbook, () => _openEbookReader(context, auth, ebookFile, title));
}
// Save/Send push the file elsewhere, which needs the server's own file
// entry (with ino) - the cache-synthesized fallback can't serve them.
final serverEbookFile = resolveEbookFile(_item);
- if (!AppPlatform.isWeb && serverEbookFile != null) {
+ if (!AppPlatform.lacksPhonePlugins && serverEbookFile != null) {
add(_ebookSaved ? Icons.download_done_rounded : Icons.save_alt_rounded,
l.ebookSaveToDevice, () => _saveEbook(context, auth, serverEbookFile, title));
}
- if (!AppPlatform.isWeb &&
+ if (!AppPlatform.lacksPhonePlugins &&
serverEbookFile != null &&
auth.ereaderDevices.isNotEmpty) {
add(Icons.send_to_mobile_rounded, l.sendToEreader, () => _sendToEreader(context, auth));
@@ -2024,7 +2024,7 @@ class _BookDetailSheetContentState extends State<_BookDetailSheetContent> {
asin,
countryCode: ui.PlatformDispatcher.instance.locale.countryCode,
);
- if (AppPlatform.isWeb) {
+ if (AppPlatform.lacksPhonePlugins) {
unawaited(_launchAudibleReviews(context, uri));
return;
}
diff --git a/lib/widgets/bookmark_detail_dialog.dart b/lib/widgets/bookmark_detail_dialog.dart
index 5e3444b8..94ae9d84 100644
--- a/lib/widgets/bookmark_detail_dialog.dart
+++ b/lib/widgets/bookmark_detail_dialog.dart
@@ -626,7 +626,7 @@ class _BookmarkDetailSheetState extends State<BookmarkDetailSheet> {
),
),
const SizedBox(height: 8),
- if (!AppPlatform.isWeb) ...[
+ if (!AppPlatform.lacksPhonePlugins) ...[
SizedBox(
width: double.infinity,
child: OutlinedButton.icon(
diff --git a/lib/widgets/card_button_config.dart b/lib/widgets/card_button_config.dart
index 94c56c00..95ae9a7f 100644
--- a/lib/widgets/card_button_config.dart
+++ b/lib/widgets/card_button_config.dart
@@ -56,11 +56,11 @@ String localizedCardButtonLabel(AppLocalizations l, CardButtonDef def) {
/// - F-Droid (GMS-free): Chromecast needs Google Play Services, so the stub
/// service reports castSupported=false and the button is dropped entirely.
final Set<String> _hiddenButtons = {
- if (AppPlatform.isWeb || AppPlatform.isIOS) 'cast',
+ if (AppPlatform.lacksPhonePlugins || AppPlatform.isIOS) 'cast',
if (!ChromecastService.castSupported) 'cast',
// AirPlay is iOS-only (Chromecast covers Android).
- if (AppPlatform.isWeb || !AppPlatform.isIOS) 'airplay',
- if (AppPlatform.isWeb) ...{
+ if (AppPlatform.lacksPhonePlugins || !AppPlatform.isIOS) 'airplay',
+ if (AppPlatform.lacksPhonePlugins) ...{
'car',
'download',
'ebook',
diff --git a/lib/widgets/episode_detail_sheet.dart b/lib/widgets/episode_detail_sheet.dart
index 9cb487f0..8f13aae9 100644
--- a/lib/widgets/episode_detail_sheet.dart
+++ b/lib/widgets/episode_detail_sheet.dart
@@ -199,7 +199,7 @@ class _EpisodeDetailSheetState extends State<EpisodeDetailSheet> {
}
Future<void> _download() async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
final auth = context.read<AuthProvider>();
final api = auth.apiService;
if (api == null) return;
@@ -404,7 +404,7 @@ class _EpisodeDetailSheetState extends State<EpisodeDetailSheet> {
// Download + Finished row
Row(children: [
- if (!AppPlatform.isWeb) ...[
+ if (!AppPlatform.lacksPhonePlugins) ...[
Expanded(child: _downloadCell(cs, l, dlKey)),
const SizedBox(width: 8),
],
@@ -670,7 +670,7 @@ class _EpisodeDetailSheetState extends State<EpisodeDetailSheet> {
_playButton(cs, tt, l, progress, isFinished),
const SizedBox(height: 10),
Row(children: [
- if (!AppPlatform.isWeb) ...[
+ if (!AppPlatform.lacksPhonePlugins) ...[
Expanded(child: _downloadCell(cs, l, dlKey)),
const SizedBox(width: 8),
],
diff --git a/lib/widgets/episode_list_sheet.dart b/lib/widgets/episode_list_sheet.dart
index 25278382..3791e8d8 100644
--- a/lib/widgets/episode_list_sheet.dart
+++ b/lib/widgets/episode_list_sheet.dart
@@ -537,7 +537,7 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
}
Future<void> _downloadEpisode(Map<String, dynamic> episode) async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
final auth = context.read<AuthProvider>();
final api = auth.apiService;
if (api == null) return;
@@ -564,7 +564,7 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
}
Future<void> _downloadAll() async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
final auth = context.read<AuthProvider>();
final api = auth.apiService;
if (api == null) return;
@@ -617,7 +617,7 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
Widget _buildOverflowMenu(ColorScheme cs) {
int downloaded = 0;
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
final dl = DownloadService();
for (final ep in _episodes) {
final eid = ep['id'] as String? ?? '';
@@ -625,7 +625,7 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
if (dl.isDownloaded(key)) downloaded++;
}
}
- final allDownloaded = !AppPlatform.isWeb && downloaded == _episodes.length;
+ final allDownloaded = !AppPlatform.lacksPhonePlugins && downloaded == _episodes.length;
if (_isDownloadingAll) {
return Padding(
@@ -660,12 +660,12 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
Center(child: Container(width: 40, height: 4, margin: const EdgeInsets.only(bottom: 16),
decoration: BoxDecoration(color: cs.onSurface.withValues(alpha: 0.24), borderRadius: BorderRadius.circular(2)))),
ActionPillGrid(items: [
- if (!AppPlatform.isWeb && !allDownloaded)
+ if (!AppPlatform.lacksPhonePlugins && !allDownloaded)
ActionPillData(
icon: Icons.download_rounded,
label: downloaded > 0 ? l.downloadRemainingCount(_episodes.length - downloaded) : l.downloadAll,
onTap: () { Navigator.pop(ctx); _downloadAll(); }),
- if (!AppPlatform.isWeb && _itemId.isNotEmpty)
+ if (!AppPlatform.lacksPhonePlugins && _itemId.isNotEmpty)
ActionPillData(
icon: _autoDownloadEnabled ? Icons.downloading_rounded : Icons.download_outlined,
label: _autoDownloadEnabled ? l.turnAutoDownloadOff : l.turnAutoDownloadOn,
@@ -907,7 +907,7 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
return Wrap(spacing: 8, runSpacing: 8, alignment: WrapAlignment.center, children: [
if (!_isLoading) _chip(Icons.podcasts_rounded, l.episodeListEpisodeCount(_episodes.length)),
if (unfinishedCount > 0) _chip(Icons.fiber_new_rounded, l.episodeListUnfinishedCount(unfinishedCount), highlight: true),
- if (!AppPlatform.isWeb && _autoDownloadEnabled) _chip(Icons.downloading_rounded, l.episodeListAutoDownloadChip),
+ if (!AppPlatform.lacksPhonePlugins && _autoDownloadEnabled) _chip(Icons.downloading_rounded, l.episodeListAutoDownloadChip),
if (_subscribed) _chip(Icons.notifications_active_rounded, l.episodeListSubscribedChip, highlight: true),
..._genres.take(3).map((g) => _chip(Icons.tag_rounded, g)),
..._tags.take(5).map((t) => _chip(Icons.local_offer_outlined, t)),
diff --git a/lib/widgets/episode_row.dart b/lib/widgets/episode_row.dart
index 3c427bae..e9073312 100644
--- a/lib/widgets/episode_row.dart
+++ b/lib/widgets/episode_row.dart
@@ -37,7 +37,7 @@ class _EpisodeRowState extends State<EpisodeRow> {
final cs = Theme.of(context).colorScheme;
final l = AppLocalizations.of(context)!;
final lib = context.watch<LibraryProvider>();
- final gesturePolicy = MediaCardGesturePolicy(isWeb: AppPlatform.isWeb);
+ final gesturePolicy = MediaCardGesturePolicy(isWeb: AppPlatform.lacksPhonePlugins);
final ep = widget.episode;
final title = ep['title'] as String? ?? l.episodeRowEpisode;
@@ -180,7 +180,7 @@ class _EpisodeRowState extends State<EpisodeRow> {
style: TextStyle(fontSize: 11, color: cs.onSurfaceVariant.withValues(alpha: 0.6)),
),
),
- if (!AppPlatform.isWeb) ListenableBuilder(
+ if (!AppPlatform.lacksPhonePlugins) ListenableBuilder(
listenable: DownloadService(),
builder: (_, __) {
final downloaded = DownloadService().isDownloaded(dlKey);
@@ -202,7 +202,7 @@ class _EpisodeRowState extends State<EpisodeRow> {
mainAxisSize: MainAxisSize.min,
children: [
// Download button (reactive)
- if (!AppPlatform.isWeb) ListenableBuilder(
+ if (!AppPlatform.lacksPhonePlugins) ListenableBuilder(
listenable: DownloadService(),
builder: (_, __) {
final dl = DownloadService();
diff --git a/lib/widgets/expanded_card.dart b/lib/widgets/expanded_card.dart
index 208529de..96dc9fcb 100644
--- a/lib/widgets/expanded_card.dart
+++ b/lib/widgets/expanded_card.dart
@@ -187,7 +187,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
}
String? get _coverUrl {
- if (!AppPlatform.isWeb) {
+ if (!AppPlatform.lacksPhonePlugins) {
final episodeId = _episodeId;
final downloadKey = episodeId == null ? _itemId : '$_itemId-$episodeId';
final localCover = DownloadService().getInfo(downloadKey).localCoverPath;
@@ -203,7 +203,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
return lib.getCoverUrl(_itemId, width: 1200);
}
bool get _isLocalCover =>
- !AppPlatform.isWeb && _coverUrl != null && _coverUrl!.startsWith('/');
+ !AppPlatform.lacksPhonePlugins && _coverUrl != null && _coverUrl!.startsWith('/');
@override
void initState() {
@@ -525,7 +525,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
final url = _coverUrl;
if (url == null) return;
final ImageProvider provider;
- if (!AppPlatform.isWeb && url.startsWith('/')) {
+ if (!AppPlatform.lacksPhonePlugins && url.startsWith('/')) {
provider = FileImage(File(url));
} else {
provider = CachedNetworkImageProvider(url, headers: context.read<LibraryProvider>().mediaHeaders);
@@ -557,7 +557,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
try {
final ImageProvider provider;
- if (!AppPlatform.isWeb && url.startsWith('/')) {
+ if (!AppPlatform.lacksPhonePlugins && url.startsWith('/')) {
provider = FileImage(File(url));
} else {
final lib = context.read<LibraryProvider>();
@@ -714,7 +714,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
child: LayoutBuilder(
builder: (context, outerConstraints) {
final compact = outerConstraints.maxHeight < 600;
- final wide = AppPlatform.isWeb
+ final wide = AppPlatform.lacksPhonePlugins
? outerConstraints.maxWidth >= 900
: outerConstraints.maxWidth >
outerConstraints.maxHeight;
@@ -769,7 +769,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
coverH = s;
}
final dlKey = _episodeId != null ? '$_itemId-$_episodeId' : _itemId;
- final isDownloaded = !AppPlatform.isWeb &&
+ final isDownloaded = !AppPlatform.lacksPhonePlugins &&
DownloadService().isDownloaded(dlKey);
final castService = ChromecastService();
final isCastingThis = castService.isCasting && castService.castingItemId == _itemId;
@@ -1055,7 +1055,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
);
}),
),
- if (AppPlatform.isWeb)
+ if (AppPlatform.lacksPhonePlugins)
Positioned(
top: 16,
right: 20,
@@ -1080,7 +1080,7 @@ class _ExpandedCardState extends State<ExpandedCard> {
),
);
- if (!AppPlatform.isWeb) return player;
+ if (!AppPlatform.lacksPhonePlugins) return player;
return CallbackShortcuts(
bindings: <ShortcutActivator, VoidCallback>{
const SingleActivator(LogicalKeyboardKey.escape): _dismissExpanded,
diff --git a/lib/widgets/home_section.dart b/lib/widgets/home_section.dart
index 200cdca8..b9a673f4 100644
--- a/lib/widgets/home_section.dart
+++ b/lib/widgets/home_section.dart
@@ -463,7 +463,7 @@ class _EpisodeCard extends StatelessWidget {
final cs = Theme.of(context).colorScheme;
final tt = Theme.of(context).textTheme;
final lib = context.watch<LibraryProvider>();
- final gesturePolicy = MediaCardGesturePolicy(isWeb: AppPlatform.isWeb);
+ final gesturePolicy = MediaCardGesturePolicy(isWeb: AppPlatform.lacksPhonePlugins);
final itemId = item['id'] as String? ?? '';
final media = item['media'] as Map<String, dynamic>? ?? {};
diff --git a/lib/widgets/library_grid_tiles.dart b/lib/widgets/library_grid_tiles.dart
index 45683059..a3c255e8 100644
--- a/lib/widgets/library_grid_tiles.dart
+++ b/lib/widgets/library_grid_tiles.dart
@@ -88,7 +88,7 @@ class _GridBookTileState extends State<GridBookTile> {
final unfinishedCount =
lib.isPodcastLibrary ? lib.getUnfinishedEpisodeCount(widget.item) : 0;
- final gesturePolicy = MediaCardGesturePolicy(isWeb: AppPlatform.isWeb);
+ final gesturePolicy = MediaCardGesturePolicy(isWeb: AppPlatform.lacksPhonePlugins);
final canEdit = itemId.isNotEmpty &&
!lib.isPodcastLibrary &&
!lib.isOffline &&
diff --git a/lib/widgets/library_sort_filter_sheet.dart b/lib/widgets/library_sort_filter_sheet.dart
index b059481d..53bf36f1 100644
--- a/lib/widgets/library_sort_filter_sheet.dart
+++ b/lib/widgets/library_sort_filter_sheet.dart
@@ -436,7 +436,7 @@ class _SortFilterSheetState extends State<SortFilterSheet> with SingleTickerProv
(LibraryFilter.inProgress, l.inProgress, Icons.play_circle_outline_rounded),
(LibraryFilter.finished, l.filterFinished, Icons.check_circle_outline_rounded),
(LibraryFilter.notStarted, l.notStarted, Icons.circle_outlined),
- if (!AppPlatform.isWeb)
+ if (!AppPlatform.lacksPhonePlugins)
(LibraryFilter.downloaded, l.downloaded, Icons.download_done_rounded),
(LibraryFilter.hasEbook, l.hasEbook, Icons.menu_book_rounded),
(LibraryFilter.noEbook, l.noEbook, Icons.menu_book_outlined),
diff --git a/lib/widgets/offline_status_icon.dart b/lib/widgets/offline_status_icon.dart
index 81da47f3..8a15bb37 100644
--- a/lib/widgets/offline_status_icon.dart
+++ b/lib/widgets/offline_status_icon.dart
@@ -18,7 +18,7 @@ class OfflineStatusIcon extends StatelessWidget {
@override
Widget build(BuildContext context) {
- if (AppPlatform.isWeb) return const SizedBox.shrink();
+ if (AppPlatform.lacksPhonePlugins) return const SizedBox.shrink();
final lib = context.watch<LibraryProvider>();
final auth = context.watch<AuthProvider>();
final l = AppLocalizations.of(context)!;
diff --git a/lib/widgets/podcast_episode_feed.dart b/lib/widgets/podcast_episode_feed.dart
index 40877903..cd7b6d0c 100644
--- a/lib/widgets/podcast_episode_feed.dart
+++ b/lib/widgets/podcast_episode_feed.dart
@@ -426,7 +426,7 @@ class _PodcastEpisodeFeedState extends State<PodcastEpisodeFeed> {
child: url == null
? placeholder
// Downloaded shows resolve to a local file path.
- : !AppPlatform.isWeb && url.startsWith('/')
+ : !AppPlatform.lacksPhonePlugins && url.startsWith('/')
? Image.file(
File(url),
width: 48,
@@ -455,7 +455,7 @@ class _PodcastEpisodeFeedState extends State<PodcastEpisodeFeed> {
_filter,
progress: progress,
finished: finished,
- downloaded: !AppPlatform.isWeb &&
+ downloaded: !AppPlatform.lacksPhonePlugins &&
DownloadService().isDownloaded('$showId-$epId'),
subscribed: lib.isPodcastSubscribed(showId),
);
@@ -508,7 +508,7 @@ class _PodcastEpisodeFeedState extends State<PodcastEpisodeFeed> {
}
Future<void> _downloadEpisode(Map<String, dynamic> ep) async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
final api = context.read<AuthProvider>().apiService;
if (api == null) return;
final showId = _showIdOf(ep);
@@ -615,7 +615,7 @@ class _PodcastEpisodeFeedState extends State<PodcastEpisodeFeed> {
('unplayed', l.filterUnplayed),
('inprogress', l.inProgress),
('finished', l.filterFinished),
- if (!AppPlatform.isWeb) ('downloaded', l.downloaded),
+ if (!AppPlatform.lacksPhonePlugins) ('downloaded', l.downloaded),
]) ...[
ChoiceChip(
label: Text(label),
@@ -681,7 +681,7 @@ class _PodcastEpisodeFeedState extends State<PodcastEpisodeFeed> {
color: cs.primary,
onTrigger: () => _toggleFinished(ep),
),
- onEndToStart: AppPlatform.isWeb
+ onEndToStart: AppPlatform.lacksPhonePlugins
? null
: SwipeActionSpec(
icon: Icons.download_rounded,
diff --git a/lib/widgets/series_books_sheet.dart b/lib/widgets/series_books_sheet.dart
index 1181956a..ac220a31 100644
--- a/lib/widgets/series_books_sheet.dart
+++ b/lib/widgets/series_books_sheet.dart
@@ -1208,7 +1208,7 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
if (dl.isDownloaded(book['id'] as String? ?? '')) downloaded++;
}
// Nothing downloads in a browser, so neither download pill shows there.
- final allDownloaded = AppPlatform.isWeb || downloaded == _books.length;
+ final allDownloaded = AppPlatform.lacksPhonePlugins || downloaded == _books.length;
final hasSeriesId = widget.seriesId != null && widget.seriesId!.isNotEmpty;
return [
// Only once the up next book is past the first few rows.
@@ -1217,7 +1217,7 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
icon: Icons.keyboard_double_arrow_down_rounded,
label: l.seriesJumpToUpNext,
onTap: _jumpToUpNext),
- if (!AppPlatform.isWeb && hasSeriesId)
+ if (!AppPlatform.lacksPhonePlugins && hasSeriesId)
ActionPillData(
icon: _autoDownloadEnabled ? Icons.downloading_rounded : Icons.download_outlined,
label: _autoDownloadEnabled ? l.turnAutoDownloadOff : l.turnAutoDownloadOn,
@@ -1265,7 +1265,7 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
if (confirmed == true) _markAllFinished();
}
}),
- if (!AppPlatform.isWeb && hasSeriesId)
+ if (!AppPlatform.lacksPhonePlugins && hasSeriesId)
ActionPillData(
icon: _scanExcluded ? Icons.visibility_rounded : Icons.visibility_off_rounded,
label: _scanExcluded ? l.seriesIncludeInScan : l.seriesExcludeFromScan,
@@ -1280,7 +1280,7 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
}
Future<void> _downloadAll() async {
- if (AppPlatform.isWeb) return;
+ if (AppPlatform.lacksPhonePlugins) return;
final auth = context.read<AuthProvider>();
final api = auth.apiService;
if (api == null) return;
@@ -1559,10 +1559,10 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
final progress = lib.getProgress(bookId);
final isFinished = lib.getProgressData(bookId)?['isFinished'] == true;
final isDownloaded =
- !AppPlatform.isWeb && DownloadService().isDownloaded(bookId);
+ !AppPlatform.lacksPhonePlugins && DownloadService().isDownloaded(bookId);
final isDownloading =
- !AppPlatform.isWeb && DownloadService().isDownloading(bookId);
- final downloadPct = AppPlatform.isWeb
+ !AppPlatform.lacksPhonePlugins && DownloadService().isDownloading(bookId);
+ final downloadPct = AppPlatform.lacksPhonePlugins
? 0
: (DownloadService().downloadProgress(bookId) * 100)
.clamp(0, 100)
@@ -1612,7 +1612,7 @@ class _SeriesBooksSheetState extends State<SeriesBooksSheet> {
child: Stack(children: [
Positioned.fill(
child: coverUrl != null
- ? (!AppPlatform.isWeb && coverUrl.startsWith('/')
+ ? (!AppPlatform.lacksPhonePlugins && coverUrl.startsWith('/')
? Image.file(File(coverUrl), fit: BoxFit.cover,
errorBuilder: (_, __, ___) => _placeholder(cs))
: CachedNetworkImage(
diff --git a/lib/widgets/sleep_timer_sheet.dart b/lib/widgets/sleep_timer_sheet.dart
index 4df18f5c..81a2a877 100644
--- a/lib/widgets/sleep_timer_sheet.dart
+++ b/lib/widgets/sleep_timer_sheet.dart
@@ -164,7 +164,7 @@ class _SleepTimerSheetState extends State<SleepTimerSheet> {
// Rewind on sleep
_buildRewindSection(accent, tt, l),
- if (!AppPlatform.isWeb) ...[
+ if (!AppPlatform.lacksPhonePlugins) ...[
const SizedBox(height: 12),
Container(
height: 0.5,
@@ -284,7 +284,7 @@ class _SleepTimerSheetState extends State<SleepTimerSheet> {
Container(height: 0.5, color: cs.onSurface.withValues(alpha: 0.08)),
const SizedBox(height: 12),
_buildRewindSection(accent, tt, l),
- if (!AppPlatform.isWeb) ...[
+ if (!AppPlatform.lacksPhonePlugins) ...[
const SizedBox(height: 12),
Container(height: 0.5, color: cs.onSurface.withValues(alpha: 0.08)),
const SizedBox(height: 12),
diff --git a/lib/widgets/tips_sheet.dart b/lib/widgets/tips_sheet.dart
index 8ab6b526..e4663a2a 100644
--- a/lib/widgets/tips_sheet.dart
+++ b/lib/widgets/tips_sheet.dart
@@ -92,7 +92,7 @@ void showTipsSheet(BuildContext context) {
title: w.tipsSheetQuickAddAbsorbingTitle,
desc: w.tipsSheetQuickAddAbsorbingDesc,
),
- if (!AppPlatform.isWeb)
+ if (!AppPlatform.lacksPhonePlugins)
_tipCard(cs, tt,
icon: Icons.vibration_rounded,
title: l.tipsSheetShakeExtendSleepTitle,
@@ -133,7 +133,7 @@ void showTipsSheet(BuildContext context) {
title: l.tipsSheetSeriesQueueModeTitle,
desc: l.tipsSheetSeriesQueueModeDesc,
),
- if (!AppPlatform.isWeb)
+ if (!AppPlatform.lacksPhonePlugins)
_tipCard(cs, tt,
icon: Icons.airplanemode_active_rounded,
title: l.tipsSheetOfflineModeTitle,
@@ -144,7 +144,7 @@ void showTipsSheet(BuildContext context) {
title: l.tipsSheetUpcomingReleasesTitle,
desc: l.tipsSheetUpcomingReleasesDesc,
),
- if (!AppPlatform.isWeb)
+ if (!AppPlatform.lacksPhonePlugins)
_tipCard(cs, tt,
icon: Icons.equalizer_rounded,
title: l.tipsSheetPerBookEqTitle,
@@ -165,7 +165,7 @@ void showTipsSheet(BuildContext context) {
title: l.tipsSheetSleepFadeChimeTitle,
desc: l.tipsSheetSleepFadeChimeDesc,
),
- if (!AppPlatform.isWeb)
+ if (!AppPlatform.lacksPhonePlugins)
_tipCard(cs, tt,
icon: Icons.directions_car_rounded,
title: l.tipsSheetCarModeTitle,
diff --git a/packages/whisper_ggml_plus/windows/CMakeLists.txt b/packages/whisper_ggml_plus/windows/CMakeLists.txt
index 26c2eb3d..2df97ea5 100644
--- a/packages/whisper_ggml_plus/windows/CMakeLists.txt
+++ b/packages/whisper_ggml_plus/windows/CMakeLists.txt
@@ -32,8 +32,11 @@ add_compile_definitions(
GGML_USE_CPU
)
-add_subdirectory("${GGML_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/ggml")
-add_subdirectory("${WHISPER_SRC_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/whisper")
+# EXCLUDE_FROM_ALL keeps the libraries' own install() rules out of the app
+# bundle step, whose prefix is a generator expression they cannot resolve.
+# They still build as link dependencies of the plugin.
+add_subdirectory("${GGML_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/ggml" EXCLUDE_FROM_ALL)
+add_subdirectory("${WHISPER_SRC_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/whisper" EXCLUDE_FROM_ALL)
add_library(${PROJECT_NAME} SHARED
"${CMAKE_CURRENT_LIST_DIR}/whisper_ggml_plus.cpp"
diff --git a/windows/.gitignore b/windows/.gitignore
new file mode 100644
index 00000000..d492d0d9
--- /dev/null
+++ b/windows/.gitignore
@@ -0,0 +1,17 @@
+flutter/ephemeral/
+
+# Visual Studio user-specific files.
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# Visual Studio build-related files.
+x64/
+x86/
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt
new file mode 100644
index 00000000..1e3aa3f1
--- /dev/null
+++ b/windows/CMakeLists.txt
@@ -0,0 +1,108 @@
+# Project-level configuration.
+cmake_minimum_required(VERSION 3.14)
+project(absorb LANGUAGES CXX)
+
+# The name of the executable created for the application. Change this to change
+# the on-disk name of your application.
+set(BINARY_NAME "absorb")
+
+# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
+# versions of CMake.
+cmake_policy(VERSION 3.14...3.25)
+
+# Define build configuration option.
+get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(IS_MULTICONFIG)
+ set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
+ CACHE STRING "" FORCE)
+else()
+ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
+ set(CMAKE_BUILD_TYPE "Debug" CACHE
+ STRING "Flutter build mode" FORCE)
+ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
+ "Debug" "Profile" "Release")
+ endif()
+endif()
+# Define settings for the Profile build mode.
+set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
+set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
+set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
+set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
+
+# Use Unicode for all projects.
+add_definitions(-DUNICODE -D_UNICODE)
+
+# Compilation settings that should be applied to most targets.
+#
+# Be cautious about adding new options here, as plugins use this function by
+# default. In most cases, you should add new options to specific targets instead
+# of modifying this function.
+function(APPLY_STANDARD_SETTINGS TARGET)
+ target_compile_features(${TARGET} PUBLIC cxx_std_17)
+ target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
+ target_compile_options(${TARGET} PRIVATE /EHsc)
+ target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
+ target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
+endfunction()
+
+# Flutter library and tool build rules.
+set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
+add_subdirectory(${FLUTTER_MANAGED_DIR})
+
+# Application build; see runner/CMakeLists.txt.
+add_subdirectory("runner")
+
+
+# Generated plugin build rules, which manage building the plugins and adding
+# them to the application.
+include(flutter/generated_plugins.cmake)
+
+
+# === Installation ===
+# Support files are copied into place next to the executable, so that it can
+# run in place. This is done instead of making a separate bundle (as on Linux)
+# so that building and running from within Visual Studio will work.
+set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
+# Make the "install" step default, as it's required to run.
+set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
+endif()
+
+set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
+set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
+
+install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
+ COMPONENT Runtime)
+
+install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
+ COMPONENT Runtime)
+
+install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
+ COMPONENT Runtime)
+
+if(PLUGIN_BUNDLED_LIBRARIES)
+ install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
+ DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
+ COMPONENT Runtime)
+endif()
+
+# Copy the native assets provided by the build.dart from all packages.
+set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/")
+install(DIRECTORY "${NATIVE_ASSETS_DIR}"
+ DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
+ COMPONENT Runtime)
+
+# Fully re-copy the assets directory on each build to avoid having stale files
+# from a previous install.
+set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
+install(CODE "
+ file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
+ " COMPONENT Runtime)
+install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
+ DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
+
+# Install the AOT library on non-Debug builds only.
+install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
+ CONFIGURATIONS Profile;Release
+ COMPONENT Runtime)
diff --git a/windows/flutter/CMakeLists.txt b/windows/flutter/CMakeLists.txt
new file mode 100644
index 00000000..903f4899
--- /dev/null
+++ b/windows/flutter/CMakeLists.txt
@@ -0,0 +1,109 @@
+# This file controls Flutter-level build steps. It should not be edited.
+cmake_minimum_required(VERSION 3.14)
+
+set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
+
+# Configuration provided via flutter tool.
+include(${EPHEMERAL_DIR}/generated_config.cmake)
+
+# TODO: Move the rest of this into files in ephemeral. See
+# https://github.com/flutter/flutter/issues/57146.
+set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
+
+# Set fallback configurations for older versions of the flutter tool.
+if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
+ set(FLUTTER_TARGET_PLATFORM "windows-x64")
+endif()
+
+# === Flutter Library ===
+set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
+
+# Published to parent scope for install step.
+set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
+set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
+set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
+set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
+
+list(APPEND FLUTTER_LIBRARY_HEADERS
+ "flutter_export.h"
+ "flutter_windows.h"
+ "flutter_messenger.h"
+ "flutter_plugin_registrar.h"
+ "flutter_texture_registrar.h"
+)
+list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
+add_library(flutter INTERFACE)
+target_include_directories(flutter INTERFACE
+ "${EPHEMERAL_DIR}"
+)
+target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
+add_dependencies(flutter flutter_assemble)
+
+# === Wrapper ===
+list(APPEND CPP_WRAPPER_SOURCES_CORE
+ "core_implementations.cc"
+ "standard_codec.cc"
+)
+list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
+list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
+ "plugin_registrar.cc"
+)
+list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
+list(APPEND CPP_WRAPPER_SOURCES_APP
+ "flutter_engine.cc"
+ "flutter_view_controller.cc"
+)
+list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
+
+# Wrapper sources needed for a plugin.
+add_library(flutter_wrapper_plugin STATIC
+ ${CPP_WRAPPER_SOURCES_CORE}
+ ${CPP_WRAPPER_SOURCES_PLUGIN}
+)
+apply_standard_settings(flutter_wrapper_plugin)
+set_target_properties(flutter_wrapper_plugin PROPERTIES
+ POSITION_INDEPENDENT_CODE ON)
+set_target_properties(flutter_wrapper_plugin PROPERTIES
+ CXX_VISIBILITY_PRESET hidden)
+target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
+target_include_directories(flutter_wrapper_plugin PUBLIC
+ "${WRAPPER_ROOT}/include"
+)
+add_dependencies(flutter_wrapper_plugin flutter_assemble)
+
+# Wrapper sources needed for the runner.
+add_library(flutter_wrapper_app STATIC
+ ${CPP_WRAPPER_SOURCES_CORE}
+ ${CPP_WRAPPER_SOURCES_APP}
+)
+apply_standard_settings(flutter_wrapper_app)
+target_link_libraries(flutter_wrapper_app PUBLIC flutter)
+target_include_directories(flutter_wrapper_app PUBLIC
+ "${WRAPPER_ROOT}/include"
+)
+add_dependencies(flutter_wrapper_app flutter_assemble)
+
+# === Flutter tool backend ===
+# _phony_ is a non-existent file to force this command to run every time,
+# since currently there's no way to get a full input/output list from the
+# flutter tool.
+set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
+set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
+add_custom_command(
+ OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
+ ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
+ ${CPP_WRAPPER_SOURCES_APP}
+ ${PHONY_OUTPUT}
+ COMMAND ${CMAKE_COMMAND} -E env
+ ${FLUTTER_TOOL_ENVIRONMENT}
+ "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
+ ${FLUTTER_TARGET_PLATFORM} $<CONFIG>
+ VERBATIM
+)
+add_custom_target(flutter_assemble DEPENDS
+ "${FLUTTER_LIBRARY}"
+ ${FLUTTER_LIBRARY_HEADERS}
+ ${CPP_WRAPPER_SOURCES_CORE}
+ ${CPP_WRAPPER_SOURCES_PLUGIN}
+ ${CPP_WRAPPER_SOURCES_APP}
+)
diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc
new file mode 100644
index 00000000..077e6d24
--- /dev/null
+++ b/windows/flutter/generated_plugin_registrant.cc
@@ -0,0 +1,35 @@
+//
+// Generated file. Do not edit.
+//
+
+// clang-format off
+
+#include "generated_plugin_registrant.h"
+
+#include <app_links/app_links_plugin_c_api.h>
+#include <connectivity_plus/connectivity_plus_windows_plugin.h>
+#include <desktop_webview_window/desktop_webview_window_plugin.h>
+#include <flutter_inappwebview_windows/flutter_inappwebview_windows_plugin_c_api.h>
+#include <permission_handler_windows/permission_handler_windows_plugin.h>
+#include <share_plus/share_plus_windows_plugin_c_api.h>
+#include <url_launcher_windows/url_launcher_windows.h>
+#include <window_to_front/window_to_front_plugin.h>
+
+void RegisterPlugins(flutter::PluginRegistry* registry) {
+ AppLinksPluginCApiRegisterWithRegistrar(
+ registry->GetRegistrarForPlugin("AppLinksPluginCApi"));
+ ConnectivityPlusWindowsPluginRegisterWithRegistrar(
+ registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
+ DesktopWebviewWindowPluginRegisterWithRegistrar(
+ registry->GetRegistrarForPlugin("DesktopWebviewWindowPlugin"));
+ FlutterInappwebviewWindowsPluginCApiRegisterWithRegistrar(
+ registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi"));
+ PermissionHandlerWindowsPluginRegisterWithRegistrar(
+ registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
+ SharePlusWindowsPluginCApiRegisterWithRegistrar(
+ registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
+ UrlLauncherWindowsRegisterWithRegistrar(
+ registry->GetRegistrarForPlugin("UrlLauncherWindows"));
+ WindowToFrontPluginRegisterWithRegistrar(
+ registry->GetRegistrarForPlugin("WindowToFrontPlugin"));
+}
diff --git a/windows/flutter/generated_plugin_registrant.h b/windows/flutter/generated_plugin_registrant.h
new file mode 100644
index 00000000..dc139d85
--- /dev/null
+++ b/windows/flutter/generated_plugin_registrant.h
@@ -0,0 +1,15 @@
+//
+// Generated file. Do not edit.
+//
+
+// clang-format off
+
+#ifndef GENERATED_PLUGIN_REGISTRANT_
+#define GENERATED_PLUGIN_REGISTRANT_
+
+#include <flutter/plugin_registry.h>
+
+// Registers Flutter plugins.
+void RegisterPlugins(flutter::PluginRegistry* registry);
+
+#endif // GENERATED_PLUGIN_REGISTRANT_
diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake
new file mode 100644
index 00000000..6e344ae8
--- /dev/null
+++ b/windows/flutter/generated_plugins.cmake
@@ -0,0 +1,32 @@
+#
+# Generated file, do not edit.
+#
+
+list(APPEND FLUTTER_PLUGIN_LIST
+ app_links
+ connectivity_plus
+ desktop_webview_window
+ flutter_inappwebview_windows
+ permission_handler_windows
+ share_plus
+ url_launcher_windows
+ window_to_front
+)
+
+list(APPEND FLUTTER_FFI_PLUGIN_LIST
+ whisper_ggml_plus
+)
+
+set(PLUGIN_BUNDLED_LIBRARIES)
+
+foreach(plugin ${FLUTTER_PLUGIN_LIST})
+ add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
+ target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
+ list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
+ list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
+endforeach(plugin)
+
+foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
+ add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
+ list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
+endforeach(ffi_plugin)
diff --git a/windows/runner/CMakeLists.txt b/windows/runner/CMakeLists.txt
new file mode 100644
index 00000000..394917c0
--- /dev/null
+++ b/windows/runner/CMakeLists.txt
@@ -0,0 +1,40 @@
+cmake_minimum_required(VERSION 3.14)
+project(runner LANGUAGES CXX)
+
+# Define the application target. To change its name, change BINARY_NAME in the
+# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
+# work.
+#
+# Any new source files that you add to the application should be added here.
+add_executable(${BINARY_NAME} WIN32
+ "flutter_window.cpp"
+ "main.cpp"
+ "utils.cpp"
+ "win32_window.cpp"
+ "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
+ "Runner.rc"
+ "runner.exe.manifest"
+)
+
+# Apply the standard set of build settings. This can be removed for applications
+# that need different build settings.
+apply_standard_settings(${BINARY_NAME})
+
+# Add preprocessor definitions for the build version.
+target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
+target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
+target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
+target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
+target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
+
+# Disable Windows macros that collide with C++ standard library functions.
+target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
+
+# Add dependency libraries and include directories. Add any application-specific
+# dependencies here.
+target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
+target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
+target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
+
+# Run the Flutter tool portions of the build. This must not be removed.
+add_dependencies(${BINARY_NAME} flutter_assemble)
diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc
new file mode 100644
index 00000000..d842c9c7
--- /dev/null
+++ b/windows/runner/Runner.rc
@@ -0,0 +1,121 @@
+// Microsoft Visual C++ generated resource script.
+//
+#pragma code_page(65001)
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (United States) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""winres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_APP_ICON ICON "resources\\app_icon.ico"
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
+#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
+#else
+#define VERSION_AS_NUMBER 1,0,0,0
+#endif
+
+#if defined(FLUTTER_VERSION)
+#define VERSION_AS_STRING FLUTTER_VERSION
+#else
+#define VERSION_AS_STRING "1.0.0"
+#endif
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION VERSION_AS_NUMBER
+ PRODUCTVERSION VERSION_AS_NUMBER
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+#ifdef _DEBUG
+ FILEFLAGS VS_FF_DEBUG
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_APP
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904e4"
+ BEGIN
+ VALUE "CompanyName", "Barnabas" "\0"
+ VALUE "FileDescription", "Absorb" "\0"
+ VALUE "FileVersion", VERSION_AS_STRING "\0"
+ VALUE "InternalName", "absorb" "\0"
+ VALUE "LegalCopyright", "Copyright (C) 2026 Barnabas" "\0"
+ VALUE "OriginalFilename", "absorb.exe" "\0"
+ VALUE "ProductName", "Absorb" "\0"
+ VALUE "ProductVersion", VERSION_AS_STRING "\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1252
+ END
+END
+
+#endif // English (United States) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
diff --git a/windows/runner/flutter_window.cpp b/windows/runner/flutter_window.cpp
new file mode 100644
index 00000000..955ee303
--- /dev/null
+++ b/windows/runner/flutter_window.cpp
@@ -0,0 +1,71 @@
+#include "flutter_window.h"
+
+#include <optional>
+
+#include "flutter/generated_plugin_registrant.h"
+
+FlutterWindow::FlutterWindow(const flutter::DartProject& project)
+ : project_(project) {}
+
+FlutterWindow::~FlutterWindow() {}
+
+bool FlutterWindow::OnCreate() {
+ if (!Win32Window::OnCreate()) {
+ return false;
+ }
+
+ RECT frame = GetClientArea();
+
+ // The size here must match the window dimensions to avoid unnecessary surface
+ // creation / destruction in the startup path.
+ flutter_controller_ = std::make_unique<flutter::FlutterViewController>(
+ frame.right - frame.left, frame.bottom - frame.top, project_);
+ // Ensure that basic setup of the controller was successful.
+ if (!flutter_controller_->engine() || !flutter_controller_->view()) {
+ return false;
+ }
+ RegisterPlugins(flutter_controller_->engine());
+ SetChildContent(flutter_controller_->view()->GetNativeWindow());
+
+ flutter_controller_->engine()->SetNextFrameCallback([&]() {
+ this->Show();
+ });
+
+ // Flutter can complete the first frame before the "show window" callback is
+ // registered. The following call ensures a frame is pending to ensure the
+ // window is shown. It is a no-op if the first frame hasn't completed yet.
+ flutter_controller_->ForceRedraw();
+
+ return true;
+}
+
+void FlutterWindow::OnDestroy() {
+ if (flutter_controller_) {
+ flutter_controller_ = nullptr;
+ }
+
+ Win32Window::OnDestroy();
+}
+
+LRESULT
+FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
+ WPARAM const wparam,
+ LPARAM const lparam) noexcept {
+ // Give Flutter, including plugins, an opportunity to handle window messages.
+ if (flutter_controller_) {
+ std::optional<LRESULT> result =
+ flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
+ lparam);
+ if (result) {
+ return *result;
+ }
+ }
+
+ switch (message) {
+ case WM_FONTCHANGE:
+ flutter_controller_->engine()->ReloadSystemFonts();
+ break;
+ }
+
+ return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
+}
diff --git a/windows/runner/flutter_window.h b/windows/runner/flutter_window.h
new file mode 100644
index 00000000..6da0652f
--- /dev/null
+++ b/windows/runner/flutter_window.h
@@ -0,0 +1,33 @@
+#ifndef RUNNER_FLUTTER_WINDOW_H_
+#define RUNNER_FLUTTER_WINDOW_H_
+
+#include <flutter/dart_project.h>
+#include <flutter/flutter_view_controller.h>
+
+#include <memory>
+
+#include "win32_window.h"
+
+// A window that does nothing but host a Flutter view.
+class FlutterWindow : public Win32Window {
+ public:
+ // Creates a new FlutterWindow hosting a Flutter view running |project|.
+ explicit FlutterWindow(const flutter::DartProject& project);
+ virtual ~FlutterWindow();
+
+ protected:
+ // Win32Window:
+ bool OnCreate() override;
+ void OnDestroy() override;
+ LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
+ LPARAM const lparam) noexcept override;
+
+ private:
+ // The project to run.
+ flutter::DartProject project_;
+
+ // The Flutter instance hosted by this window.
+ std::unique_ptr<flutter::FlutterViewController> flutter_controller_;
+};
+
+#endif // RUNNER_FLUTTER_WINDOW_H_
diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp
new file mode 100644
index 00000000..ac83b3e6
--- /dev/null
+++ b/windows/runner/main.cpp
@@ -0,0 +1,43 @@
+#include <flutter/dart_project.h>
+#include <flutter/flutter_view_controller.h>
+#include <windows.h>
+
+#include "flutter_window.h"
+#include "utils.h"
+
+int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
+ _In_ wchar_t *command_line, _In_ int show_command) {
+ // Attach to console when present (e.g., 'flutter run') or create a
+ // new console when running with a debugger.
+ if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
+ CreateAndAttachConsole();
+ }
+
+ // Initialize COM, so that it is available for use in the library and/or
+ // plugins.
+ ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
+
+ flutter::DartProject project(L"data");
+
+ std::vector<std::string> command_line_arguments =
+ GetCommandLineArguments();
+
+ project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
+
+ FlutterWindow window(project);
+ Win32Window::Point origin(10, 10);
+ Win32Window::Size size(1280, 720);
+ if (!window.Create(L"Absorb", origin, size)) {
+ return EXIT_FAILURE;
+ }
+ window.SetQuitOnClose(true);
+
+ ::MSG msg;
+ while (::GetMessage(&msg, nullptr, 0, 0)) {
+ ::TranslateMessage(&msg);
+ ::DispatchMessage(&msg);
+ }
+
+ ::CoUninitialize();
+ return EXIT_SUCCESS;
+}
diff --git a/windows/runner/resource.h b/windows/runner/resource.h
new file mode 100644
index 00000000..66a65d1e
--- /dev/null
+++ b/windows/runner/resource.h
@@ -0,0 +1,16 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by Runner.rc
+//
+#define IDI_APP_ICON 101
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 102
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/windows/runner/resources/app_icon.ico b/windows/runner/resources/app_icon.ico
new file mode 100644
index 00000000..cac82e6f
Binary files /dev/null and b/windows/runner/resources/app_icon.ico differ
diff --git a/windows/runner/runner.exe.manifest b/windows/runner/runner.exe.manifest
new file mode 100644
index 00000000..153653e8
--- /dev/null
+++ b/windows/runner/runner.exe.manifest
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+ <application xmlns="urn:schemas-microsoft-com:asm.v3">
+ <windowsSettings>
+ <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
+ </windowsSettings>
+ </application>
+ <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
+ <application>
+ <!-- Windows 10 and Windows 11 -->
+ <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
+ </application>
+ </compatibility>
+</assembly>
diff --git a/windows/runner/utils.cpp b/windows/runner/utils.cpp
new file mode 100644
index 00000000..3cb71466
--- /dev/null
+++ b/windows/runner/utils.cpp
@@ -0,0 +1,69 @@
+#include "utils.h"
+
+#include <flutter_windows.h>
+#include <io.h>
+#include <stdio.h>
+#include <windows.h>
+
+#include <iostream>
+
+void CreateAndAttachConsole() {
+ if (::AllocConsole()) {
+ FILE *unused;
+ if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
+ _dup2(_fileno(stdout), 1);
+ }
+ if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
+ _dup2(_fileno(stdout), 2);
+ }
+ std::ios::sync_with_stdio();
+ FlutterDesktopResyncOutputStreams();
+ }
+}
+
+std::vector<std::string> GetCommandLineArguments() {
+ // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
+ int argc;
+ wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
+ if (argv == nullptr) {
+ return std::vector<std::string>();
+ }
+
+ std::vector<std::string> command_line_arguments;
+
+ // Skip the first argument as it's the binary name.
+ for (int i = 1; i < argc; i++) {
+ command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
+ }
+
+ ::LocalFree(argv);
+
+ return command_line_arguments;
+}
+
+std::string Utf8FromUtf16(const wchar_t* utf16_string) {
+ if (utf16_string == nullptr) {
+ return std::string();
+ }
+ // First, find the length of the string with a safe upper bound (CWE-126).
+ // UNICODE_STRING_MAX_CHARS (32767) is the maximum length of a UNICODE_STRING.
+ int input_length = static_cast<int>(wcsnlen(utf16_string, UNICODE_STRING_MAX_CHARS));
+ // Now use that bounded length to determine the required buffer size.
+ // When an explicit length is passed, WideCharToMultiByte does not include
+ // the null terminator in its returned size.
+ int target_length = ::WideCharToMultiByte(
+ CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
+ input_length, nullptr, 0, nullptr, nullptr);
+ std::string utf8_string;
+ if (target_length == 0 || static_cast<size_t>(target_length) > utf8_string.max_size()) {
+ return utf8_string;
+ }
+ utf8_string.resize(target_length);
+ int converted_length = ::WideCharToMultiByte(
+ CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
+ input_length, utf8_string.data(), target_length, nullptr, nullptr);
+ if (converted_length == 0) {
+ return std::string();
+ }
+ return utf8_string;
+}
diff --git a/windows/runner/utils.h b/windows/runner/utils.h
new file mode 100644
index 00000000..3879d547
--- /dev/null
+++ b/windows/runner/utils.h
@@ -0,0 +1,19 @@
+#ifndef RUNNER_UTILS_H_
+#define RUNNER_UTILS_H_
+
+#include <string>
+#include <vector>
+
+// Creates a console for the process, and redirects stdout and stderr to
+// it for both the runner and the Flutter library.
+void CreateAndAttachConsole();
+
+// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
+// encoded in UTF-8. Returns an empty std::string on failure.
+std::string Utf8FromUtf16(const wchar_t* utf16_string);
+
+// Gets the command line arguments passed in as a std::vector<std::string>,
+// encoded in UTF-8. Returns an empty std::vector<std::string> on failure.
+std::vector<std::string> GetCommandLineArguments();
+
+#endif // RUNNER_UTILS_H_
diff --git a/windows/runner/win32_window.cpp b/windows/runner/win32_window.cpp
new file mode 100644
index 00000000..60608d0f
--- /dev/null
+++ b/windows/runner/win32_window.cpp
@@ -0,0 +1,288 @@
+#include "win32_window.h"
+
+#include <dwmapi.h>
+#include <flutter_windows.h>
+
+#include "resource.h"
+
+namespace {
+
+/// Window attribute that enables dark mode window decorations.
+///
+/// Redefined in case the developer's machine has a Windows SDK older than
+/// version 10.0.22000.0.
+/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
+#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
+#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
+#endif
+
+constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
+
+/// Registry key for app theme preference.
+///
+/// A value of 0 indicates apps should use dark mode. A non-zero or missing
+/// value indicates apps should use light mode.
+constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
+ L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
+constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
+
+// The number of Win32Window objects that currently exist.
+static int g_active_window_count = 0;
+
+using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);
+
+// Scale helper to convert logical scaler values to physical using passed in
+// scale factor
+int Scale(int source, double scale_factor) {
+ return static_cast<int>(source * scale_factor);
+}
+
+// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module.
+// This API is only needed for PerMonitor V1 awareness mode.
+void EnableFullDpiSupportIfAvailable(HWND hwnd) {
+ HMODULE user32_module = LoadLibraryA("User32.dll");
+ if (!user32_module) {
+ return;
+ }
+ auto enable_non_client_dpi_scaling =
+ reinterpret_cast<EnableNonClientDpiScaling*>(
+ GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
+ if (enable_non_client_dpi_scaling != nullptr) {
+ enable_non_client_dpi_scaling(hwnd);
+ }
+ FreeLibrary(user32_module);
+}
+
+} // namespace
+
+// Manages the Win32Window's window class registration.
+class WindowClassRegistrar {
+ public:
+ ~WindowClassRegistrar() = default;
+
+ // Returns the singleton registrar instance.
+ static WindowClassRegistrar* GetInstance() {
+ if (!instance_) {
+ instance_ = new WindowClassRegistrar();
+ }
+ return instance_;
+ }
+
+ // Returns the name of the window class, registering the class if it hasn't
+ // previously been registered.
+ const wchar_t* GetWindowClass();
+
+ // Unregisters the window class. Should only be called if there are no
+ // instances of the window.
+ void UnregisterWindowClass();
+
+ private:
+ WindowClassRegistrar() = default;
+
+ static WindowClassRegistrar* instance_;
+
+ bool class_registered_ = false;
+};
+
+WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
+
+const wchar_t* WindowClassRegistrar::GetWindowClass() {
+ if (!class_registered_) {
+ WNDCLASS window_class{};
+ window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
+ window_class.lpszClassName = kWindowClassName;
+ window_class.style = CS_HREDRAW | CS_VREDRAW;
+ window_class.cbClsExtra = 0;
+ window_class.cbWndExtra = 0;
+ window_class.hInstance = GetModuleHandle(nullptr);
+ window_class.hIcon =
+ LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
+ window_class.hbrBackground = 0;
+ window_class.lpszMenuName = nullptr;
+ window_class.lpfnWndProc = Win32Window::WndProc;
+ RegisterClass(&window_class);
+ class_registered_ = true;
+ }
+ return kWindowClassName;
+}
+
+void WindowClassRegistrar::UnregisterWindowClass() {
+ UnregisterClass(kWindowClassName, nullptr);
+ class_registered_ = false;
+}
+
+Win32Window::Win32Window() {
+ ++g_active_window_count;
+}
+
+Win32Window::~Win32Window() {
+ --g_active_window_count;
+ Destroy();
+}
+
+bool Win32Window::Create(const std::wstring& title,
+ const Point& origin,
+ const Size& size) {
+ Destroy();
+
+ const wchar_t* window_class =
+ WindowClassRegistrar::GetInstance()->GetWindowClass();
+
+ const POINT target_point = {static_cast<LONG>(origin.x),
+ static_cast<LONG>(origin.y)};
+ HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
+ UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
+ double scale_factor = dpi / 96.0;
+
+ HWND window = CreateWindow(
+ window_class, title.c_str(), WS_OVERLAPPEDWINDOW,
+ Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
+ Scale(size.width, scale_factor), Scale(size.height, scale_factor),
+ nullptr, nullptr, GetModuleHandle(nullptr), this);
+
+ if (!window) {
+ return false;
+ }
+
+ UpdateTheme(window);
+
+ return OnCreate();
+}
+
+bool Win32Window::Show() {
+ return ShowWindow(window_handle_, SW_SHOWNORMAL);
+}
+
+// static
+LRESULT CALLBACK Win32Window::WndProc(HWND const window,
+ UINT const message,
+ WPARAM const wparam,
+ LPARAM const lparam) noexcept {
+ if (message == WM_NCCREATE) {
+ auto window_struct = reinterpret_cast<CREATESTRUCT*>(lparam);
+ SetWindowLongPtr(window, GWLP_USERDATA,
+ reinterpret_cast<LONG_PTR>(window_struct->lpCreateParams));
+
+ auto that = static_cast<Win32Window*>(window_struct->lpCreateParams);
+ EnableFullDpiSupportIfAvailable(window);
+ that->window_handle_ = window;
+ } else if (Win32Window* that = GetThisFromHandle(window)) {
+ return that->MessageHandler(window, message, wparam, lparam);
+ }
+
+ return DefWindowProc(window, message, wparam, lparam);
+}
+
+LRESULT
+Win32Window::MessageHandler(HWND hwnd,
+ UINT const message,
+ WPARAM const wparam,
+ LPARAM const lparam) noexcept {
+ switch (message) {
+ case WM_DESTROY:
+ window_handle_ = nullptr;
+ Destroy();
+ if (quit_on_close_) {
+ PostQuitMessage(0);
+ }
+ return 0;
+
+ case WM_DPICHANGED: {
+ auto newRectSize = reinterpret_cast<RECT*>(lparam);
+ LONG newWidth = newRectSize->right - newRectSize->left;
+ LONG newHeight = newRectSize->bottom - newRectSize->top;
+
+ SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth,
+ newHeight, SWP_NOZORDER | SWP_NOACTIVATE);
+
+ return 0;
+ }
+ case WM_SIZE: {
+ RECT rect = GetClientArea();
+ if (child_content_ != nullptr) {
+ // Size and position the child window.
+ MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left,
+ rect.bottom - rect.top, TRUE);
+ }
+ return 0;
+ }
+
+ case WM_ACTIVATE:
+ if (child_content_ != nullptr) {
+ SetFocus(child_content_);
+ }
+ return 0;
+
+ case WM_DWMCOLORIZATIONCOLORCHANGED:
+ UpdateTheme(hwnd);
+ return 0;
+ }
+
+ return DefWindowProc(window_handle_, message, wparam, lparam);
+}
+
+void Win32Window::Destroy() {
+ OnDestroy();
+
+ if (window_handle_) {
+ DestroyWindow(window_handle_);
+ window_handle_ = nullptr;
+ }
+ if (g_active_window_count == 0) {
+ WindowClassRegistrar::GetInstance()->UnregisterWindowClass();
+ }
+}
+
+Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
+ return reinterpret_cast<Win32Window*>(
+ GetWindowLongPtr(window, GWLP_USERDATA));
+}
+
+void Win32Window::SetChildContent(HWND content) {
+ child_content_ = content;
+ SetParent(content, window_handle_);
+ RECT frame = GetClientArea();
+
+ MoveWindow(content, frame.left, frame.top, frame.right - frame.left,
+ frame.bottom - frame.top, true);
+
+ SetFocus(child_content_);
+}
+
+RECT Win32Window::GetClientArea() {
+ RECT frame;
+ GetClientRect(window_handle_, &frame);
+ return frame;
+}
+
+HWND Win32Window::GetHandle() {
+ return window_handle_;
+}
+
+void Win32Window::SetQuitOnClose(bool quit_on_close) {
+ quit_on_close_ = quit_on_close;
+}
+
+bool Win32Window::OnCreate() {
+ // No-op; provided for subclasses.
+ return true;
+}
+
+void Win32Window::OnDestroy() {
+ // No-op; provided for subclasses.
+}
+
+void Win32Window::UpdateTheme(HWND const window) {
+ DWORD light_mode;
+ DWORD light_mode_size = sizeof(light_mode);
+ LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
+ kGetPreferredBrightnessRegValue,
+ RRF_RT_REG_DWORD, nullptr, &light_mode,
+ &light_mode_size);
+
+ if (result == ERROR_SUCCESS) {
+ BOOL enable_dark_mode = light_mode == 0;
+ DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE,
+ &enable_dark_mode, sizeof(enable_dark_mode));
+ }
+}
diff --git a/windows/runner/win32_window.h b/windows/runner/win32_window.h
new file mode 100644
index 00000000..e901dde6
--- /dev/null
+++ b/windows/runner/win32_window.h
@@ -0,0 +1,102 @@
+#ifndef RUNNER_WIN32_WINDOW_H_
+#define RUNNER_WIN32_WINDOW_H_
+
+#include <windows.h>
+
+#include <functional>
+#include <memory>
+#include <string>
+
+// A class abstraction for a high DPI-aware Win32 Window. Intended to be
+// inherited from by classes that wish to specialize with custom
+// rendering and input handling
+class Win32Window {
+ public:
+ struct Point {
+ unsigned int x;
+ unsigned int y;
+ Point(unsigned int x, unsigned int y) : x(x), y(y) {}
+ };
+
+ struct Size {
+ unsigned int width;
+ unsigned int height;
+ Size(unsigned int width, unsigned int height)
+ : width(width), height(height) {}
+ };
+
+ Win32Window();
+ virtual ~Win32Window();
+
+ // Creates a win32 window with |title| that is positioned and sized using
+ // |origin| and |size|. New windows are created on the default monitor. Window
+ // sizes are specified to the OS in physical pixels, hence to ensure a
+ // consistent size this function will scale the inputted width and height as
+ // as appropriate for the default monitor. The window is invisible until
+ // |Show| is called. Returns true if the window was created successfully.
+ bool Create(const std::wstring& title, const Point& origin, const Size& size);
+
+ // Show the current window. Returns true if the window was successfully shown.
+ bool Show();
+
+ // Release OS resources associated with window.
+ void Destroy();
+
+ // Inserts |content| into the window tree.
+ void SetChildContent(HWND content);
+
+ // Returns the backing Window handle to enable clients to set icon and other
+ // window properties. Returns nullptr if the window has been destroyed.
+ HWND GetHandle();
+
+ // If true, closing this window will quit the application.
+ void SetQuitOnClose(bool quit_on_close);
+
+ // Return a RECT representing the bounds of the current client area.
+ RECT GetClientArea();
+
+ protected:
+ // Processes and route salient window messages for mouse handling,
+ // size change and DPI. Delegates handling of these to member overloads that
+ // inheriting classes can handle.
+ virtual LRESULT MessageHandler(HWND window,
+ UINT const message,
+ WPARAM const wparam,
+ LPARAM const lparam) noexcept;
+
+ // Called when CreateAndShow is called, allowing subclass window-related
+ // setup. Subclasses should return false if setup fails.
+ virtual bool OnCreate();
+
+ // Called when Destroy is called.
+ virtual void OnDestroy();
+
+ private:
+ friend class WindowClassRegistrar;
+
+ // OS callback called by message pump. Handles the WM_NCCREATE message which
+ // is passed when the non-client area is being created and enables automatic
+ // non-client DPI scaling so that the non-client area automatically
+ // responds to changes in DPI. All other messages are handled by
+ // MessageHandler.
+ static LRESULT CALLBACK WndProc(HWND const window,
+ UINT const message,
+ WPARAM const wparam,
+ LPARAM const lparam) noexcept;
+
+ // Retrieves a class instance pointer for |window|
+ static Win32Window* GetThisFromHandle(HWND const window) noexcept;
+
+ // Update the window frame's theme to match the system theme.
+ static void UpdateTheme(HWND const window);
+
+ bool quit_on_close_ = false;
+
+ // window handle for top level window.
+ HWND window_handle_ = nullptr;
+
+ // window handle for hosted content.
+ HWND child_content_ = nullptr;
+};
+
+#endif // RUNNER_WIN32_WINDOW_H_