Skip to content

Commit

Permalink
Revert "Inject current FlutterView into tree and make available via…
Browse files Browse the repository at this point in the history
… `View.of(context)` (flutter#116924)" (flutter#117214)

This reverts commit a34e419.
  • Loading branch information
Casey Hillers authored and gspencergoog committed Jan 19, 2023
1 parent d4ebfc3 commit c783160
Show file tree
Hide file tree
Showing 21 changed files with 108 additions and 352 deletions.
22 changes: 2 additions & 20 deletions packages/flutter/lib/src/widgets/binding.dart
Expand Up @@ -19,7 +19,6 @@ import 'framework.dart';
import 'platform_menu_bar.dart';
import 'router.dart';
import 'service_extensions.dart';
import 'view.dart';
import 'widget_inspector.dart';

export 'dart:ui' show AppLifecycleState, Locale;
Expand Down Expand Up @@ -897,22 +896,6 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
@override
bool get framesEnabled => super.framesEnabled && _readyToProduceFrames;

/// Used by [runApp] to wrap the provided `rootWidget` in the default [View].
///
/// The [View] determines into what [FlutterView] the app is rendered into.
/// For backwards-compatibility reasons, this method currently chooses
/// [window] (which is a [FlutterView]) as the rendering target. This will
/// change in a future version of Flutter.
///
/// The `rootWidget` widget provided to this method must not already be
/// wrapped in a [View].
Widget wrapWithDefaultView(Widget rootWidget) {
return View(
view: window,
child: rootWidget,
);
}

/// Schedules a [Timer] for attaching the root widget.
///
/// This is called by [runApp] to configure the widget tree. Consider using
Expand Down Expand Up @@ -1031,9 +1014,8 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
/// * [WidgetsBinding.handleBeginFrame], which pumps the widget pipeline to
/// ensure the widget, element, and render trees are all built.
void runApp(Widget app) {
final WidgetsBinding binding = WidgetsFlutterBinding.ensureInitialized();
binding
..scheduleAttachRootWidget(binding.wrapWithDefaultView(app))
WidgetsFlutterBinding.ensureInitialized()
..scheduleAttachRootWidget(app)
..scheduleWarmUpFrame();
}

Expand Down
94 changes: 0 additions & 94 deletions packages/flutter/lib/src/widgets/view.dart

This file was deleted.

8 changes: 0 additions & 8 deletions packages/flutter/lib/src/widgets/window.dart

This file was deleted.

3 changes: 0 additions & 3 deletions packages/flutter/lib/widgets.dart
Expand Up @@ -148,11 +148,8 @@ export 'src/widgets/transitions.dart';
export 'src/widgets/tween_animation_builder.dart';
export 'src/widgets/unique_widget.dart';
export 'src/widgets/value_listenable_builder.dart';
// TODO(goderbauer): Enable once clean-up in google3 is done.
// export 'src/widgets/view.dart';
export 'src/widgets/viewport.dart';
export 'src/widgets/visibility.dart';
export 'src/widgets/widget_inspector.dart';
export 'src/widgets/widget_span.dart';
export 'src/widgets/will_pop_scope.dart';
export 'src/widgets/window.dart';
20 changes: 8 additions & 12 deletions packages/flutter/test/material/debug_test.dart
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';

void main() {
testWidgets('debugCheckHasMaterial control test', (WidgetTester tester) async {
await tester.pumpWidget(const Center(child: Chip(label: Text('label'))));
await tester.pumpWidget(const Chip(label: Text('label')));
final dynamic exception = tester.takeException();
expect(exception, isFlutterError);
final FlutterError error = exception as FlutterError;
Expand All @@ -25,7 +25,7 @@ void main() {
expect(error.diagnostics[3], isA<DiagnosticsProperty<Element>>());
expect(error.diagnostics[4], isA<DiagnosticsBlock>());
expect(
error.toStringDeep(), startsWith(
error.toStringDeep(),
'FlutterError\n'
' No Material widget found.\n'
' Chip widgets require a Material widget ancestor within the\n'
Expand All @@ -42,13 +42,12 @@ void main() {
' The specific widget that could not find a Material ancestor was:\n'
' Chip\n'
' The ancestors of this widget were:\n'
' Center\n'
// End of ancestor chain omitted, not relevant for test.
));
' [root]\n',
);
});

testWidgets('debugCheckHasMaterialLocalizations control test', (WidgetTester tester) async {
await tester.pumpWidget(const Center(child: BackButton()));
await tester.pumpWidget(const BackButton());
final dynamic exception = tester.takeException();
expect(exception, isFlutterError);
final FlutterError error = exception as FlutterError;
Expand All @@ -65,7 +64,7 @@ void main() {
expect(error.diagnostics[4], isA<DiagnosticsProperty<Element>>());
expect(error.diagnostics[5], isA<DiagnosticsBlock>());
expect(
error.toStringDeep(), startsWith(
error.toStringDeep(),
'FlutterError\n'
' No MaterialLocalizations found.\n'
' BackButton widgets require MaterialLocalizations to be provided\n'
Expand All @@ -79,9 +78,8 @@ void main() {
' ancestor was:\n'
' BackButton\n'
' The ancestors of this widget were:\n'
' Center\n'
// End of ancestor chain omitted, not relevant for test.
));
' [root]\n',
);
});

testWidgets('debugCheckHasScaffold control test', (WidgetTester tester) async {
Expand Down Expand Up @@ -235,7 +233,6 @@ void main() {
' HeroControllerScope\n'
' ScrollConfiguration\n'
' MaterialApp\n'
' View-[GlobalObjectKey TestWindow#00000]\n'
' [root]\n'
' Typically, the Scaffold widget is introduced by the MaterialApp\n'
' or WidgetsApp widget at the top of your application widget tree.\n'
Expand Down Expand Up @@ -380,7 +377,6 @@ void main() {
' Scaffold-[LabeledGlobalKey<ScaffoldState>#00000]\n'
' MediaQuery\n'
' Directionality\n'
' View-[GlobalObjectKey TestWindow#00000]\n'
' [root]\n'
' Typically, the ScaffoldMessenger widget is introduced by the\n'
' MaterialApp at the top of your application widget tree.\n'
Expand Down
1 change: 0 additions & 1 deletion packages/flutter/test/material/scaffold_test.dart
Expand Up @@ -2458,7 +2458,6 @@ void main() {
' Scaffold\n'
' MediaQuery\n'
' Directionality\n'
' View-[GlobalObjectKey TestWindow#e6136]\n'
' [root]\n'
' Typically, the ScaffoldMessenger widget is introduced by the\n'
' MaterialApp at the top of your application widget tree.\n',
Expand Down
1 change: 1 addition & 0 deletions packages/flutter/test/material/text_field_test.dart
Expand Up @@ -7431,6 +7431,7 @@ void main() {
final dynamic exception = tester.takeException();
expect(exception, isFlutterError);
expect(exception.toString(), startsWith('No Material widget found.'));
expect(exception.toString(), endsWith(':\n $textField\nThe ancestors of this widget were:\n [root]'));
});

testWidgets('TextField loses focus when disabled', (WidgetTester tester) async {
Expand Down

0 comments on commit c783160

Please sign in to comment.