Unverified Commit f489256f authored by Dan Field's avatar Dan Field Committed by GitHub

Fix bug in setPreferredOrientations example (#133503)

The `ui.Display` is a simple data class (like `MediaQueryData`), and does not get updated when the display size changes.  The provided sample code does not work as intended, but the update does.
parent 6dae2698
...@@ -388,7 +388,7 @@ abstract final class SystemChrome { ...@@ -388,7 +388,7 @@ abstract final class SystemChrome {
/// } /// }
/// ///
/// class _MyAppState extends State<MyApp> with WidgetsBindingObserver { /// class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
/// ui.Display? _display; /// ui.FlutterView? _view;
/// static const double kOrientationLockBreakpoint = 600; /// static const double kOrientationLockBreakpoint = 600;
/// ///
/// @override /// @override
...@@ -400,19 +400,19 @@ abstract final class SystemChrome { ...@@ -400,19 +400,19 @@ abstract final class SystemChrome {
/// @override /// @override
/// void didChangeDependencies() { /// void didChangeDependencies() {
/// super.didChangeDependencies(); /// super.didChangeDependencies();
/// _display = View.maybeOf(context)?.display; /// _view = View.maybeOf(context);
/// } /// }
/// ///
/// @override /// @override
/// void dispose() { /// void dispose() {
/// WidgetsBinding.instance.removeObserver(this); /// WidgetsBinding.instance.removeObserver(this);
/// _display = null; /// _view = null;
/// super.dispose(); /// super.dispose();
/// } /// }
/// ///
/// @override /// @override
/// void didChangeMetrics() { /// void didChangeMetrics() {
/// final ui.Display? display = _display; /// final ui.Display? display = _view?.display;
/// if (display == null) { /// if (display == null) {
/// return; /// return;
/// } /// }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment