mirror of
https://github.com/flutter/flutter
synced 2024-08-27 20:10:11 +00:00
Avoid scheduling a forced frame when there is no child to the renderView (#102556)
This commit is contained in:
parent
bc7d3bbc65
commit
34d84209cf
|
@ -235,10 +235,13 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
|
|||
///
|
||||
/// See [dart:ui.PlatformDispatcher.onMetricsChanged].
|
||||
@protected
|
||||
@visibleForTesting
|
||||
void handleMetricsChanged() {
|
||||
assert(renderView != null);
|
||||
renderView.configuration = createViewConfiguration();
|
||||
scheduleForcedFrame();
|
||||
if (renderView.child != null) {
|
||||
scheduleForcedFrame();
|
||||
}
|
||||
}
|
||||
|
||||
/// Called when the platform text scale factor changes.
|
||||
|
|
22
packages/flutter/test/rendering/binding_test.dart
Normal file
22
packages/flutter/test/rendering/binding_test.dart
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
test('handleMetricsChanged does not scheduleForcedFrame unless there is a child to the renderView', () async {
|
||||
expect(SchedulerBinding.instance.hasScheduledFrame, false);
|
||||
RendererBinding.instance.handleMetricsChanged();
|
||||
expect(SchedulerBinding.instance.hasScheduledFrame, false);
|
||||
|
||||
RendererBinding.instance.renderView.child = RenderLimitedBox();
|
||||
RendererBinding.instance.handleMetricsChanged();
|
||||
expect(SchedulerBinding.instance.hasScheduledFrame, true);
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue