Last active
October 10, 2020 13:55
-
-
Save remonh87/bd6d8583e70955b23f2fdccfb390a9b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:sliver_tools/sliver_tools.dart'; | |
void main() { | |
testWidgets('This succeeds', (tester) async { | |
var result = 0; | |
final sut = MaterialApp( | |
home: Scaffold( | |
body: Center( | |
child: CustomScrollView( | |
slivers: [ | |
SliverStack( | |
children: [ | |
SliverToBoxAdapter( | |
child: SizedBox( | |
height: 400, | |
width: 400, | |
), | |
), | |
SliverToBoxAdapter( | |
child: TextButton( | |
child: Text('test'), | |
onPressed: () { | |
result++; | |
}, | |
), | |
) | |
], | |
) | |
], | |
), | |
), | |
), | |
); | |
await tester.pumpWidget(sut); | |
await tester.pumpAndSettle(); | |
await tester.tap(find.text('test')); | |
await tester.pumpAndSettle(); | |
expect(result, 1); | |
}); | |
testWidgets('this fail', (tester) async { | |
var result = 0; | |
final sut = MaterialApp( | |
home: Scaffold( | |
body: Center( | |
child: CustomScrollView( | |
slivers: [ | |
SliverStack( | |
children: [ | |
SliverToBoxAdapter( | |
child: SizedBox( | |
height: 100, | |
width: 400, | |
), | |
), | |
SliverPositioned( | |
left: 40, | |
right: 40, | |
top: 225, | |
child: TextButton( | |
child: Text('test'), | |
onPressed: () { | |
result++; | |
}, | |
), | |
), | |
], | |
) | |
], | |
), | |
), | |
), | |
); | |
await tester.pumpWidget(sut); | |
await tester.pumpAndSettle(); | |
await tester.tap(find.text('test')); | |
await tester.pumpAndSettle(); | |
expect(result, 1); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment