File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 1+ import 'package:flutter/services.dart' ;
2+
3+ extension OrientationExtension on SystemChrome {
4+ static Future <void > lockVertical () async =>
5+ SystemChrome .setPreferredOrientations ([
6+ DeviceOrientation .portraitUp,
7+ DeviceOrientation .portraitDown,
8+ ]);
9+
10+ static Future <void > lockHorizontal () async =>
11+ SystemChrome .setPreferredOrientations (
12+ [DeviceOrientation .landscapeLeft, DeviceOrientation .landscapeRight]);
13+
14+ static Future <void > unlock () async => SystemChrome .setPreferredOrientations ([
15+ DeviceOrientation .portraitUp,
16+ DeviceOrientation .portraitDown,
17+ DeviceOrientation .landscapeLeft,
18+ DeviceOrientation .landscapeRight
19+ ]);
20+ }
Original file line number Diff line number Diff line change @@ -10,17 +10,17 @@ import 'package:{{project_name}}/core/arch/bloc/app_bloc_observer.dart';
1010import 'package:{{project_name}}/app/app.dart' ;
1111import 'package:{{project_name}}/app/app_initialization.dart' ;
1212import 'package:{{project_name}}/core/di/services.dart' ;
13+ import 'package:{{project_name}}/core/extension/orientation_extension.dart' ;
1314
1415Future <void > main{{#flavorizr}}App {{/ flavorizr}}() async {
1516 unawaited (
1617 runZonedGuarded (
1718 () async {
1819 WidgetsFlutterBinding .ensureInitialized ();
1920 await Initialization .I .initApp ();
20- await SystemChrome .setPreferredOrientations ([
21- DeviceOrientation .portraitUp,
22- DeviceOrientation .portraitDown,
23- ]);
21+
22+ await OrientationExtension .lockVertical ();
23+
2424 Bloc .observer = AppBlocObserver ();
2525 final isAllowedToUseApp = await environmentService ().initialize ();
2626 if (isAllowedToUseApp) {
You can’t perform that action at this time.
0 commit comments