-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:[TM-42460] Reset resetPreferredOrientations after camera dispose
- Loading branch information
1 parent
f0b23a9
commit e307368
Showing
3 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'dart:ui'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
/// Controls orientations of the application interface | ||
class ZdsSystemChrome { | ||
static List<DeviceOrientation> _orientations = [ | ||
DeviceOrientation.portraitUp, | ||
DeviceOrientation.portraitDown, | ||
DeviceOrientation.landscapeLeft, | ||
DeviceOrientation.landscapeRight, | ||
]; | ||
|
||
/// Get the set of orientations the application interface can | ||
/// be displayed in. | ||
static List<DeviceOrientation> get appOrientations => _orientations; | ||
|
||
/// Specifies the set of orientations the application interface can | ||
/// be displayed in. | ||
/// | ||
/// The `orientation` argument is a list of [DeviceOrientation] enum values. | ||
static Future<void> setPreferredOrientations(List<DeviceOrientation>? orientations) async { | ||
final platformMediaQuery = MediaQueryData.fromView(PlatformDispatcher.instance.views.first); | ||
if (orientations == null || orientations.isEmpty) { | ||
if (platformMediaQuery.size.shortestSide < 600) { | ||
_orientations = [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]; | ||
} else { | ||
_orientations = [ | ||
DeviceOrientation.portraitUp, | ||
DeviceOrientation.portraitDown, | ||
DeviceOrientation.landscapeLeft, | ||
DeviceOrientation.landscapeRight, | ||
]; | ||
} | ||
} else { | ||
_orientations = orientations; | ||
} | ||
|
||
await resetAppOrientations(); | ||
} | ||
|
||
/// Set the set of orientations the application interface can | ||
/// be displayed in. | ||
static Future<void> resetAppOrientations() async { | ||
await SystemChrome.setPreferredOrientations(appOrientations); | ||
} | ||
} |