Skip to content

Commit b84a258

Browse files
authored
Merge pull request #16 from Onix-Systems/feat/orientation_extension
Feat/orientation extension
2 parents f7e5c1b + f07e714 commit b84a258

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
}

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/main.gen.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ import 'package:{{project_name}}/core/arch/bloc/app_bloc_observer.dart';
1010
import 'package:{{project_name}}/app/app.dart';
1111
import 'package:{{project_name}}/app/app_initialization.dart';
1212
import 'package:{{project_name}}/core/di/services.dart';
13+
import 'package:{{project_name}}/core/extension/orientation_extension.dart';
1314

1415
Future<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) {

0 commit comments

Comments
 (0)