try fix platformview overlap

This commit is contained in:
Fabian Freund
2026-02-02 23:33:21 +01:00
parent 4765381ada
commit 142c260fee
6 changed files with 260 additions and 56 deletions
+44
View File
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2024-2025 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'dart:io';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'device_info.g.dart';
@Riverpod(keepAlive: true)
class AndroidDeviceInfo extends _$AndroidDeviceInfo {
@override
Future<AndroidDeviceInfoData?> build() async {
if (!Platform.isAndroid) return null;
final deviceInfo = DeviceInfoPlugin();
final androidInfo = await deviceInfo.androidInfo;
return AndroidDeviceInfoData(sdkInt: androidInfo.version.sdkInt);
}
}
class AndroidDeviceInfoData {
final int sdkInt;
const AndroidDeviceInfoData({required this.sdkInt});
}
+60
View File
@@ -0,0 +1,60 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'device_info.dart';
// **************************************************************************
// RiverpodGenerator
// **************************************************************************
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint, type=warning
@ProviderFor(AndroidDeviceInfo)
final androidDeviceInfoProvider = AndroidDeviceInfoProvider._();
final class AndroidDeviceInfoProvider
extends $AsyncNotifierProvider<AndroidDeviceInfo, AndroidDeviceInfoData?> {
AndroidDeviceInfoProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'androidDeviceInfoProvider',
isAutoDispose: false,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$androidDeviceInfoHash();
@$internal
@override
AndroidDeviceInfo create() => AndroidDeviceInfo();
}
String _$androidDeviceInfoHash() => r'05c6cc63a6ee34f137aef538d65e8ab94b9cca89';
abstract class _$AndroidDeviceInfo
extends $AsyncNotifier<AndroidDeviceInfoData?> {
FutureOr<AndroidDeviceInfoData?> build();
@$mustCallSuper
@override
void runBuild() {
final ref =
this.ref
as $Ref<AsyncValue<AndroidDeviceInfoData?>, AndroidDeviceInfoData?>;
final element =
ref.element
as $ClassProviderElement<
AnyNotifier<
AsyncValue<AndroidDeviceInfoData?>,
AndroidDeviceInfoData?
>,
AsyncValue<AndroidDeviceInfoData?>,
Object?,
Object?
>;
element.handleCreate(ref, build);
}
}
+23
View File
@@ -52,3 +52,26 @@ Future<GoRouter> router(Ref ref) async {
initialLocation: initialLocation ?? const BrowserRoute().location,
);
}
@Riverpod(keepAlive: true)
class CurrentTopRoute extends _$CurrentTopRoute {
@override
RouteBase? build() {
final router = ref.watch(routerProvider).value;
if (router == null) return null;
void update() {
final config = router.routerDelegate.currentConfiguration;
final match = config.last;
state = match.route;
}
router.routerDelegate.addListener(update);
ref.onDispose(() => router.routerDelegate.removeListener(update));
update();
return state;
}
}
+52
View File
@@ -42,3 +42,55 @@ final class RouterProvider
}
String _$routerHash() => r'cbaa7e982114942303574f9573f4a75b79955583';
@ProviderFor(CurrentTopRoute)
final currentTopRouteProvider = CurrentTopRouteProvider._();
final class CurrentTopRouteProvider
extends $NotifierProvider<CurrentTopRoute, RouteBase?> {
CurrentTopRouteProvider._()
: super(
from: null,
argument: null,
retry: null,
name: r'currentTopRouteProvider',
isAutoDispose: false,
dependencies: null,
$allTransitiveDependencies: null,
);
@override
String debugGetCreateSourceHash() => _$currentTopRouteHash();
@$internal
@override
CurrentTopRoute create() => CurrentTopRoute();
/// {@macro riverpod.override_with_value}
Override overrideWithValue(RouteBase? value) {
return $ProviderOverride(
origin: this,
providerOverride: $SyncValueProvider<RouteBase?>(value),
);
}
}
String _$currentTopRouteHash() => r'71a66713adafb5f64359eec88a69344167aae64f';
abstract class _$CurrentTopRoute extends $Notifier<RouteBase?> {
RouteBase? build();
@$mustCallSuper
@override
void runBuild() {
final ref = this.ref as $Ref<RouteBase?, RouteBase?>;
final element =
ref.element
as $ClassProviderElement<
AnyNotifier<RouteBase?, RouteBase?>,
RouteBase?,
Object?,
Object?
>;
element.handleCreate(ref, build);
}
}