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 {
/// }
///
/// class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
/// ui.Display? _display;
/// ui.FlutterView? _view;
/// static const double kOrientationLockBreakpoint = 600;
///
/// @override
......@@ -400,19 +400,19 @@ abstract final class SystemChrome {
/// @override
/// void didChangeDependencies() {
/// super.didChangeDependencies();
/// _display = View.maybeOf(context)?.display;
/// _view = View.maybeOf(context);
/// }
///
/// @override
/// void dispose() {
/// WidgetsBinding.instance.removeObserver(this);
/// _display = null;
/// _view = null;
/// super.dispose();
/// }
///
/// @override
/// void didChangeMetrics() {
/// final ui.Display? display = _display;
/// final ui.Display? display = _view?.display;
/// if (display == null) {
/// 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