Migrate some widget tests to NNBD (#68150)
This commit is contained in:
parent
dfc6c4386a
commit
e3184b38be
@ -213,11 +213,13 @@ class _SaltedValueKey extends ValueKey<Key>{
|
|||||||
const _SaltedValueKey(Key key): assert(key != null), super(key);
|
const _SaltedValueKey(Key key): assert(key != null), super(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called to find the new index of a child based on its key in case of
|
/// Called to find the new index of a child based on its `key` in case of
|
||||||
/// reordering.
|
/// reordering.
|
||||||
///
|
///
|
||||||
|
/// If the child with the `key` is no longer present, null is returned.
|
||||||
|
///
|
||||||
/// Used by [SliverChildBuilderDelegate.findChildIndexCallback].
|
/// Used by [SliverChildBuilderDelegate.findChildIndexCallback].
|
||||||
typedef ChildIndexGetter = int Function(Key key);
|
typedef ChildIndexGetter = int? Function(Key key);
|
||||||
|
|
||||||
/// A delegate that supplies children for slivers using a builder callback.
|
/// A delegate that supplies children for slivers using a builder callback.
|
||||||
///
|
///
|
||||||
@ -424,8 +426,8 @@ class SliverChildBuilderDelegate extends SliverChildDelegate {
|
|||||||
/// when the order in which children are returned from [builder] changes.
|
/// when the order in which children are returned from [builder] changes.
|
||||||
/// This may result in state-loss.
|
/// This may result in state-loss.
|
||||||
///
|
///
|
||||||
/// This callback should take an input [Key], and It should return the
|
/// This callback should take an input [Key], and it should return the
|
||||||
/// index of the child element with associated key, null if not found.
|
/// index of the child element with that associated key, or null if not found.
|
||||||
final ChildIndexGetter? findChildIndexCallback;
|
final ChildIndexGetter? findChildIndexCallback;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
@ -21,7 +19,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Semantics shutdown and restart', (WidgetTester tester) async {
|
testWidgets('Semantics shutdown and restart', (WidgetTester tester) async {
|
||||||
SemanticsTester semantics = SemanticsTester(tester);
|
SemanticsTester? semantics = SemanticsTester(tester);
|
||||||
|
|
||||||
final TestSemantics expectedSemantics = TestSemantics.root(
|
final TestSemantics expectedSemantics = TestSemantics.root(
|
||||||
children: <TestSemantics>[
|
children: <TestSemantics>[
|
||||||
@ -436,7 +434,7 @@ void main() {
|
|||||||
expect(semantics, hasSemantics(expectedSemantics));
|
expect(semantics, hasSemantics(expectedSemantics));
|
||||||
|
|
||||||
// Do the actions work?
|
// Do the actions work?
|
||||||
final SemanticsOwner semanticsOwner = tester.binding.pipelineOwner.semanticsOwner;
|
final SemanticsOwner semanticsOwner = tester.binding.pipelineOwner.semanticsOwner!;
|
||||||
int expectedLength = 1;
|
int expectedLength = 1;
|
||||||
for (final SemanticsAction action in allActions) {
|
for (final SemanticsAction action in allActions) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
@ -574,7 +572,7 @@ void main() {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
final SemanticsOwner semanticsOwner = tester.binding.pipelineOwner.semanticsOwner;
|
final SemanticsOwner semanticsOwner = tester.binding.pipelineOwner.semanticsOwner!;
|
||||||
|
|
||||||
expect(semantics, hasSemantics(expectedSemantics));
|
expect(semantics, hasSemantics(expectedSemantics));
|
||||||
semanticsOwner.performAction(expectedId, SemanticsAction.tap);
|
semanticsOwner.performAction(expectedId, SemanticsAction.tap);
|
||||||
@ -1101,5 +1099,5 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CustomSortKey extends OrdinalSortKey {
|
class CustomSortKey extends OrdinalSortKey {
|
||||||
const CustomSortKey(double order, {String name}) : super(order, name: name);
|
const CustomSortKey(double order, {String? name}) : super(order, name: name);
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
@TestOn('!chrome')
|
@TestOn('!chrome')
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
@ -62,10 +60,10 @@ void _tests() {
|
|||||||
.join('\n')
|
.join('\n')
|
||||||
.trim() + ',';
|
.trim() + ',';
|
||||||
|
|
||||||
File findThisTestFile(Directory directory) {
|
File? findThisTestFile(Directory directory) {
|
||||||
for (final FileSystemEntity entity in directory.listSync()) {
|
for (final FileSystemEntity entity in directory.listSync()) {
|
||||||
if (entity is Directory) {
|
if (entity is Directory) {
|
||||||
final File childSearch = findThisTestFile(entity);
|
final File? childSearch = findThisTestFile(entity);
|
||||||
if (childSearch != null) {
|
if (childSearch != null) {
|
||||||
return childSearch;
|
return childSearch;
|
||||||
}
|
}
|
||||||
@ -76,7 +74,7 @@ void _tests() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final File thisTestFile = findThisTestFile(Directory.current);
|
final File thisTestFile = findThisTestFile(Directory.current)!;
|
||||||
expect(thisTestFile, isNotNull);
|
expect(thisTestFile, isNotNull);
|
||||||
String expectedCode = thisTestFile.readAsStringSync();
|
String expectedCode = thisTestFile.readAsStringSync();
|
||||||
expectedCode = expectedCode.substring(
|
expectedCode = expectedCode.substring(
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
@ -293,9 +291,9 @@ class TraversalTester {
|
|||||||
final SemanticsTester semantics;
|
final SemanticsTester semantics;
|
||||||
|
|
||||||
Future<void> test({
|
Future<void> test({
|
||||||
TextDirection textDirection,
|
required TextDirection textDirection,
|
||||||
Map<String, Rect> children,
|
required Map<String, Rect> children,
|
||||||
String expectedTraversal,
|
required String expectedTraversal,
|
||||||
}) async {
|
}) async {
|
||||||
assert(children is LinkedHashMap);
|
assert(children is LinkedHashMap);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -314,8 +312,8 @@ class TraversalTester {
|
|||||||
explicitChildNodes: true,
|
explicitChildNodes: true,
|
||||||
label: label,
|
label: label,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: children[label].width,
|
width: children[label]!.width,
|
||||||
height: children[label].height,
|
height: children[label]!.height,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
@ -2,13 +2,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
class Inside extends StatefulWidget {
|
class Inside extends StatefulWidget {
|
||||||
const Inside({ Key key }) : super(key: key);
|
const Inside({ Key? key }) : super(key: key);
|
||||||
@override
|
@override
|
||||||
InsideState createState() => InsideState();
|
InsideState createState() => InsideState();
|
||||||
}
|
}
|
||||||
@ -29,11 +27,11 @@ class InsideState extends State<Inside> {
|
|||||||
|
|
||||||
class Middle extends StatefulWidget {
|
class Middle extends StatefulWidget {
|
||||||
const Middle({
|
const Middle({
|
||||||
Key key,
|
Key? key,
|
||||||
this.child,
|
this.child,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Inside child;
|
final Inside? child;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
MiddleState createState() => MiddleState();
|
MiddleState createState() => MiddleState();
|
||||||
@ -54,7 +52,7 @@ class MiddleState extends State<Middle> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Outside extends StatefulWidget {
|
class Outside extends StatefulWidget {
|
||||||
const Outside({ Key key }) : super(key: key);
|
const Outside({ Key? key }) : super(key: key);
|
||||||
@override
|
@override
|
||||||
OutsideState createState() => OutsideState();
|
OutsideState createState() => OutsideState();
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
@ -2,15 +2,13 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
ChangerState changer;
|
late ChangerState changer;
|
||||||
|
|
||||||
class Changer extends StatefulWidget {
|
class Changer extends StatefulWidget {
|
||||||
const Changer(this.child, { Key key }) : super(key: key);
|
const Changer(this.child, { Key? key }) : super(key: key);
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
@ -34,7 +32,7 @@ class ChangerState extends State<Changer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Wrapper extends StatelessWidget {
|
class Wrapper extends StatelessWidget {
|
||||||
const Wrapper(this.child, { Key key }) : super(key: key);
|
const Wrapper(this.child, { Key? key }) : super(key: key);
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
@ -43,7 +41,7 @@ class Wrapper extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Leaf extends StatefulWidget {
|
class Leaf extends StatefulWidget {
|
||||||
const Leaf({ Key key }) : super(key: key);
|
const Leaf({ Key? key }) : super(key: key);
|
||||||
@override
|
@override
|
||||||
LeafState createState() => LeafState();
|
LeafState createState() => LeafState();
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
class Changer extends StatefulWidget {
|
class Changer extends StatefulWidget {
|
||||||
const Changer({ Key key }) : super(key: key);
|
const Changer({ Key? key }) : super(key: key);
|
||||||
@override
|
@override
|
||||||
ChangerState createState() => ChangerState();
|
ChangerState createState() => ChangerState();
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,11 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
class BadWidget extends StatefulWidget {
|
class BadWidget extends StatefulWidget {
|
||||||
const BadWidget({ Key key }) : super(key: key);
|
const BadWidget({ Key? key }) : super(key: key);
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => BadWidgetState();
|
State<StatefulWidget> createState() => BadWidgetState();
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:ui' show Shader;
|
import 'dart:ui' show Shader;
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
@ -26,7 +24,7 @@ void main() {
|
|||||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44152
|
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44152
|
||||||
|
|
||||||
testWidgets('Bounds rect includes offset', (WidgetTester tester) async {
|
testWidgets('Bounds rect includes offset', (WidgetTester tester) async {
|
||||||
Rect shaderBounds;
|
late Rect shaderBounds;
|
||||||
Shader recordShaderBounds(Rect bounds) {
|
Shader recordShaderBounds(Rect bounds) {
|
||||||
shaderBounds = bounds;
|
shaderBounds = bounds;
|
||||||
return createShader(bounds);
|
return createShader(bounds);
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@ -79,7 +77,7 @@ void main() {
|
|||||||
color: Colors.yellow[200],
|
color: Colors.yellow[200],
|
||||||
child: PhysicalModel(
|
child: PhysicalModel(
|
||||||
elevation: 9.0,
|
elevation: 9.0,
|
||||||
color: Colors.blue[900],
|
color: Colors.blue[900]!,
|
||||||
child: const SizedBox(
|
child: const SizedBox(
|
||||||
height: 100.0,
|
height: 100.0,
|
||||||
width: 100.0,
|
width: 100.0,
|
||||||
@ -111,7 +109,7 @@ void main() {
|
|||||||
padding: const EdgeInsets.all(150.0),
|
padding: const EdgeInsets.all(150.0),
|
||||||
color: Colors.yellow[200],
|
color: Colors.yellow[200],
|
||||||
child: PhysicalShape(
|
child: PhysicalShape(
|
||||||
color: Colors.green[900],
|
color: Colors.green[900]!,
|
||||||
clipper: ShapeBorderClipper(shape: BeveledRectangleBorder(
|
clipper: ShapeBorderClipper(shape: BeveledRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(20.0))),
|
borderRadius: BorderRadius.circular(20.0))),
|
||||||
elevation: elevation,
|
elevation: elevation,
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'dart:ui' as ui show Image;
|
import 'dart:ui' as ui show Image;
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@ -11,11 +9,11 @@ import 'package:flutter/src/services/keyboard_key.dart';
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
typedef PostInvokeCallback = void Function({Action<Intent> action, Intent intent, BuildContext context, ActionDispatcher dispatcher});
|
typedef PostInvokeCallback = void Function({Action<Intent> action, Intent intent, BuildContext? context, ActionDispatcher dispatcher});
|
||||||
|
|
||||||
class TestAction extends CallbackAction<TestIntent> {
|
class TestAction extends CallbackAction<TestIntent> {
|
||||||
TestAction({
|
TestAction({
|
||||||
@required OnInvokeCallback onInvoke,
|
required OnInvokeCallback onInvoke,
|
||||||
}) : assert(onInvoke != null),
|
}) : assert(onInvoke != null),
|
||||||
super(onInvoke: onInvoke);
|
super(onInvoke: onInvoke);
|
||||||
|
|
||||||
@ -25,11 +23,11 @@ class TestAction extends CallbackAction<TestIntent> {
|
|||||||
class TestDispatcher extends ActionDispatcher {
|
class TestDispatcher extends ActionDispatcher {
|
||||||
const TestDispatcher({this.postInvoke});
|
const TestDispatcher({this.postInvoke});
|
||||||
|
|
||||||
final PostInvokeCallback postInvoke;
|
final PostInvokeCallback? postInvoke;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Object invokeAction(Action<TestIntent> action, Intent intent, [BuildContext context]) {
|
Object? invokeAction(Action<TestIntent> action, Intent intent, [BuildContext? context]) {
|
||||||
final Object result = super.invokeAction(action, intent, context);
|
final Object? result = super.invokeAction(action, intent, context);
|
||||||
postInvoke?.call(action: action, intent: intent, context: context, dispatcher: this);
|
postInvoke?.call(action: action, intent: intent, context: context, dispatcher: this);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -45,7 +43,7 @@ class TestShortcutManager extends ShortcutManager {
|
|||||||
List<LogicalKeyboardKey> keys;
|
List<LogicalKeyboardKey> keys;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool handleKeypress(BuildContext context, RawKeyEvent event, {LogicalKeySet keysPressed}) {
|
bool handleKeypress(BuildContext context, RawKeyEvent event, {LogicalKeySet? keysPressed}) {
|
||||||
keys.add(event.logicalKey);
|
keys.add(event.logicalKey);
|
||||||
return super.handleKeypress(context, event, keysPressed: keysPressed);
|
return super.handleKeypress(context, event, keysPressed: keysPressed);
|
||||||
}
|
}
|
||||||
@ -239,7 +237,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(Shortcuts.of(containerKey.currentContext), isNotNull);
|
expect(Shortcuts.of(containerKey.currentContext!), isNotNull);
|
||||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
|
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
|
||||||
expect(invoked, isTrue);
|
expect(invoked, isTrue);
|
||||||
expect(pressedKeys, equals(<LogicalKeyboardKey>[LogicalKeyboardKey.shiftLeft]));
|
expect(pressedKeys, equals(<LogicalKeyboardKey>[LogicalKeyboardKey.shiftLeft]));
|
||||||
@ -277,7 +275,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(Shortcuts.of(containerKey.currentContext), isNotNull);
|
expect(Shortcuts.of(containerKey.currentContext!), isNotNull);
|
||||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
|
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
|
||||||
expect(invoked, isTrue);
|
expect(invoked, isTrue);
|
||||||
expect(pressedKeys, equals(<LogicalKeyboardKey>[LogicalKeyboardKey.shiftLeft]));
|
expect(pressedKeys, equals(<LogicalKeyboardKey>[LogicalKeyboardKey.shiftLeft]));
|
||||||
@ -317,7 +315,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(Shortcuts.of(containerKey.currentContext), isNotNull);
|
expect(Shortcuts.of(containerKey.currentContext!), isNotNull);
|
||||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
|
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
|
||||||
expect(invoked, isFalse);
|
expect(invoked, isFalse);
|
||||||
expect(pressedKeys, isEmpty);
|
expect(pressedKeys, isEmpty);
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
@ -15,10 +13,10 @@ import 'semantics_tester.dart';
|
|||||||
|
|
||||||
class TestScrollPosition extends ScrollPositionWithSingleContext {
|
class TestScrollPosition extends ScrollPositionWithSingleContext {
|
||||||
TestScrollPosition({
|
TestScrollPosition({
|
||||||
ScrollPhysics physics,
|
required ScrollPhysics physics,
|
||||||
ScrollContext state,
|
required ScrollContext state,
|
||||||
double initialPixels = 0.0,
|
double initialPixels = 0.0,
|
||||||
ScrollPosition oldPosition,
|
ScrollPosition? oldPosition,
|
||||||
}) : super(
|
}) : super(
|
||||||
physics: physics,
|
physics: physics,
|
||||||
context: state,
|
context: state,
|
||||||
@ -29,7 +27,7 @@ class TestScrollPosition extends ScrollPositionWithSingleContext {
|
|||||||
|
|
||||||
class TestScrollController extends ScrollController {
|
class TestScrollController extends ScrollController {
|
||||||
@override
|
@override
|
||||||
ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition oldPosition) {
|
ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition? oldPosition) {
|
||||||
return TestScrollPosition(
|
return TestScrollPosition(
|
||||||
physics: physics,
|
physics: physics,
|
||||||
state: context,
|
state: context,
|
||||||
@ -53,7 +51,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 1st, check that the render object has received the default clip behavior.
|
// 1st, check that the render object has received the default clip behavior.
|
||||||
final dynamic renderObject = tester.allRenderObjects.where((RenderObject o) => o.runtimeType.toString() == '_RenderSingleChildViewport').first;
|
final dynamic renderObject = tester.allRenderObjects.where((RenderObject o) => o.runtimeType.toString() == '_RenderSingleChildViewport').first; // ignore: unnecessary_nullable_for_final_variable_declarations
|
||||||
expect(renderObject.clipBehavior, equals(Clip.hardEdge));
|
expect(renderObject.clipBehavior, equals(Clip.hardEdge));
|
||||||
|
|
||||||
// 2nd, height == widow.height test: check that the painting context does not call pushClipRect .
|
// 2nd, height == widow.height test: check that the painting context does not call pushClipRect .
|
||||||
@ -107,7 +105,7 @@ void main() {
|
|||||||
await tester.pumpWidget(SingleChildScrollView(child: Container(height: 2000.0)));
|
await tester.pumpWidget(SingleChildScrollView(child: Container(height: 2000.0)));
|
||||||
|
|
||||||
// 1st, check that the render object has received the default clip behavior.
|
// 1st, check that the render object has received the default clip behavior.
|
||||||
final dynamic renderObject = tester.allRenderObjects.where((RenderObject o) => o.runtimeType.toString() == '_RenderSingleChildViewport').first;
|
final dynamic renderObject = tester.allRenderObjects.where((RenderObject o) => o.runtimeType.toString() == '_RenderSingleChildViewport').first; // ignore: unnecessary_nullable_for_final_variable_declarations
|
||||||
expect(renderObject.clipBehavior, equals(Clip.hardEdge));
|
expect(renderObject.clipBehavior, equals(Clip.hardEdge));
|
||||||
|
|
||||||
// 2nd, check that the painting context has received the default clip behavior.
|
// 2nd, check that the painting context has received the default clip behavior.
|
||||||
@ -630,7 +628,15 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Nested SingleChildScrollView showOnScreen', (WidgetTester tester) async {
|
testWidgets('Nested SingleChildScrollView showOnScreen', (WidgetTester tester) async {
|
||||||
final List<List<Widget>> children = List<List<Widget>>(10);
|
final List<List<Widget>> children = List<List<Widget>>.generate(10, (int x) {
|
||||||
|
return List<Widget>.generate(10, (int y) {
|
||||||
|
return SizedBox(
|
||||||
|
key: UniqueKey(),
|
||||||
|
height: 100.0,
|
||||||
|
width: 100.0,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
ScrollController controllerX;
|
ScrollController controllerX;
|
||||||
ScrollController controllerY;
|
ScrollController controllerY;
|
||||||
|
|
||||||
@ -665,17 +671,11 @@ void main() {
|
|||||||
controller: controllerX = ScrollController(initialScrollOffset: 400.0),
|
controller: controllerX = ScrollController(initialScrollOffset: 400.0),
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: List<Widget>.generate(10, (int y) {
|
children: children.map((List<Widget> widgets) {
|
||||||
return Row(
|
return Row(
|
||||||
children: children[y] = List<Widget>.generate(10, (int x) {
|
children: widgets,
|
||||||
return SizedBox(
|
|
||||||
key: UniqueKey(),
|
|
||||||
height: 100.0,
|
|
||||||
width: 100.0,
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}),
|
}).toList(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -792,9 +792,9 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
group('Nested SingleChildScrollView (same orientation) showOnScreen', () {
|
group('Nested SingleChildScrollView (same orientation) showOnScreen', () {
|
||||||
List<Widget> children;
|
late List<Widget> children;
|
||||||
|
|
||||||
Future<void> buildNestedScroller({ WidgetTester tester, ScrollController inner, ScrollController outer }) {
|
Future<void> buildNestedScroller({ required WidgetTester tester, ScrollController? inner, ScrollController? outer }) {
|
||||||
return tester.pumpWidget(
|
return tester.pumpWidget(
|
||||||
Directionality(
|
Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
@ -48,7 +46,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(patient.currentContext.size, equals(const Size(0.0, 0.0)));
|
expect(patient.currentContext!.size, equals(const Size(0.0, 0.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Center(
|
Center(
|
||||||
@ -58,7 +56,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(patient.currentContext.size, equals(const Size(0.0, 0.0)));
|
expect(patient.currentContext!.size, equals(const Size(0.0, 0.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Center(
|
Center(
|
||||||
@ -69,7 +67,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(patient.currentContext.size, equals(const Size(0.0, 0.0)));
|
expect(patient.currentContext!.size, equals(const Size(0.0, 0.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Center(
|
Center(
|
||||||
@ -80,7 +78,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(patient.currentContext.size, equals(const Size(100.0, 100.0)));
|
expect(patient.currentContext!.size, equals(const Size(100.0, 100.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Center(
|
Center(
|
||||||
@ -91,7 +89,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(patient.currentContext.size, equals(const Size(800.0, 600.0)));
|
expect(patient.currentContext!.size, equals(const Size(800.0, 600.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Center(
|
Center(
|
||||||
@ -100,7 +98,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(patient.currentContext.size, equals(const Size(800.0, 600.0)));
|
expect(patient.currentContext!.size, equals(const Size(800.0, 600.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Center(
|
Center(
|
||||||
@ -109,7 +107,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(patient.currentContext.size, equals(const Size(0.0, 0.0)));
|
expect(patient.currentContext!.size, equals(const Size(0.0, 0.0)));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('SizedBox - container child', (WidgetTester tester) async {
|
testWidgets('SizedBox - container child', (WidgetTester tester) async {
|
||||||
@ -123,7 +121,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(patient.currentContext.size, equals(const Size(800.0, 600.0)));
|
expect(patient.currentContext!.size, equals(const Size(800.0, 600.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Center(
|
Center(
|
||||||
@ -134,7 +132,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(patient.currentContext.size, equals(const Size(800.0, 0.0)));
|
expect(patient.currentContext!.size, equals(const Size(800.0, 0.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Center(
|
Center(
|
||||||
@ -146,7 +144,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(patient.currentContext.size, equals(const Size(0.0, 0.0)));
|
expect(patient.currentContext!.size, equals(const Size(0.0, 0.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Center(
|
Center(
|
||||||
@ -158,7 +156,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(patient.currentContext.size, equals(const Size(100.0, 100.0)));
|
expect(patient.currentContext!.size, equals(const Size(100.0, 100.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Center(
|
Center(
|
||||||
@ -170,7 +168,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(patient.currentContext.size, equals(const Size(800.0, 600.0)));
|
expect(patient.currentContext!.size, equals(const Size(800.0, 600.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Center(
|
Center(
|
||||||
@ -180,7 +178,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(patient.currentContext.size, equals(const Size(800.0, 600.0)));
|
expect(patient.currentContext!.size, equals(const Size(800.0, 600.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Center(
|
Center(
|
||||||
@ -190,6 +188,6 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(patient.currentContext.size, equals(const Size(0.0, 0.0)));
|
expect(patient.currentContext!.size, equals(const Size(0.0, 0.0)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -21,11 +19,11 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
||||||
expect(render.text.style.color.opacity, 1.0);
|
expect(render.text.style!.color!.opacity, 1.0);
|
||||||
|
|
||||||
controller.jumpTo(200.0);
|
controller.jumpTo(200.0);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(render.text.style.color.opacity, 0.0);
|
expect(render.text.style!.color!.opacity, 0.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('!pinned && !floating && bottom ==> fade opacity', (WidgetTester tester) async {
|
testWidgets('!pinned && !floating && bottom ==> fade opacity', (WidgetTester tester) async {
|
||||||
@ -40,11 +38,11 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
||||||
expect(render.text.style.color.opacity, 1.0);
|
expect(render.text.style!.color!.opacity, 1.0);
|
||||||
|
|
||||||
controller.jumpTo(200.0);
|
controller.jumpTo(200.0);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(render.text.style.color.opacity, 0.0);
|
expect(render.text.style!.color!.opacity, 0.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('!pinned && floating && !bottom ==> fade opacity', (WidgetTester tester) async {
|
testWidgets('!pinned && floating && !bottom ==> fade opacity', (WidgetTester tester) async {
|
||||||
@ -59,11 +57,11 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
||||||
expect(render.text.style.color.opacity, 1.0);
|
expect(render.text.style!.color!.opacity, 1.0);
|
||||||
|
|
||||||
controller.jumpTo(200.0);
|
controller.jumpTo(200.0);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(render.text.style.color.opacity, 0.0);
|
expect(render.text.style!.color!.opacity, 0.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('!pinned && floating && bottom ==> fade opacity', (WidgetTester tester) async {
|
testWidgets('!pinned && floating && bottom ==> fade opacity', (WidgetTester tester) async {
|
||||||
@ -78,11 +76,11 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
||||||
expect(render.text.style.color.opacity, 1.0);
|
expect(render.text.style!.color!.opacity, 1.0);
|
||||||
|
|
||||||
controller.jumpTo(200.0);
|
controller.jumpTo(200.0);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(render.text.style.color.opacity, 0.0);
|
expect(render.text.style!.color!.opacity, 0.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('pinned && !floating && !bottom ==> 1.0 opacity', (WidgetTester tester) async {
|
testWidgets('pinned && !floating && !bottom ==> 1.0 opacity', (WidgetTester tester) async {
|
||||||
@ -97,11 +95,11 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
||||||
expect(render.text.style.color.opacity, 1.0);
|
expect(render.text.style!.color!.opacity, 1.0);
|
||||||
|
|
||||||
controller.jumpTo(200.0);
|
controller.jumpTo(200.0);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(render.text.style.color.opacity, 1.0);
|
expect(render.text.style!.color!.opacity, 1.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('pinned && !floating && bottom ==> 1.0 opacity', (WidgetTester tester) async {
|
testWidgets('pinned && !floating && bottom ==> 1.0 opacity', (WidgetTester tester) async {
|
||||||
@ -116,11 +114,11 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
||||||
expect(render.text.style.color.opacity, 1.0);
|
expect(render.text.style!.color!.opacity, 1.0);
|
||||||
|
|
||||||
controller.jumpTo(200.0);
|
controller.jumpTo(200.0);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(render.text.style.color.opacity, 1.0);
|
expect(render.text.style!.color!.opacity, 1.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('pinned && floating && !bottom ==> 1.0 opacity', (WidgetTester tester) async {
|
testWidgets('pinned && floating && !bottom ==> 1.0 opacity', (WidgetTester tester) async {
|
||||||
@ -137,11 +135,11 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
||||||
expect(render.text.style.color.opacity, 1.0);
|
expect(render.text.style!.color!.opacity, 1.0);
|
||||||
|
|
||||||
controller.jumpTo(200.0);
|
controller.jumpTo(200.0);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(render.text.style.color.opacity, 1.0);
|
expect(render.text.style!.color!.opacity, 1.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('pinned && floating && bottom && extraToolbarHeight == 0.0 ==> fade opacity', (WidgetTester tester) async {
|
testWidgets('pinned && floating && bottom && extraToolbarHeight == 0.0 ==> fade opacity', (WidgetTester tester) async {
|
||||||
@ -158,11 +156,11 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
||||||
expect(render.text.style.color.opacity, 1.0);
|
expect(render.text.style!.color!.opacity, 1.0);
|
||||||
|
|
||||||
controller.jumpTo(200.0);
|
controller.jumpTo(200.0);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(render.text.style.color.opacity, 0.0);
|
expect(render.text.style!.color!.opacity, 0.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('pinned && floating && bottom && extraToolbarHeight != 0.0 ==> 1.0 opacity', (WidgetTester tester) async {
|
testWidgets('pinned && floating && bottom && extraToolbarHeight != 0.0 ==> 1.0 opacity', (WidgetTester tester) async {
|
||||||
@ -178,11 +176,11 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
||||||
expect(render.text.style.color.opacity, 1.0);
|
expect(render.text.style!.color!.opacity, 1.0);
|
||||||
|
|
||||||
controller.jumpTo(200.0);
|
controller.jumpTo(200.0);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(render.text.style.color.opacity, 1.0);
|
expect(render.text.style!.color!.opacity, 1.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('!pinned && !floating && !bottom && extraToolbarHeight != 0.0 ==> fade opacity', (WidgetTester tester) async {
|
testWidgets('!pinned && !floating && !bottom && extraToolbarHeight != 0.0 ==> fade opacity', (WidgetTester tester) async {
|
||||||
@ -199,20 +197,20 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
final RenderParagraph render = tester.renderObject(find.text('Hallo Welt!!1'));
|
||||||
expect(render.text.style.color.opacity, 1.0);
|
expect(render.text.style!.color!.opacity, 1.0);
|
||||||
|
|
||||||
controller.jumpTo(collapsedHeight);
|
controller.jumpTo(collapsedHeight);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(render.text.style.color.opacity, 0.0);
|
expect(render.text.style!.color!.opacity, 0.0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TestWidget extends StatelessWidget {
|
class _TestWidget extends StatelessWidget {
|
||||||
|
|
||||||
const _TestWidget({
|
const _TestWidget({
|
||||||
this.pinned,
|
required this.pinned,
|
||||||
this.floating,
|
required this.floating,
|
||||||
this.bottom,
|
required this.bottom,
|
||||||
this.controller,
|
this.controller,
|
||||||
this.collapsedHeight,
|
this.collapsedHeight,
|
||||||
});
|
});
|
||||||
@ -220,8 +218,8 @@ class _TestWidget extends StatelessWidget {
|
|||||||
final bool pinned;
|
final bool pinned;
|
||||||
final bool floating;
|
final bool floating;
|
||||||
final bool bottom;
|
final bool bottom;
|
||||||
final ScrollController controller;
|
final ScrollController? controller;
|
||||||
final double collapsedHeight;
|
final double? collapsedHeight;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@ -39,7 +37,7 @@ void main() {
|
|||||||
// can fit in the viewport, and the SliverList doesn't report a child count,
|
// can fit in the viewport, and the SliverList doesn't report a child count,
|
||||||
// so the SliverList leads to an infinite precedingScrollExtent.
|
// so the SliverList leads to an infinite precedingScrollExtent.
|
||||||
final RenderViewport renderViewport = tester.renderObject(find.byType(Viewport));
|
final RenderViewport renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
final RenderSliver lastRenderSliver = renderViewport.lastChild;
|
final RenderSliver lastRenderSliver = renderViewport.lastChild!;
|
||||||
expect(lastRenderSliver.constraints.precedingScrollExtent, double.infinity);
|
expect(lastRenderSliver.constraints.precedingScrollExtent, double.infinity);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -21,7 +19,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
Widget boilerplate(
|
Widget boilerplate(
|
||||||
List<Widget> slivers, {
|
List<Widget> slivers, {
|
||||||
ScrollController controller,
|
ScrollController? controller,
|
||||||
Axis scrollDirection = Axis.vertical,
|
Axis scrollDirection = Axis.vertical,
|
||||||
}) {
|
}) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@ -174,7 +172,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final RenderSliver boxWithPadding = tester.renderObject<RenderSliver>(find.byType(SliverFillViewport));
|
final RenderSliver boxWithPadding = tester.renderObject<RenderSliver>(find.byType(SliverFillViewport));
|
||||||
expect(boxWithPadding.geometry.paintExtent, equals(600.0));
|
expect(boxWithPadding.geometry!.paintExtent, equals(600.0));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Directionality(
|
||||||
@ -192,6 +190,6 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final RenderSliver boxWithoutPadding = tester.renderObject<RenderSliver>(find.byType(SliverFillViewport));
|
final RenderSliver boxWithoutPadding = tester.renderObject<RenderSliver>(find.byType(SliverFillViewport));
|
||||||
expect(boxWithoutPadding.geometry.paintExtent, equals(300.0));
|
expect(boxWithoutPadding.geometry!.paintExtent, equals(300.0));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -368,7 +366,7 @@ Widget _buildSliverListRenderWidgetChild(List<String> items) {
|
|||||||
|
|
||||||
Widget _buildSliverList({
|
Widget _buildSliverList({
|
||||||
List<int> items = const <int>[],
|
List<int> items = const <int>[],
|
||||||
ScrollController controller,
|
ScrollController? controller,
|
||||||
double itemHeight = 500.0,
|
double itemHeight = 500.0,
|
||||||
double viewportHeight = 300.0,
|
double viewportHeight = 300.0,
|
||||||
}) {
|
}) {
|
||||||
|
@ -2,16 +2,14 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
class TestItem extends StatelessWidget {
|
class TestItem extends StatelessWidget {
|
||||||
const TestItem({ Key key, this.item, this.width, this.height }) : super(key: key);
|
const TestItem({ Key? key, required this.item, this.width, this.height }) : super(key: key);
|
||||||
final int item;
|
final int item;
|
||||||
final double width;
|
final double? width;
|
||||||
final double height;
|
final double? height;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
@ -23,7 +21,7 @@ class TestItem extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildFrame({ int count, double width, double height, Axis scrollDirection }) {
|
Widget buildFrame({ int? count, double? width, double? height, Axis? scrollDirection }) {
|
||||||
return Directionality(
|
return Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@ -13,7 +11,7 @@ import '../rendering/mock_canvas.dart';
|
|||||||
import 'semantics_tester.dart';
|
import 'semantics_tester.dart';
|
||||||
|
|
||||||
class TestState extends StatefulWidget {
|
class TestState extends StatefulWidget {
|
||||||
const TestState({ Key key, this.child, this.log }) : super(key: key);
|
const TestState({ Key? key, required this.child, required this.log }) : super(key: key);
|
||||||
final Widget child;
|
final Widget child;
|
||||||
final List<String> log;
|
final List<String> log;
|
||||||
@override
|
@override
|
||||||
@ -84,8 +82,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility), findsOneWidget);
|
expect(find.byType(SliverVisibility), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility), paints..paragraph());
|
expect(find.byType(SliverVisibility), paints..paragraph());
|
||||||
RenderViewport renderViewport = tester.renderObject(find.byType(Viewport));
|
RenderViewport renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
RenderSliver renderSliver = renderViewport.lastChild;
|
RenderSliver renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 14.0);
|
expect(renderSliver.geometry!.scrollExtent, 14.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
||||||
expect(log, <String>['created new state']);
|
expect(log, <String>['created new state']);
|
||||||
@ -103,8 +101,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility, skipOffstage: false), findsOneWidget);
|
expect(find.byType(SliverVisibility, skipOffstage: false), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility, skipOffstage: false), paintsNothing);
|
expect(find.byType(SliverVisibility, skipOffstage: false), paintsNothing);
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 0.0);
|
expect(renderSliver.geometry!.scrollExtent, 0.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
||||||
expect(log, <String>[]);
|
expect(log, <String>[]);
|
||||||
expect(find.byKey(anchor), findsNothing);
|
expect(find.byKey(anchor), findsNothing);
|
||||||
@ -121,8 +119,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility), findsOneWidget);
|
expect(find.byType(SliverVisibility), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility), paints..path());
|
expect(find.byType(SliverVisibility), paints..path());
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 400.0);
|
expect(renderSliver.geometry!.scrollExtent, 400.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
||||||
expect(log, <String>[]);
|
expect(log, <String>[]);
|
||||||
expect(find.byKey(anchor), findsNothing);
|
expect(find.byKey(anchor), findsNothing);
|
||||||
@ -140,8 +138,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility), findsOneWidget);
|
expect(find.byType(SliverVisibility), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility), paints..paragraph());
|
expect(find.byType(SliverVisibility), paints..paragraph());
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 14.0);
|
expect(renderSliver.geometry!.scrollExtent, 14.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
||||||
expect(log, <String>['created new state']);
|
expect(log, <String>['created new state']);
|
||||||
await tester.tap(find.byKey(anchor));
|
await tester.tap(find.byKey(anchor));
|
||||||
@ -163,8 +161,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility), findsOneWidget);
|
expect(find.byType(SliverVisibility), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility), paints..paragraph());
|
expect(find.byType(SliverVisibility), paints..paragraph());
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 14.0);
|
expect(renderSliver.geometry!.scrollExtent, 14.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
||||||
expect(log, <String>['created new state']);
|
expect(log, <String>['created new state']);
|
||||||
await tester.tap(find.byKey(anchor));
|
await tester.tap(find.byKey(anchor));
|
||||||
@ -186,8 +184,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility), findsOneWidget);
|
expect(find.byType(SliverVisibility), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility), paintsNothing);
|
expect(find.byType(SliverVisibility), paintsNothing);
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 14.0);
|
expect(renderSliver.geometry!.scrollExtent, 14.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
||||||
expect(log, <String>[]);
|
expect(log, <String>[]);
|
||||||
await tester.tap(find.byKey(anchor));
|
await tester.tap(find.byKey(anchor));
|
||||||
@ -211,8 +209,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility), findsOneWidget);
|
expect(find.byType(SliverVisibility), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility), paintsNothing);
|
expect(find.byType(SliverVisibility), paintsNothing);
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 14.0);
|
expect(renderSliver.geometry!.scrollExtent, 14.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
||||||
expect(log, <String>[]);
|
expect(log, <String>[]);
|
||||||
@ -234,8 +232,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility), findsOneWidget);
|
expect(find.byType(SliverVisibility), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility), paintsNothing);
|
expect(find.byType(SliverVisibility), paintsNothing);
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 14.0);
|
expect(renderSliver.geometry!.scrollExtent, 14.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
||||||
expect(log, <String>[]);
|
expect(log, <String>[]);
|
||||||
@ -257,8 +255,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility), findsOneWidget);
|
expect(find.byType(SliverVisibility), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility), paintsNothing);
|
expect(find.byType(SliverVisibility), paintsNothing);
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 14.0);
|
expect(renderSliver.geometry!.scrollExtent, 14.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
||||||
expect(log, <String>['created new state']);
|
expect(log, <String>['created new state']);
|
||||||
@ -279,8 +277,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility), findsOneWidget);
|
expect(find.byType(SliverVisibility), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility), paintsNothing);
|
expect(find.byType(SliverVisibility), paintsNothing);
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 14.0);
|
expect(renderSliver.geometry!.scrollExtent, 14.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
||||||
expect(log, <String>[]);
|
expect(log, <String>[]);
|
||||||
@ -301,8 +299,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility, skipOffstage: false), findsOneWidget);
|
expect(find.byType(SliverVisibility, skipOffstage: false), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility, skipOffstage: false), paintsNothing);
|
expect(find.byType(SliverVisibility, skipOffstage: false), paintsNothing);
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 0.0);
|
expect(renderSliver.geometry!.scrollExtent, 0.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
||||||
expect(log, <String>['created new state']);
|
expect(log, <String>['created new state']);
|
||||||
@ -321,8 +319,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility, skipOffstage: false), findsOneWidget);
|
expect(find.byType(SliverVisibility, skipOffstage: false), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility, skipOffstage: false), paintsNothing);
|
expect(find.byType(SliverVisibility, skipOffstage: false), paintsNothing);
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 0.0);
|
expect(renderSliver.geometry!.scrollExtent, 0.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
||||||
expect(log, <String>['created new state']);
|
expect(log, <String>['created new state']);
|
||||||
@ -343,8 +341,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility), findsOneWidget);
|
expect(find.byType(SliverVisibility), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility), paints..paragraph());
|
expect(find.byType(SliverVisibility), paints..paragraph());
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 14.0);
|
expect(renderSliver.geometry!.scrollExtent, 14.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
||||||
expect(log, <String>[]);
|
expect(log, <String>[]);
|
||||||
@ -364,8 +362,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility, skipOffstage: false), findsOneWidget);
|
expect(find.byType(SliverVisibility, skipOffstage: false), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility, skipOffstage: false), paintsNothing);
|
expect(find.byType(SliverVisibility, skipOffstage: false), paintsNothing);
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 0.0);
|
expect(renderSliver.geometry!.scrollExtent, 0.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a false'), hasLength(0));
|
expect(semantics.nodesWith(label: 'a false'), hasLength(0));
|
||||||
expect(log, <String>[]);
|
expect(log, <String>[]);
|
||||||
@ -384,8 +382,8 @@ void main() {
|
|||||||
expect(
|
expect(
|
||||||
find.byType(SliverVisibility, skipOffstage: false), paints..paragraph());
|
find.byType(SliverVisibility, skipOffstage: false), paints..paragraph());
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 14.0);
|
expect(renderSliver.geometry!.scrollExtent, 14.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
||||||
expect(log, <String>[]);
|
expect(log, <String>[]);
|
||||||
@ -405,8 +403,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility, skipOffstage: false), findsOneWidget);
|
expect(find.byType(SliverVisibility, skipOffstage: false), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility, skipOffstage: false), paintsNothing);
|
expect(find.byType(SliverVisibility, skipOffstage: false), paintsNothing);
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 0.0);
|
expect(renderSliver.geometry!.scrollExtent, 0.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a false'), hasLength(0));
|
expect(semantics.nodesWith(label: 'a false'), hasLength(0));
|
||||||
expect(log, <String>[]);
|
expect(log, <String>[]);
|
||||||
@ -424,8 +422,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility, skipOffstage: false), findsOneWidget);
|
expect(find.byType(SliverVisibility, skipOffstage: false), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility, skipOffstage: false), paintsNothing);
|
expect(find.byType(SliverVisibility, skipOffstage: false), paintsNothing);
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 0.0);
|
expect(renderSliver.geometry!.scrollExtent, 0.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
||||||
expect(log, <String>[]);
|
expect(log, <String>[]);
|
||||||
@ -442,8 +440,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility), findsOneWidget);
|
expect(find.byType(SliverVisibility), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility), paints..paragraph());
|
expect(find.byType(SliverVisibility), paints..paragraph());
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 14.0);
|
expect(renderSliver.geometry!.scrollExtent, 14.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
||||||
expect(log, <String>['created new state']);
|
expect(log, <String>['created new state']);
|
||||||
@ -460,8 +458,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility, skipOffstage: false), findsOneWidget);
|
expect(find.byType(SliverVisibility, skipOffstage: false), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility, skipOffstage: false), paintsNothing);
|
expect(find.byType(SliverVisibility, skipOffstage: false), paintsNothing);
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 0.0);
|
expect(renderSliver.geometry!.scrollExtent, 0.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(0));
|
||||||
expect(log, <String>[]);
|
expect(log, <String>[]);
|
||||||
@ -478,8 +476,8 @@ void main() {
|
|||||||
expect(find.byType(SliverVisibility), findsOneWidget);
|
expect(find.byType(SliverVisibility), findsOneWidget);
|
||||||
expect(find.byType(SliverVisibility), paints..paragraph());
|
expect(find.byType(SliverVisibility), paints..paragraph());
|
||||||
renderViewport = tester.renderObject(find.byType(Viewport));
|
renderViewport = tester.renderObject(find.byType(Viewport));
|
||||||
renderSliver = renderViewport.lastChild;
|
renderSliver = renderViewport.lastChild!;
|
||||||
expect(renderSliver.geometry.scrollExtent, 14.0);
|
expect(renderSliver.geometry!.scrollExtent, 14.0);
|
||||||
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
expect(renderSliver.constraints.crossAxisExtent, 800.0);
|
||||||
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
expect(semantics.nodesWith(label: 'a true'), hasLength(1));
|
||||||
expect(log, <String>['created new state']);
|
expect(log, <String>['created new state']);
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -336,15 +334,15 @@ void main() {
|
|||||||
);
|
);
|
||||||
final RenderSliverFloatingPinnedPersistentHeader render = tester.renderObject(find.byType(SliverAppBar));
|
final RenderSliverFloatingPinnedPersistentHeader render = tester.renderObject(find.byType(SliverAppBar));
|
||||||
expect(render.minExtent, greaterThan(availableHeight)); // Precondition
|
expect(render.minExtent, greaterThan(availableHeight)); // Precondition
|
||||||
expect(render.geometry.scrollExtent, 120.0);
|
expect(render.geometry!.scrollExtent, 120.0);
|
||||||
expect(render.geometry.paintExtent, availableHeight);
|
expect(render.geometry!.paintExtent, availableHeight);
|
||||||
expect(render.geometry.layoutExtent, availableHeight);
|
expect(render.geometry!.layoutExtent, availableHeight);
|
||||||
|
|
||||||
controller.jumpTo(200.0);
|
controller.jumpTo(200.0);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(render.geometry.scrollExtent, 120.0);
|
expect(render.geometry!.scrollExtent, 120.0);
|
||||||
expect(render.geometry.paintExtent, availableHeight);
|
expect(render.geometry!.paintExtent, availableHeight);
|
||||||
expect(render.geometry.layoutExtent, 0.0);
|
expect(render.geometry!.layoutExtent, 0.0);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Pinned and floating SliverAppBar sticks to top the content is scroll down', (WidgetTester tester) async {
|
testWidgets('Pinned and floating SliverAppBar sticks to top the content is scroll down', (WidgetTester tester) async {
|
||||||
@ -378,7 +376,7 @@ void main() {
|
|||||||
await gesture.moveBy(const Offset(0, scrollDistance));
|
await gesture.moveBy(const Offset(0, scrollDistance));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
expect(render.geometry.paintOrigin, -scrollDistance);
|
expect(render.geometry!.paintOrigin, -scrollDistance);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Floating SliverAppBar sticks to top the content is scroll down', (WidgetTester tester) async {
|
testWidgets('Floating SliverAppBar sticks to top the content is scroll down', (WidgetTester tester) async {
|
||||||
@ -412,7 +410,7 @@ void main() {
|
|||||||
await gesture.moveBy(const Offset(0, scrollDistance));
|
await gesture.moveBy(const Offset(0, scrollDistance));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
expect(render.geometry.paintOrigin, -scrollDistance);
|
expect(render.geometry!.paintOrigin, -scrollDistance);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Pinned SliverAppBar sticks to top the content is scroll down', (WidgetTester tester) async {
|
testWidgets('Pinned SliverAppBar sticks to top the content is scroll down', (WidgetTester tester) async {
|
||||||
@ -446,6 +444,6 @@ void main() {
|
|||||||
await gesture.moveBy(const Offset(0, scrollDistance));
|
await gesture.moveBy(const Offset(0, scrollDistance));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
expect(render.geometry.paintOrigin, -scrollDistance);
|
expect(render.geometry!.paintOrigin, -scrollDistance);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,19 +2,17 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
void verifyPaintPosition(GlobalKey key, Offset ideal, bool visible) {
|
void verifyPaintPosition(GlobalKey key, Offset ideal, bool visible) {
|
||||||
final RenderSliver target = key.currentContext.findRenderObject() as RenderSliver;
|
final RenderSliver target = key.currentContext!.findRenderObject()! as RenderSliver;
|
||||||
expect(target.parent, isA<RenderViewport>());
|
expect(target.parent, isA<RenderViewport>());
|
||||||
final SliverPhysicalParentData parentData = target.parentData as SliverPhysicalParentData;
|
final SliverPhysicalParentData parentData = target.parentData! as SliverPhysicalParentData;
|
||||||
final Offset actual = parentData.paintOffset;
|
final Offset actual = parentData.paintOffset;
|
||||||
expect(actual, ideal);
|
expect(actual, ideal);
|
||||||
final SliverGeometry geometry = target.geometry;
|
final SliverGeometry geometry = target.geometry!;
|
||||||
expect(geometry.visible, visible);
|
expect(geometry.visible, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +257,7 @@ class RenderBigSliver extends RenderSliver {
|
|||||||
markNeedsLayout();
|
markNeedsLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
double get paintExtent => (height - constraints.scrollOffset).clamp(0.0, constraints.remainingPaintExtent) as double;
|
double get paintExtent => (height - constraints.scrollOffset).clamp(0.0, constraints.remainingPaintExtent);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void performLayout() {
|
void performLayout() {
|
||||||
@ -272,7 +270,7 @@ class RenderBigSliver extends RenderSliver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BigSliver extends LeafRenderObjectWidget {
|
class BigSliver extends LeafRenderObjectWidget {
|
||||||
const BigSliver({ Key key, this.height }) : super(key: key);
|
const BigSliver({ Key? key, required this.height }) : super(key: key);
|
||||||
|
|
||||||
final double height;
|
final double height;
|
||||||
|
|
||||||
|
@ -2,19 +2,17 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
void verifyPaintPosition(GlobalKey key, Offset ideal, bool visible) {
|
void verifyPaintPosition(GlobalKey key, Offset ideal, bool visible) {
|
||||||
final RenderSliver target = key.currentContext.findRenderObject() as RenderSliver;
|
final RenderSliver target = key.currentContext!.findRenderObject()! as RenderSliver;
|
||||||
expect(target.parent, isA<RenderViewport>());
|
expect(target.parent, isA<RenderViewport>());
|
||||||
final SliverPhysicalParentData parentData = target.parentData as SliverPhysicalParentData;
|
final SliverPhysicalParentData parentData = target.parentData! as SliverPhysicalParentData;
|
||||||
final Offset actual = parentData.paintOffset;
|
final Offset actual = parentData.paintOffset;
|
||||||
expect(actual, ideal);
|
expect(actual, ideal);
|
||||||
final SliverGeometry geometry = target.geometry;
|
final SliverGeometry geometry = target.geometry!;
|
||||||
expect(geometry.visible, visible);
|
expect(geometry.visible, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +74,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
await tester.pumpAndSettle(const Duration(milliseconds: 10));
|
await tester.pumpAndSettle(const Duration(milliseconds: 10));
|
||||||
|
|
||||||
final RenderObject renderObject = key.currentContext.findRenderObject();
|
final RenderObject renderObject = key.currentContext!.findRenderObject()!;
|
||||||
// The delegate must only start throwing immediately before calling
|
// The delegate must only start throwing immediately before calling
|
||||||
// toStringDeep to avoid triggering spurious exceptions.
|
// toStringDeep to avoid triggering spurious exceptions.
|
||||||
// If the _RenderSliverPinnedPersistentHeaderForWidgets class was not
|
// If the _RenderSliverPinnedPersistentHeaderForWidgets class was not
|
||||||
@ -348,7 +346,7 @@ class RenderBigSliver extends RenderSliver {
|
|||||||
markNeedsLayout();
|
markNeedsLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
double get paintExtent => (height - constraints.scrollOffset).clamp(0.0, constraints.remainingPaintExtent) as double;
|
double get paintExtent => (height - constraints.scrollOffset).clamp(0.0, constraints.remainingPaintExtent);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void performLayout() {
|
void performLayout() {
|
||||||
@ -361,7 +359,7 @@ class RenderBigSliver extends RenderSliver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BigSliver extends LeafRenderObjectWidget {
|
class BigSliver extends LeafRenderObjectWidget {
|
||||||
const BigSliver({ Key key, this.height }) : super(key: key);
|
const BigSliver({ Key? key, required this.height }) : super(key: key);
|
||||||
|
|
||||||
final double height;
|
final double height;
|
||||||
|
|
||||||
|
@ -2,16 +2,14 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
void verifyPaintPosition(GlobalKey key, Offset ideal) {
|
void verifyPaintPosition(GlobalKey key, Offset ideal) {
|
||||||
final RenderObject target = key.currentContext.findRenderObject();
|
final RenderObject target = key.currentContext!.findRenderObject()!;
|
||||||
expect(target.parent, isA<RenderViewport>());
|
expect(target.parent, isA<RenderViewport>());
|
||||||
final SliverPhysicalParentData parentData = target.parentData as SliverPhysicalParentData;
|
final SliverPhysicalParentData parentData = target.parentData! as SliverPhysicalParentData;
|
||||||
final Offset actual = parentData.paintOffset;
|
final Offset actual = parentData.paintOffset;
|
||||||
expect(actual, ideal);
|
expect(actual, ideal);
|
||||||
}
|
}
|
||||||
@ -160,7 +158,7 @@ class TestDelegate extends SliverPersistentHeaderDelegate {
|
|||||||
|
|
||||||
class RenderBigSliver extends RenderSliver {
|
class RenderBigSliver extends RenderSliver {
|
||||||
static const double height = 550.0;
|
static const double height = 550.0;
|
||||||
double get paintExtent => (height - constraints.scrollOffset).clamp(0.0, constraints.remainingPaintExtent) as double;
|
double get paintExtent => (height - constraints.scrollOffset).clamp(0.0, constraints.remainingPaintExtent);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void performLayout() {
|
void performLayout() {
|
||||||
@ -173,7 +171,7 @@ class RenderBigSliver extends RenderSliver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BigSliver extends LeafRenderObjectWidget {
|
class BigSliver extends LeafRenderObjectWidget {
|
||||||
const BigSliver({ Key key }) : super(key: key);
|
const BigSliver({ Key? key }) : super(key: key);
|
||||||
@override
|
@override
|
||||||
RenderBigSliver createRenderObject(BuildContext context) {
|
RenderBigSliver createRenderObject(BuildContext context) {
|
||||||
return RenderBigSliver();
|
return RenderBigSliver();
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
@ -41,9 +39,9 @@ void main() {
|
|||||||
final RenderSliverScrollingPersistentHeader header = tester.renderObject(
|
final RenderSliverScrollingPersistentHeader header = tester.renderObject(
|
||||||
find.byType(SliverAppBar)
|
find.byType(SliverAppBar)
|
||||||
);
|
);
|
||||||
expect(header.child.size.height, equals(100.0));
|
expect(header.child!.size.height, equals(100.0));
|
||||||
await slowDrag(tester, anchor, const Offset(0.0, 100));
|
await slowDrag(tester, anchor, const Offset(0.0, 100));
|
||||||
expect(header.child.size.height, equals(200.0));
|
expect(header.child!.size.height, equals(200.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('does not stretch without overscroll physics', (WidgetTester tester) async {
|
testWidgets('does not stretch without overscroll physics', (WidgetTester tester) async {
|
||||||
@ -76,9 +74,9 @@ void main() {
|
|||||||
final RenderSliverScrollingPersistentHeader header = tester.renderObject(
|
final RenderSliverScrollingPersistentHeader header = tester.renderObject(
|
||||||
find.byType(SliverAppBar)
|
find.byType(SliverAppBar)
|
||||||
);
|
);
|
||||||
expect(header.child.size.height, equals(100.0));
|
expect(header.child!.size.height, equals(100.0));
|
||||||
await slowDrag(tester, anchor, const Offset(0.0, 100.0));
|
await slowDrag(tester, anchor, const Offset(0.0, 100.0));
|
||||||
expect(header.child.size.height, equals(100.0));
|
expect(header.child!.size.height, equals(100.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('default trigger offset', (WidgetTester tester) async {
|
testWidgets('default trigger offset', (WidgetTester tester) async {
|
||||||
@ -92,9 +90,8 @@ void main() {
|
|||||||
SliverAppBar(
|
SliverAppBar(
|
||||||
stretch: true,
|
stretch: true,
|
||||||
expandedHeight: 100.0,
|
expandedHeight: 100.0,
|
||||||
onStretchTrigger: () {
|
onStretchTrigger: () async {
|
||||||
didTrigger = true;
|
didTrigger = true;
|
||||||
return;
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
@ -132,9 +129,8 @@ void main() {
|
|||||||
stretch: true,
|
stretch: true,
|
||||||
expandedHeight: 100.0,
|
expandedHeight: 100.0,
|
||||||
stretchTriggerOffset: 150.0,
|
stretchTriggerOffset: 150.0,
|
||||||
onStretchTrigger: () {
|
onStretchTrigger: () async {
|
||||||
didTrigger = true;
|
didTrigger = true;
|
||||||
return;
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
@ -172,9 +168,8 @@ void main() {
|
|||||||
stretch: true,
|
stretch: true,
|
||||||
expandedHeight: 100.0,
|
expandedHeight: 100.0,
|
||||||
stretchTriggerOffset: 150.0,
|
stretchTriggerOffset: 150.0,
|
||||||
onStretchTrigger: () {
|
onStretchTrigger: () async {
|
||||||
didTrigger = true;
|
didTrigger = true;
|
||||||
return;
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
@ -200,35 +195,6 @@ void main() {
|
|||||||
expect(didTrigger, isFalse);
|
expect(didTrigger, isFalse);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('asserts stretch != null', (WidgetTester tester) async {
|
|
||||||
expect(
|
|
||||||
() {
|
|
||||||
return MaterialApp(
|
|
||||||
home: CustomScrollView(
|
|
||||||
physics: const ClampingScrollPhysics(),
|
|
||||||
slivers: <Widget>[
|
|
||||||
SliverAppBar(
|
|
||||||
stretch: null,
|
|
||||||
expandedHeight: 100.0,
|
|
||||||
),
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: Container(
|
|
||||||
height: 800,
|
|
||||||
)
|
|
||||||
),
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: Container(
|
|
||||||
height: 800,
|
|
||||||
)
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
throwsAssertionError,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('asserts reasonable trigger offset', (WidgetTester tester) async {
|
testWidgets('asserts reasonable trigger offset', (WidgetTester tester) async {
|
||||||
expect(
|
expect(
|
||||||
() {
|
() {
|
||||||
@ -291,9 +257,9 @@ void main() {
|
|||||||
final RenderSliverPinnedPersistentHeader header = tester.renderObject(
|
final RenderSliverPinnedPersistentHeader header = tester.renderObject(
|
||||||
find.byType(SliverAppBar)
|
find.byType(SliverAppBar)
|
||||||
);
|
);
|
||||||
expect(header.child.size.height, equals(100.0));
|
expect(header.child!.size.height, equals(100.0));
|
||||||
await slowDrag(tester, anchor, const Offset(0.0, 100));
|
await slowDrag(tester, anchor, const Offset(0.0, 100));
|
||||||
expect(header.child.size.height, equals(200.0));
|
expect(header.child!.size.height, equals(200.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('does not stretch without overscroll physics', (WidgetTester tester) async {
|
testWidgets('does not stretch without overscroll physics', (WidgetTester tester) async {
|
||||||
@ -326,9 +292,9 @@ void main() {
|
|||||||
final RenderSliverPinnedPersistentHeader header = tester.renderObject(
|
final RenderSliverPinnedPersistentHeader header = tester.renderObject(
|
||||||
find.byType(SliverAppBar)
|
find.byType(SliverAppBar)
|
||||||
);
|
);
|
||||||
expect(header.child.size.height, equals(100.0));
|
expect(header.child!.size.height, equals(100.0));
|
||||||
await slowDrag(tester, anchor, const Offset(0.0, 100));
|
await slowDrag(tester, anchor, const Offset(0.0, 100));
|
||||||
expect(header.child.size.height, equals(100.0));
|
expect(header.child!.size.height, equals(100.0));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -363,9 +329,9 @@ void main() {
|
|||||||
final RenderSliverFloatingPersistentHeader header = tester.renderObject(
|
final RenderSliverFloatingPersistentHeader header = tester.renderObject(
|
||||||
find.byType(SliverAppBar)
|
find.byType(SliverAppBar)
|
||||||
);
|
);
|
||||||
expect(header.child.size.height, equals(100.0));
|
expect(header.child!.size.height, equals(100.0));
|
||||||
await slowDrag(tester, anchor, const Offset(0.0, 100));
|
await slowDrag(tester, anchor, const Offset(0.0, 100));
|
||||||
expect(header.child.size.height, equals(200.0));
|
expect(header.child!.size.height, equals(200.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('does not fill overscroll without proper physics', (WidgetTester tester) async {
|
testWidgets('does not fill overscroll without proper physics', (WidgetTester tester) async {
|
||||||
@ -398,9 +364,9 @@ void main() {
|
|||||||
final RenderSliverFloatingPersistentHeader header = tester.renderObject(
|
final RenderSliverFloatingPersistentHeader header = tester.renderObject(
|
||||||
find.byType(SliverAppBar)
|
find.byType(SliverAppBar)
|
||||||
);
|
);
|
||||||
expect(header.child.size.height, equals(100.0));
|
expect(header.child!.size.height, equals(100.0));
|
||||||
await slowDrag(tester, anchor, const Offset(0.0, 100));
|
await slowDrag(tester, anchor, const Offset(0.0, 100));
|
||||||
expect(header.child.size.height, equals(100.0));
|
expect(header.child!.size.height, equals(100.0));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -436,9 +402,9 @@ void main() {
|
|||||||
final RenderSliverFloatingPinnedPersistentHeader header = tester.renderObject(
|
final RenderSliverFloatingPinnedPersistentHeader header = tester.renderObject(
|
||||||
find.byType(SliverAppBar)
|
find.byType(SliverAppBar)
|
||||||
);
|
);
|
||||||
expect(header.child.size.height, equals(100.0));
|
expect(header.child!.size.height, equals(100.0));
|
||||||
await slowDrag(tester, anchor, const Offset(0.0, 100));
|
await slowDrag(tester, anchor, const Offset(0.0, 100));
|
||||||
expect(header.child.size.height, equals(200.0));
|
expect(header.child!.size.height, equals(200.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('does not fill overscroll without proper physics', (WidgetTester tester) async {
|
testWidgets('does not fill overscroll without proper physics', (WidgetTester tester) async {
|
||||||
@ -472,9 +438,9 @@ void main() {
|
|||||||
final RenderSliverFloatingPinnedPersistentHeader header = tester.renderObject(
|
final RenderSliverFloatingPinnedPersistentHeader header = tester.renderObject(
|
||||||
find.byType(SliverAppBar)
|
find.byType(SliverAppBar)
|
||||||
);
|
);
|
||||||
expect(header.child.size.height, equals(100.0));
|
expect(header.child!.size.height, equals(100.0));
|
||||||
await slowDrag(tester, anchor, const Offset(0.0, 100));
|
await slowDrag(tester, anchor, const Offset(0.0, 100));
|
||||||
expect(header.child.size.height, equals(100.0));
|
expect(header.child!.size.height, equals(100.0));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@ -11,7 +9,7 @@ import 'package:flutter/widgets.dart';
|
|||||||
int globalGeneration = 0;
|
int globalGeneration = 0;
|
||||||
|
|
||||||
class GenerationText extends StatefulWidget {
|
class GenerationText extends StatefulWidget {
|
||||||
const GenerationText(this.value, { Key key }) : super(key: key);
|
const GenerationText(this.value, { Key? key }) : super(key: key);
|
||||||
final int value;
|
final int value;
|
||||||
@override
|
@override
|
||||||
_GenerationTextState createState() => _GenerationTextState();
|
_GenerationTextState createState() => _GenerationTextState();
|
||||||
@ -55,7 +53,7 @@ void verify(WidgetTester tester, List<Offset> answerKey, String text) {
|
|||||||
expect(testAnswers, equals(answerKey));
|
expect(testAnswers, equals(answerKey));
|
||||||
final String foundText =
|
final String foundText =
|
||||||
tester.widgetList<Text>(find.byType(Text))
|
tester.widgetList<Text>(find.byType(Text))
|
||||||
.map<String>((Text widget) => widget.data)
|
.map<String>((Text widget) => widget.data!)
|
||||||
.reduce((String value, String element) => value + element);
|
.reduce((String value, String element) => value + element);
|
||||||
expect(foundText, equals(text));
|
expect(foundText, equals(text));
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@ -61,7 +59,7 @@ void verify(WidgetTester tester, List<Offset> answerKey, String text) {
|
|||||||
expect(testAnswers, equals(answerKey));
|
expect(testAnswers, equals(answerKey));
|
||||||
final String foundText =
|
final String foundText =
|
||||||
tester.widgetList<Text>(find.byType(Text))
|
tester.widgetList<Text>(find.byType(Text))
|
||||||
.map<String>((Text widget) => widget.data)
|
.map<String>((Text widget) => widget.data!)
|
||||||
.reduce((String value, String element) => value + element);
|
.reduce((String value, String element) => value + element);
|
||||||
expect(foundText, equals(text));
|
expect(foundText, equals(text));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user