Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
solved potrait for mobile only
Browse files Browse the repository at this point in the history
  • Loading branch information
ge59dil committed Dec 11, 2023
1 parent facf090 commit bae843e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,32 @@ class App extends ConsumerWidget {
theme: appTheme,
navigatorKey: navigatorKey,
scaffoldMessengerKey: scaffoldMessengerKey,
builder: (context, child) => TouchIndicator(child: child!),
builder: (context, child) {
_setPreferredOrientations(context);
return TouchIndicator(child: child!);
},
home: homeScreen,
routes: _buildRoutes(),
);
}

void _setPreferredOrientations(BuildContext context) {
if (MediaQuery.of(context).size.shortestSide < 600) {
// This is likely a phone
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
} else {
// This is likely a tablet
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
}
}
Widget _getHomeScreen(User? user) {
return user == null ? const WelcomeScreen() : const CourseOverview();
}
Expand Down

0 comments on commit bae843e

Please sign in to comment.