Commit 34923506 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Remove Placeholder. It has no clients. (#9563)

parent 55f33468
// 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 'basic.dart';
import 'framework.dart';
/// A widget whose child can be mutated.
class Placeholder extends StatefulWidget {
/// Creates a widget whose child can be mutated.
const Placeholder({ Key key }) : super(key: key);
@override
PlaceholderState createState() => new PlaceholderState();
}
/// State for a [Placeholder] widget.
///
/// Useful for setting the child currently displayed by this placeholder widget.
class PlaceholderState extends State<Placeholder> {
/// The child that this widget builds.
///
/// Mutating this field will cause this widget to rebuild with the new child.
Widget get child => _child;
Widget _child;
set child(Widget value) {
if (_child == value)
return;
setState(() {
_child = value;
});
}
@override
Widget build(BuildContext context) {
if (_child != null)
return child;
return const SizedBox(width: 0.0, height: 0.0);
}
}
......@@ -43,7 +43,6 @@ export 'src/widgets/page_storage.dart';
export 'src/widgets/page_view.dart';
export 'src/widgets/pages.dart';
export 'src/widgets/performance_overlay.dart';
export 'src/widgets/placeholder.dart';
export 'src/widgets/preferred_size.dart';
export 'src/widgets/primary_scroll_controller.dart';
export 'src/widgets/raw_keyboard_listener.dart';
......
......@@ -11,6 +11,11 @@ class TestState extends State<StatefulWidget> {
Widget build(BuildContext context) => null;
}
// TODO(ianh): Remove this once we add the real Placeholder widget
class Placeholder extends Container {
Placeholder({ Key key }) : super(key: key);
}
void main() {
testWidgets('UniqueKey control test', (WidgetTester tester) async {
final Key key = new UniqueKey();
......@@ -440,7 +445,7 @@ void main() {
final GlobalKey key = new GlobalKey();
await tester.pumpWidget(new Container(key: key));
expect(log, isEmpty);
await tester.pumpWidget(const Placeholder());
await tester.pumpWidget(new Placeholder());
debugPrint = oldCallback;
debugPrintGlobalKeyedWidgetLifecycle = false;
......
// Copyright 2017 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 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
void main() {
testWidgets('Placeholder control test', (WidgetTester tester) async {
final GlobalKey<PlaceholderState> key = new GlobalKey<PlaceholderState>();
await tester.pumpWidget(new Placeholder(key: key));
key.currentState.child = const Text('target');
expect(find.text('target'), findsNothing);
await tester.pump();
expect(find.text('target'), findsOneWidget);
});
}
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