parent
8ba5732c4c
commit
dfc6c4386a
@ -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';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('Intrinsic stepWidth, stepHeight', (WidgetTester tester) async {
|
testWidgets('Intrinsic stepWidth, stepHeight', (WidgetTester tester) async {
|
||||||
// Regression test for https://github.com/flutter/flutter/issues/25224
|
// Regression test for https://github.com/flutter/flutter/issues/25224
|
||||||
Widget buildFrame(double stepWidth, double stepHeight) {
|
Widget buildFrame(double? stepWidth, double? stepHeight) {
|
||||||
return Center(
|
return Center(
|
||||||
child: IntrinsicWidth(
|
child: IntrinsicWidth(
|
||||||
stepWidth: stepWidth,
|
stepWidth: stepWidth,
|
||||||
|
@ -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/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
@ -49,13 +47,13 @@ void main() {
|
|||||||
// and [invertColors] applied for testing the invert colors.
|
// and [invertColors] applied for testing the invert colors.
|
||||||
class InvertColorTestWidget extends LeafRenderObjectWidget {
|
class InvertColorTestWidget extends LeafRenderObjectWidget {
|
||||||
const InvertColorTestWidget({
|
const InvertColorTestWidget({
|
||||||
this.color,
|
required this.color,
|
||||||
this.filter,
|
this.filter,
|
||||||
Key key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Color color;
|
final Color color;
|
||||||
final ColorFilter filter;
|
final ColorFilter? filter;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
RenderInvertColorTest createRenderObject(BuildContext context) {
|
RenderInvertColorTest createRenderObject(BuildContext context) {
|
||||||
@ -83,9 +81,9 @@ class RenderInvertColorTest extends RenderProxyBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ColorFilter get filter => _filter;
|
ColorFilter? get filter => _filter;
|
||||||
ColorFilter _filter;
|
ColorFilter? _filter;
|
||||||
set filter(ColorFilter value) {
|
set filter(ColorFilter? value) {
|
||||||
if (filter == value)
|
if (filter == value)
|
||||||
return;
|
return;
|
||||||
_filter = value;
|
_filter = value;
|
||||||
|
@ -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') // diagnostics use Platform.operatingSystem.
|
@TestOn('!chrome') // diagnostics use Platform.operatingSystem.
|
||||||
import 'dart:io' show Platform;
|
import 'dart:io' show Platform;
|
||||||
|
|
||||||
@ -11,7 +9,10 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
class Leaf extends StatefulWidget {
|
class Leaf extends StatefulWidget {
|
||||||
const Leaf({ Key key, this.child }) : super(key: key);
|
const Leaf({
|
||||||
|
Key? key,
|
||||||
|
required this.child,
|
||||||
|
}) : super(key: key);
|
||||||
final Widget child;
|
final Widget child;
|
||||||
@override
|
@override
|
||||||
_LeafState createState() => _LeafState();
|
_LeafState createState() => _LeafState();
|
||||||
@ -73,7 +74,7 @@ void main() {
|
|||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsOneWidget);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(61)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(61)), findsOneWidget);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
|
||||||
const GlobalObjectKey<_LeafState>(60).currentState.setKeepAlive(true);
|
const GlobalObjectKey<_LeafState>(60).currentState!.setKeepAlive(true);
|
||||||
await tester.drag(find.byType(ListView), const Offset(0.0, 300.0)); // back to top
|
await tester.drag(find.byType(ListView), const Offset(0.0, 300.0)); // back to top
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
|
||||||
@ -83,7 +84,7 @@ void main() {
|
|||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsNothing);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsNothing);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
|
||||||
const GlobalObjectKey<_LeafState>(60).currentState.setKeepAlive(false);
|
const GlobalObjectKey<_LeafState>(60).currentState!.setKeepAlive(false);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
|
||||||
@ -120,7 +121,7 @@ void main() {
|
|||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsOneWidget);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(61)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(61)), findsOneWidget);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
|
||||||
const GlobalObjectKey<_LeafState>(60).currentState.setKeepAlive(true);
|
const GlobalObjectKey<_LeafState>(60).currentState!.setKeepAlive(true);
|
||||||
await tester.drag(find.byType(ListView), const Offset(0.0, 300.0)); // back to top
|
await tester.drag(find.byType(ListView), const Offset(0.0, 300.0)); // back to top
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
|
||||||
@ -130,7 +131,7 @@ void main() {
|
|||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsNothing);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsNothing);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
|
||||||
const GlobalObjectKey<_LeafState>(60).currentState.setKeepAlive(false);
|
const GlobalObjectKey<_LeafState>(60).currentState!.setKeepAlive(false);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
|
||||||
@ -169,7 +170,7 @@ void main() {
|
|||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsOneWidget);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(61)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(61)), findsOneWidget);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
|
||||||
const GlobalObjectKey<_LeafState>(60).currentState.setKeepAlive(true);
|
const GlobalObjectKey<_LeafState>(60).currentState!.setKeepAlive(true);
|
||||||
await tester.drag(find.byType(GridView), const Offset(0.0, 300.0)); // back to top
|
await tester.drag(find.byType(GridView), const Offset(0.0, 300.0)); // back to top
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
|
||||||
@ -179,7 +180,7 @@ void main() {
|
|||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsNothing);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsNothing);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
|
||||||
const GlobalObjectKey<_LeafState>(60).currentState.setKeepAlive(false);
|
const GlobalObjectKey<_LeafState>(60).currentState!.setKeepAlive(false);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
|
||||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
|
expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
|
||||||
@ -345,10 +346,10 @@ void main() {
|
|||||||
' constraints: BoxConstraints(w=800.0, h=400.0)\n'
|
' constraints: BoxConstraints(w=800.0, h=400.0)\n'
|
||||||
' size: Size(800.0, 400.0)\n'
|
' size: Size(800.0, 400.0)\n'
|
||||||
));
|
));
|
||||||
const GlobalObjectKey<_LeafState>(0).currentState.setKeepAlive(true);
|
const GlobalObjectKey<_LeafState>(0).currentState!.setKeepAlive(true);
|
||||||
await tester.drag(find.byType(ListView), const Offset(0.0, -1000.0));
|
await tester.drag(find.byType(ListView), const Offset(0.0, -1000.0));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
const GlobalObjectKey<_LeafState>(3).currentState.setKeepAlive(true);
|
const GlobalObjectKey<_LeafState>(3).currentState!.setKeepAlive(true);
|
||||||
await tester.drag(find.byType(ListView), const Offset(0.0, -1000.0));
|
await tester.drag(find.byType(ListView), const Offset(0.0, -1000.0));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(tester.binding.renderView.toStringDeep(minLevel: DiagnosticLevel.info), equalsIgnoringHashCodes(
|
expect(tester.binding.renderView.toStringDeep(minLevel: DiagnosticLevel.info), equalsIgnoringHashCodes(
|
||||||
|
@ -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,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/src/rendering/sliver.dart';
|
import 'package:flutter/src/rendering/sliver.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';
|
||||||
|
|
||||||
class Wrapper extends StatelessWidget {
|
class Wrapper extends StatelessWidget {
|
||||||
const Wrapper({
|
const Wrapper({
|
||||||
Key key,
|
Key? key,
|
||||||
this.child,
|
required this.child,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
@ -22,8 +20,8 @@ class Wrapper extends StatelessWidget {
|
|||||||
|
|
||||||
class StatefulWrapper extends StatefulWidget {
|
class StatefulWrapper extends StatefulWidget {
|
||||||
const StatefulWrapper({
|
const StatefulWrapper({
|
||||||
Key key,
|
Key? key,
|
||||||
this.child,
|
required this.child,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
@ -54,7 +52,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
key.currentState.trigger();
|
key.currentState!.trigger();
|
||||||
return StatefulWrapper(key: key, child: Container(height: 100.0));
|
return StatefulWrapper(key: key, child: Container(height: 100.0));
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -89,7 +87,7 @@ void main() {
|
|||||||
slivers: <Widget>[
|
slivers: <Widget>[
|
||||||
SliverLayoutBuilder(
|
SliverLayoutBuilder(
|
||||||
builder: (BuildContext context, SliverConstraints constraint) {
|
builder: (BuildContext context, SliverConstraints constraint) {
|
||||||
key.currentState.trigger();
|
key.currentState!.trigger();
|
||||||
return SliverToBoxAdapter(
|
return SliverToBoxAdapter(
|
||||||
child: StatefulWrapper(key: key, child: Container(height: 100.0)),
|
child: StatefulWrapper(key: key, child: Container(height: 100.0)),
|
||||||
);
|
);
|
||||||
|
@ -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';
|
||||||
|
|
||||||
class SizeChanger extends StatefulWidget {
|
class SizeChanger extends StatefulWidget {
|
||||||
const SizeChanger({
|
const SizeChanger({
|
||||||
Key key,
|
Key? key,
|
||||||
this.child,
|
required this.child,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
@ -45,8 +43,8 @@ class SizeChangerState extends State<SizeChanger> {
|
|||||||
|
|
||||||
class Wrapper extends StatelessWidget {
|
class Wrapper extends StatelessWidget {
|
||||||
const Wrapper({
|
const Wrapper({
|
||||||
Key key,
|
Key? key,
|
||||||
this.child,
|
required this.child,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
@ -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';
|
||||||
import 'test_widgets.dart';
|
import 'test_widgets.dart';
|
||||||
|
|
||||||
class StatefulWrapper extends StatefulWidget {
|
class StatefulWrapper extends StatefulWidget {
|
||||||
const StatefulWrapper({
|
const StatefulWrapper({
|
||||||
Key key,
|
Key? key,
|
||||||
this.child,
|
required this.child,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
@ -37,8 +35,8 @@ class StatefulWrapperState extends State<StatefulWrapper> {
|
|||||||
|
|
||||||
class Wrapper extends StatelessWidget {
|
class Wrapper extends StatelessWidget {
|
||||||
const Wrapper({
|
const Wrapper({
|
||||||
Key key,
|
Key? key,
|
||||||
this.child,
|
required this.child,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
@ -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/src/rendering/sliver.dart';
|
import 'package:flutter/src/rendering/sliver.dart';
|
||||||
import 'package:flutter/src/widgets/basic.dart';
|
import 'package:flutter/src/widgets/basic.dart';
|
||||||
import 'package:flutter/src/widgets/framework.dart';
|
import 'package:flutter/src/widgets/framework.dart';
|
||||||
@ -14,8 +12,8 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
|
|
||||||
class Wrapper extends StatelessWidget {
|
class Wrapper extends StatelessWidget {
|
||||||
const Wrapper({
|
const Wrapper({
|
||||||
Key key,
|
Key? key,
|
||||||
@required this.child,
|
required this.child,
|
||||||
}) : assert(child != null),
|
}) : assert(child != null),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
|
@ -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/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('LayoutBuilder parent size', (WidgetTester tester) async {
|
testWidgets('LayoutBuilder parent size', (WidgetTester tester) async {
|
||||||
Size layoutBuilderSize;
|
late Size layoutBuilderSize;
|
||||||
final Key childKey = UniqueKey();
|
final Key childKey = UniqueKey();
|
||||||
final Key parentKey = UniqueKey();
|
final Key parentKey = UniqueKey();
|
||||||
|
|
||||||
@ -41,8 +39,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('SliverLayoutBuilder parent geometry', (WidgetTester tester) async {
|
testWidgets('SliverLayoutBuilder parent geometry', (WidgetTester tester) async {
|
||||||
SliverConstraints parentConstraints1;
|
late SliverConstraints parentConstraints1;
|
||||||
SliverConstraints parentConstraints2;
|
late SliverConstraints parentConstraints2;
|
||||||
final Key childKey1 = UniqueKey();
|
final Key childKey1 = UniqueKey();
|
||||||
final Key parentKey1 = UniqueKey();
|
final Key parentKey1 = UniqueKey();
|
||||||
final Key childKey2 = UniqueKey();
|
final Key childKey2 = UniqueKey();
|
||||||
@ -81,8 +79,8 @@ void main() {
|
|||||||
final RenderSliver parentSliver2 = tester.renderObject(find.byKey(parentKey2));
|
final RenderSliver parentSliver2 = tester.renderObject(find.byKey(parentKey2));
|
||||||
|
|
||||||
// scrollExtent == top + bottom.
|
// scrollExtent == top + bottom.
|
||||||
expect(parentSliver1.geometry.scrollExtent, 2 + 4);
|
expect(parentSliver1.geometry!.scrollExtent, 2 + 4);
|
||||||
expect(parentSliver2.geometry.scrollExtent, 7 + 13);
|
expect(parentSliver2.geometry!.scrollExtent, 7 + 13);
|
||||||
|
|
||||||
final RenderSliver childSliver1 = tester.renderObject(find.byKey(childKey1));
|
final RenderSliver childSliver1 = tester.renderObject(find.byKey(childKey1));
|
||||||
final RenderSliver childSliver2 = tester.renderObject(find.byKey(childKey2));
|
final RenderSliver childSliver2 = tester.renderObject(find.byKey(childKey2));
|
||||||
@ -91,8 +89,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('LayoutBuilder stateful child', (WidgetTester tester) async {
|
testWidgets('LayoutBuilder stateful child', (WidgetTester tester) async {
|
||||||
Size layoutBuilderSize;
|
late Size layoutBuilderSize;
|
||||||
StateSetter setState;
|
late StateSetter setState;
|
||||||
final Key childKey = UniqueKey();
|
final Key childKey = UniqueKey();
|
||||||
final Key parentKey = UniqueKey();
|
final Key parentKey = UniqueKey();
|
||||||
double childWidth = 10.0;
|
double childWidth = 10.0;
|
||||||
@ -137,7 +135,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('SliverLayoutBuilder stateful descendants', (WidgetTester tester) async {
|
testWidgets('SliverLayoutBuilder stateful descendants', (WidgetTester tester) async {
|
||||||
StateSetter setState;
|
late StateSetter setState;
|
||||||
double childWidth = 10.0;
|
double childWidth = 10.0;
|
||||||
double childHeight = 20.0;
|
double childHeight = 20.0;
|
||||||
final Key parentKey = UniqueKey();
|
final Key parentKey = UniqueKey();
|
||||||
@ -174,8 +172,8 @@ void main() {
|
|||||||
RenderSliver parentSliver = tester.renderObject(find.byKey(parentKey));
|
RenderSliver parentSliver = tester.renderObject(find.byKey(parentKey));
|
||||||
expect(childBox.size.width, 800);
|
expect(childBox.size.width, 800);
|
||||||
expect(childBox.size.height, childHeight);
|
expect(childBox.size.height, childHeight);
|
||||||
expect(parentSliver.geometry.scrollExtent, childHeight);
|
expect(parentSliver.geometry!.scrollExtent, childHeight);
|
||||||
expect(parentSliver.geometry.paintExtent, childHeight);
|
expect(parentSliver.geometry!.paintExtent, childHeight);
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
childWidth = 100.0;
|
childWidth = 100.0;
|
||||||
@ -187,8 +185,8 @@ void main() {
|
|||||||
parentSliver = tester.renderObject(find.byKey(parentKey));
|
parentSliver = tester.renderObject(find.byKey(parentKey));
|
||||||
expect(childBox.size.width, 800);
|
expect(childBox.size.width, 800);
|
||||||
expect(childBox.size.height, childHeight);
|
expect(childBox.size.height, childHeight);
|
||||||
expect(parentSliver.geometry.scrollExtent, childHeight);
|
expect(parentSliver.geometry!.scrollExtent, childHeight);
|
||||||
expect(parentSliver.geometry.paintExtent, childHeight);
|
expect(parentSliver.geometry!.paintExtent, childHeight);
|
||||||
|
|
||||||
// Make child wider and higher than the viewport.
|
// Make child wider and higher than the viewport.
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -201,13 +199,13 @@ void main() {
|
|||||||
parentSliver = tester.renderObject(find.byKey(parentKey));
|
parentSliver = tester.renderObject(find.byKey(parentKey));
|
||||||
expect(childBox.size.width, 800);
|
expect(childBox.size.width, 800);
|
||||||
expect(childBox.size.height, childHeight);
|
expect(childBox.size.height, childHeight);
|
||||||
expect(parentSliver.geometry.scrollExtent, childHeight);
|
expect(parentSliver.geometry!.scrollExtent, childHeight);
|
||||||
expect(parentSliver.geometry.paintExtent, 600);
|
expect(parentSliver.geometry!.paintExtent, 600);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('LayoutBuilder stateful parent', (WidgetTester tester) async {
|
testWidgets('LayoutBuilder stateful parent', (WidgetTester tester) async {
|
||||||
Size layoutBuilderSize;
|
late Size layoutBuilderSize;
|
||||||
StateSetter setState;
|
late StateSetter setState;
|
||||||
final Key childKey = UniqueKey();
|
final Key childKey = UniqueKey();
|
||||||
double childWidth = 10.0;
|
double childWidth = 10.0;
|
||||||
double childHeight = 20.0;
|
double childHeight = 20.0;
|
||||||
@ -362,8 +360,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('nested SliverLayoutBuilder', (WidgetTester tester) async {
|
testWidgets('nested SliverLayoutBuilder', (WidgetTester tester) async {
|
||||||
SliverConstraints parentConstraints1;
|
late SliverConstraints parentConstraints1;
|
||||||
SliverConstraints parentConstraints2;
|
late SliverConstraints parentConstraints2;
|
||||||
final Key childKey = UniqueKey();
|
final Key childKey = UniqueKey();
|
||||||
final Key parentKey1 = UniqueKey();
|
final Key parentKey1 = UniqueKey();
|
||||||
final Key parentKey2 = UniqueKey();
|
final Key parentKey2 = UniqueKey();
|
||||||
@ -399,7 +397,7 @@ void main() {
|
|||||||
final RenderSliver parentSliver1 = tester.renderObject(find.byKey(parentKey1));
|
final RenderSliver parentSliver1 = tester.renderObject(find.byKey(parentKey1));
|
||||||
final RenderSliver parentSliver2 = tester.renderObject(find.byKey(parentKey2));
|
final RenderSliver parentSliver2 = tester.renderObject(find.byKey(parentKey2));
|
||||||
// scrollExtent == top + bottom.
|
// scrollExtent == top + bottom.
|
||||||
expect(parentSliver1.geometry.scrollExtent, 2 + 4);
|
expect(parentSliver1.geometry!.scrollExtent, 2 + 4);
|
||||||
|
|
||||||
final RenderSliver childSliver = tester.renderObject(find.byKey(childKey));
|
final RenderSliver childSliver = tester.renderObject(find.byKey(childKey));
|
||||||
expect(childSliver.geometry, parentSliver1.geometry);
|
expect(childSliver.geometry, parentSliver1.geometry);
|
||||||
|
@ -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
|
|
||||||
|
|
||||||
// This file contains a wacky demonstration of creating a custom ScrollPosition
|
// This file contains a wacky demonstration of creating a custom ScrollPosition
|
||||||
// setup. It's testing that we don't regress the factoring of the
|
// setup. It's testing that we don't regress the factoring of the
|
||||||
// ScrollPosition/ScrollActivity logic into a state where you can no longer
|
// ScrollPosition/ScrollActivity logic into a state where you can no longer
|
||||||
@ -21,18 +19,18 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
class LinkedScrollController extends ScrollController {
|
class LinkedScrollController extends ScrollController {
|
||||||
LinkedScrollController({ this.before, this.after });
|
LinkedScrollController({ this.before, this.after });
|
||||||
|
|
||||||
LinkedScrollController before;
|
LinkedScrollController? before;
|
||||||
LinkedScrollController after;
|
LinkedScrollController? after;
|
||||||
|
|
||||||
ScrollController _parent;
|
ScrollController? _parent;
|
||||||
|
|
||||||
void setParent(ScrollController newParent) {
|
void setParent(ScrollController? newParent) {
|
||||||
if (_parent != null) {
|
if (_parent != null) {
|
||||||
positions.forEach(_parent.detach);
|
positions.forEach(_parent!.detach);
|
||||||
}
|
}
|
||||||
_parent = newParent;
|
_parent = newParent;
|
||||||
if (_parent != null) {
|
if (_parent != null) {
|
||||||
positions.forEach(_parent.attach);
|
positions.forEach(_parent!.attach);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,13 +52,13 @@ class LinkedScrollController extends ScrollController {
|
|||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
if (_parent != null) {
|
if (_parent != null) {
|
||||||
positions.forEach(_parent.detach);
|
positions.forEach(_parent!.detach);
|
||||||
}
|
}
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
LinkedScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition oldPosition) {
|
LinkedScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition? oldPosition) {
|
||||||
return LinkedScrollPosition(
|
return LinkedScrollPosition(
|
||||||
this,
|
this,
|
||||||
physics: physics,
|
physics: physics,
|
||||||
@ -70,18 +68,18 @@ class LinkedScrollController extends ScrollController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get canLinkWithBefore => before != null && before.hasClients;
|
bool get canLinkWithBefore => before != null && before!.hasClients;
|
||||||
|
|
||||||
bool get canLinkWithAfter => after != null && after.hasClients;
|
bool get canLinkWithAfter => after != null && after!.hasClients;
|
||||||
|
|
||||||
Iterable<LinkedScrollActivity> linkWithBefore(LinkedScrollPosition driver) {
|
Iterable<LinkedScrollActivity> linkWithBefore(LinkedScrollPosition driver) {
|
||||||
assert(canLinkWithBefore);
|
assert(canLinkWithBefore);
|
||||||
return before.link(driver);
|
return before!.link(driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterable<LinkedScrollActivity> linkWithAfter(LinkedScrollPosition driver) {
|
Iterable<LinkedScrollActivity> linkWithAfter(LinkedScrollPosition driver) {
|
||||||
assert(canLinkWithAfter);
|
assert(canLinkWithAfter);
|
||||||
return after.link(driver);
|
return after!.link(driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterable<LinkedScrollActivity> link(LinkedScrollPosition driver) sync* {
|
Iterable<LinkedScrollActivity> link(LinkedScrollPosition driver) sync* {
|
||||||
@ -109,10 +107,10 @@ class LinkedScrollController extends ScrollController {
|
|||||||
class LinkedScrollPosition extends ScrollPositionWithSingleContext {
|
class LinkedScrollPosition extends ScrollPositionWithSingleContext {
|
||||||
LinkedScrollPosition(
|
LinkedScrollPosition(
|
||||||
this.owner, {
|
this.owner, {
|
||||||
ScrollPhysics physics,
|
required ScrollPhysics physics,
|
||||||
ScrollContext context,
|
required ScrollContext context,
|
||||||
double initialPixels,
|
required double initialPixels,
|
||||||
ScrollPosition oldPosition,
|
ScrollPosition? oldPosition,
|
||||||
}) : assert(owner != null),
|
}) : assert(owner != null),
|
||||||
super(
|
super(
|
||||||
physics: physics,
|
physics: physics,
|
||||||
@ -123,22 +121,22 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext {
|
|||||||
|
|
||||||
final LinkedScrollController owner;
|
final LinkedScrollController owner;
|
||||||
|
|
||||||
Set<LinkedScrollActivity> _beforeActivities;
|
Set<LinkedScrollActivity>? _beforeActivities;
|
||||||
Set<LinkedScrollActivity> _afterActivities;
|
Set<LinkedScrollActivity>? _afterActivities;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void beginActivity(ScrollActivity newActivity) {
|
void beginActivity(ScrollActivity? newActivity) {
|
||||||
if (newActivity == null)
|
if (newActivity == null)
|
||||||
return;
|
return;
|
||||||
if (_beforeActivities != null) {
|
if (_beforeActivities != null) {
|
||||||
for (final LinkedScrollActivity activity in _beforeActivities)
|
for (final LinkedScrollActivity activity in _beforeActivities!)
|
||||||
activity.unlink(this);
|
activity.unlink(this);
|
||||||
_beforeActivities.clear();
|
_beforeActivities!.clear();
|
||||||
}
|
}
|
||||||
if (_afterActivities != null) {
|
if (_afterActivities != null) {
|
||||||
for (final LinkedScrollActivity activity in _afterActivities)
|
for (final LinkedScrollActivity activity in _afterActivities!)
|
||||||
activity.unlink(this);
|
activity.unlink(this);
|
||||||
_afterActivities.clear();
|
_afterActivities!.clear();
|
||||||
}
|
}
|
||||||
super.beginActivity(newActivity);
|
super.beginActivity(newActivity);
|
||||||
}
|
}
|
||||||
@ -155,8 +153,8 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext {
|
|||||||
if (owner.canLinkWithBefore && (value < minScrollExtent)) {
|
if (owner.canLinkWithBefore && (value < minScrollExtent)) {
|
||||||
final double delta = value - minScrollExtent;
|
final double delta = value - minScrollExtent;
|
||||||
_beforeActivities ??= HashSet<LinkedScrollActivity>();
|
_beforeActivities ??= HashSet<LinkedScrollActivity>();
|
||||||
_beforeActivities.addAll(owner.linkWithBefore(this));
|
_beforeActivities!.addAll(owner.linkWithBefore(this));
|
||||||
for (final LinkedScrollActivity activity in _beforeActivities)
|
for (final LinkedScrollActivity activity in _beforeActivities!)
|
||||||
beforeOverscroll = math.min(activity.moveBy(delta), beforeOverscroll);
|
beforeOverscroll = math.min(activity.moveBy(delta), beforeOverscroll);
|
||||||
assert(beforeOverscroll <= 0.0);
|
assert(beforeOverscroll <= 0.0);
|
||||||
}
|
}
|
||||||
@ -165,8 +163,8 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext {
|
|||||||
if (owner.canLinkWithAfter && (value > maxScrollExtent)) {
|
if (owner.canLinkWithAfter && (value > maxScrollExtent)) {
|
||||||
final double delta = value - maxScrollExtent;
|
final double delta = value - maxScrollExtent;
|
||||||
_afterActivities ??= HashSet<LinkedScrollActivity>();
|
_afterActivities ??= HashSet<LinkedScrollActivity>();
|
||||||
_afterActivities.addAll(owner.linkWithAfter(this));
|
_afterActivities!.addAll(owner.linkWithAfter(this));
|
||||||
for (final LinkedScrollActivity activity in _afterActivities)
|
for (final LinkedScrollActivity activity in _afterActivities!)
|
||||||
afterOverscroll = math.max(activity.moveBy(delta), afterOverscroll);
|
afterOverscroll = math.max(activity.moveBy(delta), afterOverscroll);
|
||||||
assert(afterOverscroll >= 0.0);
|
assert(afterOverscroll >= 0.0);
|
||||||
}
|
}
|
||||||
@ -176,7 +174,7 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext {
|
|||||||
final double localOverscroll = setPixels(value.clamp(
|
final double localOverscroll = setPixels(value.clamp(
|
||||||
owner.canLinkWithBefore ? minScrollExtent : -double.infinity,
|
owner.canLinkWithBefore ? minScrollExtent : -double.infinity,
|
||||||
owner.canLinkWithAfter ? maxScrollExtent : double.infinity,
|
owner.canLinkWithAfter ? maxScrollExtent : double.infinity,
|
||||||
) as double);
|
));
|
||||||
|
|
||||||
assert(localOverscroll == 0.0 || (beforeOverscroll == 0.0 && afterOverscroll == 0.0));
|
assert(localOverscroll == 0.0 || (beforeOverscroll == 0.0 && afterOverscroll == 0.0));
|
||||||
}
|
}
|
||||||
@ -188,16 +186,16 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext {
|
|||||||
LinkedScrollActivity link(LinkedScrollPosition driver) {
|
LinkedScrollActivity link(LinkedScrollPosition driver) {
|
||||||
if (this.activity is! LinkedScrollActivity)
|
if (this.activity is! LinkedScrollActivity)
|
||||||
beginActivity(LinkedScrollActivity(this));
|
beginActivity(LinkedScrollActivity(this));
|
||||||
final LinkedScrollActivity activity = this.activity as LinkedScrollActivity;
|
final LinkedScrollActivity? activity = this.activity as LinkedScrollActivity?;
|
||||||
activity.link(driver);
|
activity!.link(driver);
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void unlink(LinkedScrollActivity activity) {
|
void unlink(LinkedScrollActivity activity) {
|
||||||
if (_beforeActivities != null)
|
if (_beforeActivities != null)
|
||||||
_beforeActivities.remove(activity);
|
_beforeActivities!.remove(activity);
|
||||||
if (_afterActivities != null)
|
if (_afterActivities != null)
|
||||||
_afterActivities.remove(activity);
|
_afterActivities!.remove(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -224,7 +222,7 @@ class LinkedScrollActivity extends ScrollActivity {
|
|||||||
void unlink(LinkedScrollPosition driver) {
|
void unlink(LinkedScrollPosition driver) {
|
||||||
drivers.remove(driver);
|
drivers.remove(driver);
|
||||||
if (drivers.isEmpty)
|
if (drivers.isEmpty)
|
||||||
delegate?.goIdle();
|
delegate.goIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -240,13 +238,16 @@ class LinkedScrollActivity extends ScrollActivity {
|
|||||||
|
|
||||||
double moveBy(double delta) {
|
double moveBy(double delta) {
|
||||||
assert(drivers.isNotEmpty);
|
assert(drivers.isNotEmpty);
|
||||||
ScrollDirection commonDirection;
|
ScrollDirection? commonDirection;
|
||||||
for (final LinkedScrollPosition driver in drivers) {
|
for (final LinkedScrollPosition driver in drivers) {
|
||||||
commonDirection ??= driver.userScrollDirection;
|
commonDirection ??= driver.userScrollDirection;
|
||||||
if (driver.userScrollDirection != commonDirection)
|
if (driver.userScrollDirection != commonDirection)
|
||||||
commonDirection = ScrollDirection.idle;
|
commonDirection = ScrollDirection.idle;
|
||||||
}
|
}
|
||||||
delegate._userMoved(commonDirection);
|
|
||||||
|
if (commonDirection != null) {
|
||||||
|
delegate._userMoved(commonDirection);
|
||||||
|
}
|
||||||
return delegate.setPixels(delegate.pixels + delta);
|
return delegate.setPixels(delegate.pixels + delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,14 +260,14 @@ class LinkedScrollActivity extends ScrollActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Test extends StatefulWidget {
|
class Test extends StatefulWidget {
|
||||||
const Test({ Key key }) : super(key: key);
|
const Test({ Key? key }) : super(key: key);
|
||||||
@override
|
@override
|
||||||
_TestState createState() => _TestState();
|
_TestState createState() => _TestState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TestState extends State<Test> {
|
class _TestState extends State<Test> {
|
||||||
LinkedScrollController _beforeController;
|
late LinkedScrollController _beforeController;
|
||||||
LinkedScrollController _afterController;
|
late LinkedScrollController _afterController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -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/src/foundation/assertions.dart';
|
import 'package:flutter/src/foundation/assertions.dart';
|
||||||
import 'package:flutter/src/painting/basic_types.dart';
|
import 'package:flutter/src/painting/basic_types.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
@ -112,7 +110,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Limited space along main axis error', (WidgetTester tester) async {
|
testWidgets('Limited space along main axis error', (WidgetTester tester) async {
|
||||||
final FlutterExceptionHandler oldHandler = FlutterError.onError;
|
final FlutterExceptionHandler oldHandler = FlutterError.onError!;
|
||||||
final List<FlutterErrorDetails> errors = <FlutterErrorDetails>[];
|
final List<FlutterErrorDetails> errors = <FlutterErrorDetails>[];
|
||||||
FlutterError.onError = (FlutterErrorDetails error) => errors.add(error);
|
FlutterError.onError = (FlutterErrorDetails error) => errors.add(error);
|
||||||
try {
|
try {
|
||||||
@ -145,7 +143,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Nested ListBody unbounded cross axis error', (WidgetTester tester) async {
|
testWidgets('Nested ListBody unbounded cross axis error', (WidgetTester tester) async {
|
||||||
final FlutterExceptionHandler oldHandler = FlutterError.onError;
|
final FlutterExceptionHandler oldHandler = FlutterError.onError!;
|
||||||
final List<FlutterErrorDetails> errors = <FlutterErrorDetails>[];
|
final List<FlutterErrorDetails> errors = <FlutterErrorDetails>[];
|
||||||
FlutterError.onError = (FlutterErrorDetails error) => errors.add(error);
|
FlutterError.onError = (FlutterErrorDetails error) => errors.add(error);
|
||||||
try {
|
try {
|
||||||
|
@ -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';
|
||||||
|
|
||||||
@ -264,7 +262,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('ListView.separated', (WidgetTester tester) async {
|
testWidgets('ListView.separated', (WidgetTester tester) async {
|
||||||
Widget buildFrame({ int itemCount }) {
|
Widget buildFrame({ required int itemCount }) {
|
||||||
return Directionality(
|
return Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: ListView.separated(
|
child: ListView.separated(
|
||||||
@ -309,7 +307,7 @@ void main() {
|
|||||||
|
|
||||||
|
|
||||||
testWidgets('ListView.separated uses correct semanticChildCount', (WidgetTester tester) async {
|
testWidgets('ListView.separated uses correct semanticChildCount', (WidgetTester tester) async {
|
||||||
Widget buildFrame({int itemCount}) {
|
Widget buildFrame({ required int itemCount}) {
|
||||||
return Directionality(
|
return Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: ListView.separated(
|
child: ListView.separated(
|
||||||
|
@ -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';
|
||||||
|
|
||||||
|
@ -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';
|
||||||
|
|
||||||
|
@ -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/rendering.dart';
|
import 'package:flutter/rendering.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';
|
||||||
|
|
||||||
const List<int> items = <int>[0, 1, 2, 3, 4, 5];
|
const List<int> items = <int>[0, 1, 2, 3, 4, 5];
|
||||||
|
|
||||||
Widget buildFrame({ bool reverse = false, @required TextDirection textDirection }) {
|
Widget buildFrame({ bool reverse = false, required TextDirection textDirection }) {
|
||||||
return Directionality(
|
return Directionality(
|
||||||
textDirection: textDirection,
|
textDirection: textDirection,
|
||||||
child: Center(
|
child: Center(
|
||||||
|
@ -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';
|
||||||
@ -218,7 +216,7 @@ void main() {
|
|||||||
await tester.pumpWidget(buildFrame());
|
await tester.pumpWidget(buildFrame());
|
||||||
expect(find.text('top'), findsOneWidget);
|
expect(find.text('top'), findsOneWidget);
|
||||||
|
|
||||||
final ScrollPosition position = Scrollable.of(tester.element(find.text('middle'))).position;
|
final ScrollPosition position = Scrollable.of(tester.element(find.text('middle')))!.position;
|
||||||
expect(position.viewportDimension, 600.0);
|
expect(position.viewportDimension, 600.0);
|
||||||
expect(position.pixels, 0.0);
|
expect(position.pixels, 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_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';
|
||||||
@ -80,7 +78,7 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final RenderSliverList list = tester.renderObject(find.byType(SliverList));
|
final RenderSliverList list = tester.renderObject(find.byType(SliverList));
|
||||||
expect(list.geometry.scrollExtent, equals(100.0));
|
expect(list.geometry!.scrollExtent, equals(100.0));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Directionality(
|
||||||
@ -93,7 +91,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(list.geometry.scrollExtent, equals(300.0));
|
expect(list.geometry!.scrollExtent, equals(300.0));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Directionality(
|
||||||
@ -103,7 +101,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(list.geometry.scrollExtent, equals(0.0));
|
expect(list.geometry!.scrollExtent, equals(0.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Overflowing ListView should relayout for missing children', (WidgetTester tester) async {
|
testWidgets('Overflowing ListView should relayout for missing children', (WidgetTester tester) async {
|
||||||
|
@ -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,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_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
@ -24,7 +22,7 @@ class TestSliverChildListDelegate extends SliverChildListDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Alive extends StatefulWidget {
|
class Alive extends StatefulWidget {
|
||||||
const Alive(this.alive, this.index, { Key key }) : super(key: key);
|
const Alive(this.alive, this.index, { Key? key }) : super(key: key);
|
||||||
final bool alive;
|
final bool alive;
|
||||||
final int index;
|
final int index;
|
||||||
|
|
||||||
@ -371,7 +369,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('ListView automatically pad MediaQuery on axis', (WidgetTester tester) async {
|
testWidgets('ListView automatically pad MediaQuery on axis', (WidgetTester tester) async {
|
||||||
EdgeInsets innerMediaQueryPadding;
|
EdgeInsets? innerMediaQueryPadding;
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Directionality(
|
||||||
@ -384,7 +382,7 @@ void main() {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const Text('top', textDirection: TextDirection.ltr),
|
const Text('top', textDirection: TextDirection.ltr),
|
||||||
Builder(builder: (BuildContext context) {
|
Builder(builder: (BuildContext context) {
|
||||||
innerMediaQueryPadding = MediaQuery.of(context).padding;
|
innerMediaQueryPadding = MediaQuery.of(context)!.padding;
|
||||||
return Container();
|
return Container();
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
@ -545,7 +543,7 @@ void main() {
|
|||||||
// Regression test for https://github.com/flutter/flutter/issues/43380.
|
// Regression test for https://github.com/flutter/flutter/issues/43380.
|
||||||
final ScrollController controller = ScrollController();
|
final ScrollController controller = ScrollController();
|
||||||
|
|
||||||
Widget buildListView({@required Axis scrollDirection}) {
|
Widget buildListView({ required Axis scrollDirection }) {
|
||||||
assert(scrollDirection != null);
|
assert(scrollDirection != null);
|
||||||
return Directionality(
|
return 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_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.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_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';
|
||||||
@ -182,7 +180,7 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('ListView reinvoke builders', (WidgetTester tester) async {
|
testWidgets('ListView reinvoke builders', (WidgetTester tester) async {
|
||||||
final List<int> callbackTracker = <int>[];
|
final List<int> callbackTracker = <int>[];
|
||||||
final List<String> text = <String>[];
|
final List<String?> text = <String?>[];
|
||||||
|
|
||||||
final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) {
|
final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) {
|
||||||
callbackTracker.add(index);
|
callbackTracker.add(index);
|
||||||
@ -232,7 +230,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('ListView reinvoke builders', (WidgetTester tester) async {
|
testWidgets('ListView reinvoke builders', (WidgetTester tester) async {
|
||||||
StateSetter setState;
|
late StateSetter setState;
|
||||||
ThemeData themeData = ThemeData.light();
|
ThemeData themeData = ThemeData.light();
|
||||||
|
|
||||||
final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) {
|
final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) {
|
||||||
@ -240,7 +238,7 @@ void main() {
|
|||||||
key: ValueKey<int>(index),
|
key: ValueKey<int>(index),
|
||||||
width: 500.0, // this should be ignored
|
width: 500.0, // this should be ignored
|
||||||
height: 220.0,
|
height: 220.0,
|
||||||
color: Theme.of(context).primaryColor,
|
color: Theme.of(context)!.primaryColor,
|
||||||
child: Text('$index', textDirection: TextDirection.ltr),
|
child: Text('$index', textDirection: TextDirection.ltr),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -319,10 +317,10 @@ void main() {
|
|||||||
|
|
||||||
final RenderSliverList list = tester.renderObject(find.byType(SliverList));
|
final RenderSliverList list = tester.renderObject(find.byType(SliverList));
|
||||||
|
|
||||||
expect(list.indexOf(list.firstChild), equals(0));
|
expect(list.indexOf(list.firstChild!), equals(0));
|
||||||
expect(list.indexOf(list.lastChild), equals(2));
|
expect(list.indexOf(list.lastChild!), equals(2));
|
||||||
expect(list.childScrollOffset(list.firstChild), equals(0.0));
|
expect(list.childScrollOffset(list.firstChild!), equals(0.0));
|
||||||
expect(list.geometry.scrollExtent, equals(300.0));
|
expect(list.geometry!.scrollExtent, equals(300.0));
|
||||||
|
|
||||||
expect(list, hasAGoodToStringDeep);
|
expect(list, hasAGoodToStringDeep);
|
||||||
expect(
|
expect(
|
||||||
|
@ -2,22 +2,30 @@
|
|||||||
// 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';
|
||||||
|
|
||||||
List<int> items = <int>[0, 1, 2, 3, 4, 5];
|
List<String> items = <String>[
|
||||||
|
'one',
|
||||||
|
'two',
|
||||||
|
'three',
|
||||||
|
'four',
|
||||||
|
'five',
|
||||||
|
];
|
||||||
|
|
||||||
Widget buildCard(BuildContext context, int index) {
|
Widget buildCard(BuildContext context, int index) {
|
||||||
if (index >= items.length)
|
// We still want to populate the list with items beyond the list
|
||||||
return null;
|
// provided.
|
||||||
|
if (index >= items.length) {
|
||||||
|
return const SizedBox(height: 100);
|
||||||
|
}
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
key: ValueKey<int>(items[index]),
|
key: ValueKey<String>(items[index]),
|
||||||
height: 100.0,
|
height: 100.0,
|
||||||
child: DefaultTextStyle(
|
child: DefaultTextStyle(
|
||||||
style: TextStyle(fontSize: 2.0 + items.length.toDouble()),
|
style: TextStyle(fontSize: 2.0 + items.length.toDouble()),
|
||||||
child: Text('${items[index]}', textDirection: TextDirection.ltr),
|
child: Text(items[index], textDirection: TextDirection.ltr),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -34,15 +42,15 @@ Widget buildFrame() {
|
|||||||
void main() {
|
void main() {
|
||||||
testWidgets('ListView is a build function (smoketest)', (WidgetTester tester) async {
|
testWidgets('ListView is a build function (smoketest)', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(buildFrame());
|
await tester.pumpWidget(buildFrame());
|
||||||
expect(find.text('0'), findsOneWidget);
|
expect(find.text('one'), findsOneWidget);
|
||||||
expect(find.text('1'), findsOneWidget);
|
expect(find.text('two'), findsOneWidget);
|
||||||
expect(find.text('2'), findsOneWidget);
|
expect(find.text('three'), findsOneWidget);
|
||||||
expect(find.text('3'), findsOneWidget);
|
expect(find.text('four'), findsOneWidget);
|
||||||
items.removeAt(2);
|
items.removeAt(2);
|
||||||
await tester.pumpWidget(buildFrame());
|
await tester.pumpWidget(buildFrame());
|
||||||
expect(find.text('0'), findsOneWidget);
|
expect(find.text('one'), findsOneWidget);
|
||||||
expect(find.text('1'), findsOneWidget);
|
expect(find.text('two'), findsOneWidget);
|
||||||
expect(find.text('2'), findsNothing);
|
expect(find.text('three'), findsNothing);
|
||||||
expect(find.text('3'), findsOneWidget);
|
expect(find.text('four'), findsOneWidget);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -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/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
@ -65,18 +63,6 @@ void main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('ListWheelScrollView needs positive item extent', (WidgetTester tester) async {
|
|
||||||
expect(
|
|
||||||
() {
|
|
||||||
ListWheelScrollView(
|
|
||||||
itemExtent: null,
|
|
||||||
children: <Widget>[Container()],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
throwsAssertionError,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('ListWheelScrollView can have zero child', (WidgetTester tester) async {
|
testWidgets('ListWheelScrollView can have zero child', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Directionality(
|
||||||
@ -106,17 +92,6 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('ListWheelScrollView needs valid overAndUnderCenterOpacity', (WidgetTester tester) async {
|
testWidgets('ListWheelScrollView needs valid overAndUnderCenterOpacity', (WidgetTester tester) async {
|
||||||
expect(
|
|
||||||
() {
|
|
||||||
ListWheelScrollView(
|
|
||||||
overAndUnderCenterOpacity: null,
|
|
||||||
itemExtent: 20.0,
|
|
||||||
children: <Widget>[Container()],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
throwsAssertionError,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
() {
|
() {
|
||||||
ListWheelScrollView(
|
ListWheelScrollView(
|
||||||
@ -426,7 +401,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final RenderListWheelViewport viewport = tester.firstRenderObject(find.byType(Text)).parent.parent as RenderListWheelViewport;
|
final RenderListWheelViewport viewport = tester.renderObject(find.byType(ListWheelViewport)) as RenderListWheelViewport;
|
||||||
|
|
||||||
// Item 0 is in the middle. There are 3 children visible after it, so the
|
// Item 0 is in the middle. There are 3 children visible after it, so the
|
||||||
// value of childCount should be 4.
|
// value of childCount should be 4.
|
||||||
@ -463,7 +438,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final RenderListWheelViewport viewport = tester.firstRenderObject(find.byType(Text)).parent.parent as RenderListWheelViewport;
|
final RenderListWheelViewport viewport = tester.renderObject(find.byType(ListWheelViewport)) as RenderListWheelViewport;
|
||||||
|
|
||||||
// The screen is vertically 600px. Since the middle item is centered,
|
// The screen is vertically 600px. Since the middle item is centered,
|
||||||
// half of the first and last items are visible, making 7 children visible.
|
// half of the first and last items are visible, making 7 children visible.
|
||||||
@ -654,7 +629,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final RenderListWheelViewport viewport = tester.firstRenderObject(find.byType(Container)).parent.parent as RenderListWheelViewport;
|
final RenderListWheelViewport viewport = tester.renderObject(find.byType(ListWheelViewport)) as RenderListWheelViewport;
|
||||||
expect(viewport, paints..transform(
|
expect(viewport, paints..transform(
|
||||||
matrix4: equals(<dynamic>[
|
matrix4: equals(<dynamic>[
|
||||||
1.0, 0.0, 0.0, 0.0,
|
1.0, 0.0, 0.0, 0.0,
|
||||||
@ -711,7 +686,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final RenderListWheelViewport viewport = tester.firstRenderObject(find.byType(Container)).parent.parent as RenderListWheelViewport;
|
final RenderListWheelViewport viewport = tester.renderObject(find.byType(ListWheelViewport)) as RenderListWheelViewport;
|
||||||
expect(viewport, paints..transform(
|
expect(viewport, paints..transform(
|
||||||
matrix4: equals(<dynamic>[
|
matrix4: equals(<dynamic>[
|
||||||
1.0, 0.0, 0.0, 0.0,
|
1.0, 0.0, 0.0, 0.0,
|
||||||
@ -832,7 +807,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final RenderListWheelViewport viewport = tester.firstRenderObject(find.byType(Container)).parent.parent as RenderListWheelViewport;
|
final RenderListWheelViewport viewport = tester.renderObject(find.byType(ListWheelViewport)) as RenderListWheelViewport;
|
||||||
expect(viewport, paints
|
expect(viewport, paints
|
||||||
..transform(
|
..transform(
|
||||||
matrix4: equals(<dynamic>[
|
matrix4: equals(<dynamic>[
|
||||||
@ -1295,7 +1270,7 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('ListWheelScrollView getOffsetToReveal', (WidgetTester tester) async {
|
testWidgets('ListWheelScrollView getOffsetToReveal', (WidgetTester tester) async {
|
||||||
List<Widget> outerChildren;
|
List<Widget> outerChildren;
|
||||||
final List<Widget> innerChildren = List<Widget>(10);
|
final List<Widget> innerChildren = List<Widget>.generate(10, (int index) => Container());
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Directionality(
|
||||||
@ -1365,7 +1340,7 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('ListWheelScrollView showOnScreen', (WidgetTester tester) async {
|
testWidgets('ListWheelScrollView showOnScreen', (WidgetTester tester) async {
|
||||||
List<Widget> outerChildren;
|
List<Widget> outerChildren;
|
||||||
final List<Widget> innerChildren = List<Widget>(10);
|
final List<Widget> innerChildren = List<Widget>.generate(10, (int index) => Container());
|
||||||
ScrollController controller;
|
ScrollController controller;
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
|
@ -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' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
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 '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/gestures.dart' show DragStartBehavior;
|
import 'package:flutter/gestures.dart' show DragStartBehavior;
|
||||||
|
@ -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:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
@ -22,11 +20,11 @@ void main() {
|
|||||||
],
|
],
|
||||||
child: const Text('loaded')
|
child: const Text('loaded')
|
||||||
));
|
));
|
||||||
final dynamic state = tester.state(find.byType(Localizations));
|
final dynamic state = tester.state(find.byType(Localizations)); // ignore: unnecessary_nullable_for_final_variable_declarations
|
||||||
expect(state.locale, isNull);
|
expect(state!.locale, isNull);
|
||||||
expect(find.text('loaded'), findsNothing);
|
expect(find.text('loaded'), findsNothing);
|
||||||
|
|
||||||
Locale locale;
|
late Locale locale;
|
||||||
binding.onAllowFrame = () {
|
binding.onAllowFrame = () {
|
||||||
locale = state.locale as Locale;
|
locale = state.locale as Locale;
|
||||||
};
|
};
|
||||||
@ -53,12 +51,11 @@ class FakeLocalizationsDelegate extends LocalizationsDelegate<String> {
|
|||||||
|
|
||||||
class TestAutomatedTestWidgetsFlutterBinding extends AutomatedTestWidgetsFlutterBinding {
|
class TestAutomatedTestWidgetsFlutterBinding extends AutomatedTestWidgetsFlutterBinding {
|
||||||
|
|
||||||
VoidCallback onAllowFrame;
|
VoidCallback? onAllowFrame;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void allowFirstFrame() {
|
void allowFirstFrame() {
|
||||||
if (onAllowFrame != null)
|
onAllowFrame?.call();
|
||||||
onAllowFrame();
|
|
||||||
super.allowFirstFrame();
|
super.allowFirstFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 Brightness;
|
import 'dart:ui' show Brightness;
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
@ -50,7 +48,7 @@ void main() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Builder(
|
Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
final MediaQueryData data = MediaQuery.of(context, nullOk: true);
|
final MediaQueryData? data = MediaQuery.of(context, nullOk: true);
|
||||||
expect(data, isNull);
|
expect(data, isNull);
|
||||||
tested = true;
|
tested = true;
|
||||||
return Container();
|
return Container();
|
||||||
@ -61,10 +59,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('MediaQueryData is sane', (WidgetTester tester) async {
|
testWidgets('MediaQueryData is sane', (WidgetTester tester) async {
|
||||||
final MediaQueryData data = MediaQueryData.fromWindow(WidgetsBinding.instance.window);
|
final MediaQueryData data = MediaQueryData.fromWindow(WidgetsBinding.instance!.window);
|
||||||
expect(data, hasOneLineDescription);
|
expect(data, hasOneLineDescription);
|
||||||
expect(data.hashCode, equals(data.copyWith().hashCode));
|
expect(data.hashCode, equals(data.copyWith().hashCode));
|
||||||
expect(data.size, equals(WidgetsBinding.instance.window.physicalSize / WidgetsBinding.instance.window.devicePixelRatio));
|
expect(data.size, equals(WidgetsBinding.instance!.window.physicalSize / WidgetsBinding.instance!.window.devicePixelRatio));
|
||||||
expect(data.accessibleNavigation, false);
|
expect(data.accessibleNavigation, false);
|
||||||
expect(data.invertColors, false);
|
expect(data.invertColors, false);
|
||||||
expect(data.disableAnimations, false);
|
expect(data.disableAnimations, false);
|
||||||
@ -74,7 +72,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('MediaQueryData.copyWith defaults to source', (WidgetTester tester) async {
|
testWidgets('MediaQueryData.copyWith defaults to source', (WidgetTester tester) async {
|
||||||
final MediaQueryData data = MediaQueryData.fromWindow(WidgetsBinding.instance.window);
|
final MediaQueryData data = MediaQueryData.fromWindow(WidgetsBinding.instance!.window);
|
||||||
final MediaQueryData copied = data.copyWith();
|
final MediaQueryData copied = data.copyWith();
|
||||||
expect(copied.size, data.size);
|
expect(copied.size, data.size);
|
||||||
expect(copied.devicePixelRatio, data.devicePixelRatio);
|
expect(copied.devicePixelRatio, data.devicePixelRatio);
|
||||||
@ -103,7 +101,7 @@ void main() {
|
|||||||
const EdgeInsets customViewInsets = EdgeInsets.all(1.67262);
|
const EdgeInsets customViewInsets = EdgeInsets.all(1.67262);
|
||||||
const EdgeInsets customSystemGestureInsets = EdgeInsets.all(1.5556);
|
const EdgeInsets customSystemGestureInsets = EdgeInsets.all(1.5556);
|
||||||
|
|
||||||
final MediaQueryData data = MediaQueryData.fromWindow(WidgetsBinding.instance.window);
|
final MediaQueryData data = MediaQueryData.fromWindow(WidgetsBinding.instance!.window);
|
||||||
final MediaQueryData copied = data.copyWith(
|
final MediaQueryData copied = data.copyWith(
|
||||||
size: customSize,
|
size: customSize,
|
||||||
devicePixelRatio: customDevicePixelRatio,
|
devicePixelRatio: customDevicePixelRatio,
|
||||||
@ -144,7 +142,7 @@ void main() {
|
|||||||
const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
|
const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
|
||||||
const EdgeInsets viewInsets = EdgeInsets.only(top: 5.0, right: 6.0, left: 7.0, bottom: 8.0);
|
const EdgeInsets viewInsets = EdgeInsets.only(top: 5.0, right: 6.0, left: 7.0, bottom: 8.0);
|
||||||
|
|
||||||
MediaQueryData unpadded;
|
late MediaQueryData unpadded;
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MediaQuery(
|
MediaQuery(
|
||||||
data: const MediaQueryData(
|
data: const MediaQueryData(
|
||||||
@ -171,7 +169,7 @@ void main() {
|
|||||||
removeBottom: true,
|
removeBottom: true,
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
unpadded = MediaQuery.of(context);
|
unpadded = MediaQuery.of(context)!;
|
||||||
return Container();
|
return Container();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -203,7 +201,7 @@ void main() {
|
|||||||
const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
|
const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
|
||||||
const EdgeInsets viewInsets = EdgeInsets.only(top: 5.0, right: 6.0, left: 7.0, bottom: 8.0);
|
const EdgeInsets viewInsets = EdgeInsets.only(top: 5.0, right: 6.0, left: 7.0, bottom: 8.0);
|
||||||
|
|
||||||
MediaQueryData unpadded;
|
late MediaQueryData unpadded;
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MediaQuery(
|
MediaQuery(
|
||||||
data: const MediaQueryData(
|
data: const MediaQueryData(
|
||||||
@ -227,7 +225,7 @@ void main() {
|
|||||||
context: context,
|
context: context,
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
unpadded = MediaQuery.of(context);
|
unpadded = MediaQuery.of(context)!;
|
||||||
return Container();
|
return Container();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -259,7 +257,7 @@ void main() {
|
|||||||
const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
|
const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
|
||||||
const EdgeInsets viewInsets = EdgeInsets.only(top: 1.0, right: 2.0, left: 3.0, bottom: 4.0);
|
const EdgeInsets viewInsets = EdgeInsets.only(top: 1.0, right: 2.0, left: 3.0, bottom: 4.0);
|
||||||
|
|
||||||
MediaQueryData unpadded;
|
late MediaQueryData unpadded;
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MediaQuery(
|
MediaQuery(
|
||||||
data: const MediaQueryData(
|
data: const MediaQueryData(
|
||||||
@ -286,7 +284,7 @@ void main() {
|
|||||||
removeBottom: true,
|
removeBottom: true,
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
unpadded = MediaQuery.of(context);
|
unpadded = MediaQuery.of(context)!;
|
||||||
return Container();
|
return Container();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -318,7 +316,7 @@ void main() {
|
|||||||
const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
|
const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
|
||||||
const EdgeInsets viewInsets = EdgeInsets.only(top: 1.0, right: 2.0, left: 3.0, bottom: 4.0);
|
const EdgeInsets viewInsets = EdgeInsets.only(top: 1.0, right: 2.0, left: 3.0, bottom: 4.0);
|
||||||
|
|
||||||
MediaQueryData unpadded;
|
late MediaQueryData unpadded;
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MediaQuery(
|
MediaQuery(
|
||||||
data: const MediaQueryData(
|
data: const MediaQueryData(
|
||||||
@ -342,7 +340,7 @@ void main() {
|
|||||||
removeBottom: true,
|
removeBottom: true,
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
unpadded = MediaQuery.of(context);
|
unpadded = MediaQuery.of(context)!;
|
||||||
return Container();
|
return Container();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -374,7 +372,7 @@ void main() {
|
|||||||
const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
|
const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
|
||||||
const EdgeInsets viewInsets = EdgeInsets.only(top: 1.0, right: 2.0, left: 3.0, bottom: 4.0);
|
const EdgeInsets viewInsets = EdgeInsets.only(top: 1.0, right: 2.0, left: 3.0, bottom: 4.0);
|
||||||
|
|
||||||
MediaQueryData unpadded;
|
late MediaQueryData unpadded;
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MediaQuery(
|
MediaQuery(
|
||||||
data: const MediaQueryData(
|
data: const MediaQueryData(
|
||||||
@ -401,7 +399,7 @@ void main() {
|
|||||||
removeBottom: true,
|
removeBottom: true,
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
unpadded = MediaQuery.of(context);
|
unpadded = MediaQuery.of(context)!;
|
||||||
return Container();
|
return Container();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -433,7 +431,7 @@ void main() {
|
|||||||
const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
|
const EdgeInsets viewPadding = EdgeInsets.only(top: 6.0, right: 8.0, left: 10.0, bottom: 12.0);
|
||||||
const EdgeInsets viewInsets = EdgeInsets.only(top: 1.0, right: 2.0, left: 3.0, bottom: 4.0);
|
const EdgeInsets viewInsets = EdgeInsets.only(top: 1.0, right: 2.0, left: 3.0, bottom: 4.0);
|
||||||
|
|
||||||
MediaQueryData unpadded;
|
late MediaQueryData unpadded;
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MediaQuery(
|
MediaQuery(
|
||||||
data: const MediaQueryData(
|
data: const MediaQueryData(
|
||||||
@ -457,7 +455,7 @@ void main() {
|
|||||||
removeLeft: true,
|
removeLeft: true,
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
unpadded = MediaQuery.of(context);
|
unpadded = MediaQuery.of(context)!;
|
||||||
return Container();
|
return Container();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -482,8 +480,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('MediaQuery.textScaleFactorOf', (WidgetTester tester) async {
|
testWidgets('MediaQuery.textScaleFactorOf', (WidgetTester tester) async {
|
||||||
double outsideTextScaleFactor;
|
late double outsideTextScaleFactor;
|
||||||
double insideTextScaleFactor;
|
late double insideTextScaleFactor;
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Builder(
|
Builder(
|
||||||
@ -509,8 +507,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('MediaQuery.platformBrightnessOf', (WidgetTester tester) async {
|
testWidgets('MediaQuery.platformBrightnessOf', (WidgetTester tester) async {
|
||||||
Brightness outsideBrightness;
|
late Brightness outsideBrightness;
|
||||||
Brightness insideBrightness;
|
late Brightness insideBrightness;
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Builder(
|
Builder(
|
||||||
@ -536,8 +534,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('MediaQuery.highContrastOf', (WidgetTester tester) async {
|
testWidgets('MediaQuery.highContrastOf', (WidgetTester tester) async {
|
||||||
bool outsideHighContrast;
|
late bool outsideHighContrast;
|
||||||
bool insideHighContrast;
|
late bool insideHighContrast;
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Builder(
|
Builder(
|
||||||
@ -563,8 +561,8 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('MediaQuery.boldTextOverride', (WidgetTester tester) async {
|
testWidgets('MediaQuery.boldTextOverride', (WidgetTester tester) async {
|
||||||
bool outsideBoldTextOverride;
|
late bool outsideBoldTextOverride;
|
||||||
bool insideBoldTextOverride;
|
late bool insideBoldTextOverride;
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Builder(
|
Builder(
|
||||||
@ -588,159 +586,4 @@ void main() {
|
|||||||
expect(outsideBoldTextOverride, false);
|
expect(outsideBoldTextOverride, false);
|
||||||
expect(insideBoldTextOverride, true);
|
expect(insideBoldTextOverride, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('size parameter in MediaQueryData cannot be null', () {
|
|
||||||
try {
|
|
||||||
MediaQueryData(size: null);
|
|
||||||
} on AssertionError catch (error) {
|
|
||||||
expect(error.toString(), contains('size != null'));
|
|
||||||
expect(error.toString(), contains('is not true'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail('The assert was never called when it should have been');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('devicePixelRatio parameter in MediaQueryData cannot be null', () {
|
|
||||||
try {
|
|
||||||
MediaQueryData(devicePixelRatio: null);
|
|
||||||
} on AssertionError catch (error) {
|
|
||||||
expect(error.toString(), contains('devicePixelRatio != null'));
|
|
||||||
expect(error.toString(), contains('is not true'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail('The assert was never called when it should have been');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('textScaleFactor parameter in MediaQueryData cannot be null', () {
|
|
||||||
try {
|
|
||||||
MediaQueryData(textScaleFactor: null);
|
|
||||||
} on AssertionError catch (error) {
|
|
||||||
expect(error.toString(), contains('textScaleFactor != null'));
|
|
||||||
expect(error.toString(), contains('is not true'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail('The assert was never called when it should have been');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('platformBrightness parameter in MediaQueryData cannot be null', () {
|
|
||||||
try {
|
|
||||||
MediaQueryData(platformBrightness: null);
|
|
||||||
} on AssertionError catch (error) {
|
|
||||||
expect(error.toString(), contains('platformBrightness != null'));
|
|
||||||
expect(error.toString(), contains('is not true'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail('The assert was never called when it should have been');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('padding parameter in MediaQueryData cannot be null', () {
|
|
||||||
try {
|
|
||||||
MediaQueryData(padding: null);
|
|
||||||
} on AssertionError catch (error) {
|
|
||||||
expect(error.toString(), contains('padding != null'));
|
|
||||||
expect(error.toString(), contains('is not true'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail('The assert was never called when it should have been');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('viewInsets parameter in MediaQueryData cannot be null', () {
|
|
||||||
try {
|
|
||||||
MediaQueryData(viewInsets: null);
|
|
||||||
} on AssertionError catch (error) {
|
|
||||||
expect(error.toString(), contains('viewInsets != null'));
|
|
||||||
expect(error.toString(), contains('is not true'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail('The assert was never called when it should have been');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('systemGestureInsets parameter in MediaQueryData cannot be null', () {
|
|
||||||
try {
|
|
||||||
MediaQueryData(systemGestureInsets: null);
|
|
||||||
} on AssertionError catch (error) {
|
|
||||||
expect(error.toString(), contains('systemGestureInsets != null'));
|
|
||||||
expect(error.toString(), contains('is not true'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail('The assert was never called when it should have been');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('viewPadding parameter in MediaQueryData cannot be null', () {
|
|
||||||
try {
|
|
||||||
MediaQueryData(viewPadding: null);
|
|
||||||
} on AssertionError catch (error) {
|
|
||||||
expect(error.toString(), contains('viewPadding != null'));
|
|
||||||
expect(error.toString(), contains('is not true'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail('The assert was never called when it should have been');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('alwaysUse24HourFormat parameter in MediaQueryData cannot be null', () {
|
|
||||||
try {
|
|
||||||
MediaQueryData(alwaysUse24HourFormat: null);
|
|
||||||
} on AssertionError catch (error) {
|
|
||||||
expect(error.toString(), contains('alwaysUse24HourFormat != null'));
|
|
||||||
expect(error.toString(), contains('is not true'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail('The assert was never called when it should have been');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('accessibleNavigation parameter in MediaQueryData cannot be null', () {
|
|
||||||
try {
|
|
||||||
MediaQueryData(accessibleNavigation: null);
|
|
||||||
} on AssertionError catch (error) {
|
|
||||||
expect(error.toString(), contains('accessibleNavigation != null'));
|
|
||||||
expect(error.toString(), contains('is not true'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail('The assert was never called when it should have been');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('invertColors parameter in MediaQueryData cannot be null', () {
|
|
||||||
try {
|
|
||||||
MediaQueryData(invertColors: null);
|
|
||||||
} on AssertionError catch (error) {
|
|
||||||
expect(error.toString(), contains('invertColors != null'));
|
|
||||||
expect(error.toString(), contains('is not true'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail('The assert was never called when it should have been');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('highContrast parameter in MediaQueryData cannot be null', () {
|
|
||||||
try {
|
|
||||||
MediaQueryData(highContrast: null);
|
|
||||||
} on AssertionError catch (error) {
|
|
||||||
expect(error.toString(), contains('highContrast != null'));
|
|
||||||
expect(error.toString(), contains('is not true'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail('The assert was never called when it should have been');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('disableAnimations parameter in MediaQueryData cannot be null', () {
|
|
||||||
try {
|
|
||||||
MediaQueryData(disableAnimations: null);
|
|
||||||
} on AssertionError catch (error) {
|
|
||||||
expect(error.toString(), contains('disableAnimations != null'));
|
|
||||||
expect(error.toString(), contains('is not true'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail('The assert was never called when it should have been');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('boldText parameter in MediaQueryData cannot be null', () {
|
|
||||||
try {
|
|
||||||
MediaQueryData(boldText: null);
|
|
||||||
} on AssertionError catch (error) {
|
|
||||||
expect(error.toString(), contains('boldText != null'));
|
|
||||||
expect(error.toString(), contains('is not true'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail('The assert was never called when it should have been');
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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';
|
||||||
@ -15,10 +13,10 @@ import 'package:flutter/gestures.dart' show kSecondaryButton, PointerDeviceKind;
|
|||||||
import 'semantics_tester.dart';
|
import 'semantics_tester.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
bool tapped;
|
late bool tapped;
|
||||||
bool hovered;
|
late bool hovered;
|
||||||
Widget tapTarget;
|
late Widget tapTarget;
|
||||||
Widget hoverTarget;
|
late Widget hoverTarget;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tapped = false;
|
tapped = false;
|
||||||
@ -418,12 +416,12 @@ void main() {
|
|||||||
|
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class FirstWidget extends StatelessWidget {
|
class FirstWidget extends StatelessWidget {
|
||||||
const FirstWidget({ Key key }) : super(key: key);
|
const FirstWidget({ Key? key }) : super(key: key);
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
@ -438,7 +436,7 @@ class FirstWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SecondWidget extends StatelessWidget {
|
class SecondWidget extends StatelessWidget {
|
||||||
const SecondWidget({ Key key }) : super(key: key);
|
const SecondWidget({ Key? key }) : super(key: key);
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const ModalBarrier(
|
return const ModalBarrier(
|
||||||
@ -449,7 +447,7 @@ class SecondWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SecondWidgetWithCompetence extends StatelessWidget {
|
class SecondWidgetWithCompetence extends StatelessWidget {
|
||||||
const SecondWidgetWithCompetence({ Key key }) : super(key: key);
|
const SecondWidgetWithCompetence({ Key? key }) : super(key: key);
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Stack(
|
return Stack(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user