Skip to content

Commit

Permalink
Nnbd widgets (#64672)
Browse files Browse the repository at this point in the history
* migrate widget to nullsafety

* remove double blank line after license

* address review comments in actions.dart

* nullable ObjectKey.value

* use local variable oldElement

* make State.build non-nullable

* make State.context non-nullable

* newline at eof

* make ProxyWidget.child non-nullable

* make _InactiveElements.debugContains non-nullable

* make Element.depth non-nullable

* make ProxyElement.build non-nullable

* make StatefulElement.state non-nullable

* remove 'Notice that'

* avoid cast of list in RenderObjectElement.updateChildren

* make IndexedSlot.value non-nullable

* avoid cast of list in MultiChildRenderObjectElement.mount

* make some WidgetsApp parameters non-nullable

* hitTest take non-nullable position

* make ScrollableState.position non-nullable

* use _pixels instead of pixels

* make ViewportOffset.pixels non-nullable

* make param and return type of IndexedWidgetBuilder non-nullable

* unused_import

* make context param non-nullable for Builder in animated_list.dart

* make ScrollMetrics.viewportDimension non-nullable

* make ScrollMetrics.{min,max}ScrollExtent non-nullable

* make _Location.file non-nullable

* _WidgetForTypeTests.createElement throw UnimplementedError

* update _NullWidget.build error message

* make _ShortcutsState.manager non-nullable

* Fix childCount issues for NNBD

* fix childCount computation on web

* increase max value on js side to compute childCount

* make aspect parameter of dependOnInheritedWidgetOfExactType nullable

* merge has{min,max}ScrollExtent into hasScrollExtents

* update focus_manager.dart

* address review comments in icon.dart

* address review comments in image.dart

* address review comments in routes.dart

* address review comments in scroll_activity.dart

* update doc comments

* make UserScrollNotification.direction non-nullable and required

* rename hasScrollExtents to hasContentDimensions

* unnecessary late

Co-authored-by: Ian Hickson <ian@hixie.ch>
  • Loading branch information
a14n and Hixie committed Sep 9, 2020
1 parent abeaf11 commit e682ec7
Show file tree
Hide file tree
Showing 123 changed files with 5,145 additions and 5,301 deletions.
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/cupertino/text_field.dart
Expand Up @@ -645,7 +645,7 @@ class CupertinoTextField extends StatefulWidget {
}
}

class _CupertinoTextFieldState extends State<CupertinoTextField> with RestorationMixin, AutomaticKeepAliveClientMixin implements TextSelectionGestureDetectorBuilderDelegate {
class _CupertinoTextFieldState extends State<CupertinoTextField> with RestorationMixin, AutomaticKeepAliveClientMixin<CupertinoTextField> implements TextSelectionGestureDetectorBuilderDelegate {
final GlobalKey _clearGlobalKey = GlobalKey();

RestorableTextEditingController _controller;
Expand Down
21 changes: 2 additions & 19 deletions packages/flutter/lib/src/rendering/sliver_fixed_extent_list.dart
Expand Up @@ -196,28 +196,11 @@ abstract class RenderSliverFixedExtentBoxAdaptor extends RenderSliverMultiBoxAda
if (firstChild == null) {
if (!addInitialChild(index: firstIndex, layoutOffset: indexToLayoutOffset(itemExtent, firstIndex))) {
// There are either no children, or we are past the end of all our children.
// If it is the latter, we will need to find the first available child.
double max;
if (childManager.childCount != null) {
max = computeMaxScrollOffset(constraints, itemExtent);
// TODO(ianh): null-aware flow analysis flags the next two
// branches as entirely dead code, and it's hard to argue with
// its logic.
} else if (firstIndex <= 0) { // ignore: dead_code
if (firstIndex <= 0) {
max = 0.0;
} else {
// We will have to find it manually.
int possibleFirstIndex = firstIndex - 1;
while (
possibleFirstIndex > 0 &&
!addInitialChild(
index: possibleFirstIndex,
layoutOffset: indexToLayoutOffset(itemExtent, possibleFirstIndex),
)
) {
possibleFirstIndex -= 1;
}
max = (possibleFirstIndex + 1) * itemExtent;
max = computeMaxScrollOffset(constraints, itemExtent);
}
geometry = SliverGeometry(
scrollExtent: max,
Expand Down
10 changes: 9 additions & 1 deletion packages/flutter/lib/src/rendering/viewport_offset.dart
Expand Up @@ -94,6 +94,9 @@ abstract class ViewportOffset extends ChangeNotifier {
/// the value changes due to [correctBy]).
double get pixels;

/// Whether the [pixels] property is available.
bool get hasPixels;

/// Called when the viewport's extents are established.
///
/// The argument is the dimension of the [RenderViewport] in the main axis
Expand Down Expand Up @@ -245,7 +248,9 @@ abstract class ViewportOffset extends ChangeNotifier {
/// `super.debugFillDescription(description)`.
@mustCallSuper
void debugFillDescription(List<String> description) {
description.add('offset: ${pixels.toStringAsFixed(1)}');
if (hasPixels) {
description.add('offset: ${pixels.toStringAsFixed(1)}');
}
}
}

Expand All @@ -258,6 +263,9 @@ class _FixedViewportOffset extends ViewportOffset {
@override
double get pixels => _pixels;

@override
bool get hasPixels => true;

@override
bool applyViewportDimension(double viewportDimension) => true;

Expand Down

0 comments on commit e682ec7

Please sign in to comment.