From 3492350653b188bfd800e1c6fed47d960edc71a2 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Mon, 24 Apr 2017 12:40:27 -0700 Subject: [PATCH] Remove Placeholder. It has no clients. (#9563) --- .../flutter/lib/src/widgets/placeholder.dart | 40 ------------------- packages/flutter/lib/widgets.dart | 1 - .../flutter/test/widgets/framework_test.dart | 7 +++- .../test/widgets/placeholder_test.dart | 22 ---------- 4 files changed, 6 insertions(+), 64 deletions(-) delete mode 100644 packages/flutter/lib/src/widgets/placeholder.dart delete mode 100644 packages/flutter/test/widgets/placeholder_test.dart diff --git a/packages/flutter/lib/src/widgets/placeholder.dart b/packages/flutter/lib/src/widgets/placeholder.dart deleted file mode 100644 index 6f6bf8a5ee..0000000000 --- a/packages/flutter/lib/src/widgets/placeholder.dart +++ /dev/null @@ -1,40 +0,0 @@ -// 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 { - /// 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); - } -} diff --git a/packages/flutter/lib/widgets.dart b/packages/flutter/lib/widgets.dart index 0df4bb439e..80700ce7e6 100644 --- a/packages/flutter/lib/widgets.dart +++ b/packages/flutter/lib/widgets.dart @@ -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'; diff --git a/packages/flutter/test/widgets/framework_test.dart b/packages/flutter/test/widgets/framework_test.dart index a1d7d7d117..0dc2007f9b 100644 --- a/packages/flutter/test/widgets/framework_test.dart +++ b/packages/flutter/test/widgets/framework_test.dart @@ -11,6 +11,11 @@ class TestState extends State { 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; diff --git a/packages/flutter/test/widgets/placeholder_test.dart b/packages/flutter/test/widgets/placeholder_test.dart deleted file mode 100644 index 03a232aca2..0000000000 --- a/packages/flutter/test/widgets/placeholder_test.dart +++ /dev/null @@ -1,22 +0,0 @@ -// 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 key = new GlobalKey(); - - 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); - }); -}