mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

- Change RouteArguments to pass the route's BuildContext rather than the Navigator. This caused the bulk of the examples/ and .../test/ changes (those are mostly mechanical changes). It also meant I could simplify Navigator.of(). - Make initState() actually get called when the State's Element is in the tree, so you can use Foo.of() functions there. Added a test for this also. - Provide a RouteWidget so that routes have a position in the Widget tree. The bulk of the route logic is still in a longer-lived Route object for now. - Make Route.setState() only rebuild the actual route, not the whole navigator. - Provided a Route.of(). - Provided a Route.writeState / Route.readState API that tries to identify the clients by their runtimeType, their key, and their ancestors keys, up to the nearest ancestor with a GlobalKey. - Made scrollables hook into this API to track state. Added a test to make sure this works. - Fix the debug output of GestureDetector and the hashCode of MixedViewport. - Fixed ScrollableWidgetListState<T> to handle infinite lists.
36 lines
1.0 KiB
Dart
36 lines
1.0 KiB
Dart
// 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 'package:flutter/widgets.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import 'widget_tester.dart';
|
|
|
|
List<String> ancestors = <String>[];
|
|
|
|
class TestComponent extends StatefulComponent {
|
|
TestComponentState createState() => new TestComponentState();
|
|
}
|
|
|
|
class TestComponentState extends State<TestComponent> {
|
|
void initState() {
|
|
super.initState();
|
|
context.visitAncestorElements((Element element) {
|
|
ancestors.add(element.widget.runtimeType.toString());
|
|
return true;
|
|
});
|
|
}
|
|
|
|
Widget build(BuildContext context) => new Container();
|
|
}
|
|
|
|
void main() {
|
|
test('initState() is called when we are in the tree', () {
|
|
testWidgets((WidgetTester tester) {
|
|
tester.pumpWidget(new Container(child: new TestComponent()));
|
|
expect(ancestors, equals(<String>['Container', 'RenderObjectToWidgetAdapter<RenderBox>']));
|
|
});
|
|
});
|
|
}
|