Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Disabling switching router layouts after init #191

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lib/util/adaptive_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class AdaptiveLayoutBuilder extends ConsumerStatefulWidget {
class _AdaptiveLayoutBuilderState extends ConsumerState<AdaptiveLayoutBuilder> {
late LayoutState layout = widget.fallBack;
late ScreenLayout size = ScreenLayout.single;
late AutoRouter router = AutoRouter(layout: size, ref: ref);
AutoRouter? router;
late TargetPlatform currentPlatform = defaultTargetPlatform;
late ScrollController controller = ScrollController();

Expand Down Expand Up @@ -177,10 +177,7 @@ class _AdaptiveLayoutBuilderState extends ConsumerState<AdaptiveLayoutBuilder> {
} else {
newSize = ScreenLayout.dual;
}
if (size != newSize) {
size = newSize;
router = AutoRouter(layout: size, ref: ref);
}
size = newSize;
}

@override
Expand All @@ -197,7 +194,7 @@ class _AdaptiveLayoutBuilderState extends ConsumerState<AdaptiveLayoutBuilder> {
inputDevice: (isDesktop || kIsWeb) ? InputDevice.pointer : InputDevice.touch,
platform: currentPlatform,
isDesktop: isDesktop,
router: router,
router: router ??= AutoRouter(layout: size, ref: ref),
posterDefaults: switch (layout) {
LayoutState.phone => const PosterDefaults(size: 300, ratio: 0.55),
LayoutState.tablet => const PosterDefaults(size: 350, ratio: 0.55),
Expand Down
Loading