Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:dual_screen/dual_screen.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/foundation.dart';
Expand Down Expand Up @@ -69,6 +70,7 @@ class GalleryApp extends StatelessWidget {
child: Builder(
builder: (context) {
final options = GalleryOptions.of(context);
final hasHinge = MediaQuery.of(context).hinge?.bounds != null;
return MaterialApp(
restorationScopeId: 'rootGallery',
title: 'Flutter Gallery',
Expand All @@ -91,7 +93,8 @@ class GalleryApp extends StatelessWidget {
deviceLocale = locales?.first;
return basicLocaleListResolution(locales, supportedLocales);
},
onGenerateRoute: RouteConfiguration.onGenerateRoute,
onGenerateRoute: (settings) =>
RouteConfiguration.onGenerateRoute(settings, hasHinge),
);
},
),
Expand Down
7 changes: 5 additions & 2 deletions lib/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ class RouteConfiguration {
/// route. Set it on the [MaterialApp.onGenerateRoute] or
/// [WidgetsApp.onGenerateRoute] to make use of the [paths] for route
/// matching.
static Route<dynamic>? onGenerateRoute(RouteSettings settings) {
static Route<dynamic>? onGenerateRoute(
RouteSettings settings,
bool hasHinge,
) {
for (final path in paths) {
final regExpPattern = RegExp(path.pattern);
if (regExpPattern.hasMatch(settings.name!)) {
Expand All @@ -130,7 +133,7 @@ class RouteConfiguration {
settings: settings,
);
}
if (path.openInSecondScreen) {
if (path.openInSecondScreen && hasHinge) {
return TwoPanePageRoute<void>(
builder: (context) => path.builder(context, match),
settings: settings,
Expand Down