@@ -4,8 +4,9 @@
|
||||
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
import 'media_query.dart';
|
||||
import 'debug.dart';
|
||||
import 'framework.dart';
|
||||
import 'media_query.dart';
|
||||
|
||||
export 'package:flutter/rendering.dart' show ChildViewConnection;
|
||||
|
||||
@@ -16,7 +17,7 @@ class ChildView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
assert(MediaQuery.of(context) != null);
|
||||
assert(debugCheckHasMediaQuery(context));
|
||||
return new _ChildViewWidget(
|
||||
child: child,
|
||||
scale: MediaQuery.of(context).devicePixelRatio
|
||||
|
||||
24
packages/flutter/lib/src/widgets/debug.dart
Normal file
24
packages/flutter/lib/src/widgets/debug.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
// Copyright 2015 The Chromium 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 'framework.dart';
|
||||
import 'media_query.dart';
|
||||
|
||||
bool debugCheckHasMediaQuery(BuildContext context) {
|
||||
assert(() {
|
||||
if (MediaQuery.of(context) == null) {
|
||||
Element element = context;
|
||||
throw new FlutterError(
|
||||
'No MediaQuery widget found.\n'
|
||||
'${element.widget.runtimeType} widgets require a MediaQuery widget ancestor.\n'
|
||||
'The specific widget that could not find a MediaQuery ancestor was:\n'
|
||||
' ${element.widget}'
|
||||
'The ownership chain for the affected widget is:\n'
|
||||
' ${element.debugGetOwnershipChain(10)}'
|
||||
);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
@@ -12,6 +12,7 @@ export 'src/widgets/banner.dart';
|
||||
export 'src/widgets/basic.dart';
|
||||
export 'src/widgets/binding.dart';
|
||||
export 'src/widgets/child_view.dart';
|
||||
export 'src/widgets/debug.dart';
|
||||
export 'src/widgets/dismissable.dart';
|
||||
export 'src/widgets/drag_target.dart';
|
||||
export 'src/widgets/editable.dart';
|
||||
|
||||
Reference in New Issue
Block a user