@@ -201,7 +201,7 @@ void main() {
201201 currentTimer = tracer.autoFinishAfterTimer;
202202 });
203203
204- await tapMe (tester, sut, 'btn_1' );
204+ await tapMe (tester, sut, 'btn_1' , pumpWidget : false );
205205
206206 Timer ? autoFinishAfterTimer;
207207 fixture.hub.configureScope ((scope) {
@@ -226,7 +226,7 @@ void main() {
226226 currentTracer = (scope.span as SentryTracer );
227227 });
228228
229- await tapMe (tester, sut, 'btn_2' );
229+ await tapMe (tester, sut, 'btn_2' , pumpWidget : false );
230230
231231 SentryTracer ? tracer;
232232 fixture.hub.configureScope ((scope) {
@@ -238,8 +238,15 @@ void main() {
238238 });
239239}
240240
241- Future <void > tapMe (WidgetTester tester, Widget widget, String key) async {
242- await tester.pumpWidget (widget);
241+ Future <void > tapMe (
242+ WidgetTester tester,
243+ Widget widget,
244+ String key, {
245+ bool pumpWidget = true ,
246+ }) async {
247+ if (pumpWidget) {
248+ await tester.pumpWidget (widget);
249+ }
243250
244251 await tester.tap (find.byKey (Key (key)));
245252}
@@ -278,59 +285,96 @@ class MyApp extends StatelessWidget {
278285 Widget build (BuildContext context) {
279286 return MaterialApp (
280287 title: 'Welcome to Flutter' ,
281- home: Scaffold (
282- appBar: AppBar (
283- title: const Text ('Welcome to Flutter' ),
284- ),
285- body: Center (
286- child: Column (
287- children: [
288- MaterialButton (
289- key: Key ('btn_1' ),
290- onPressed: () {
291- // print('button pressed');
292- },
293- child: const Text ('Button 1' ),
294- ),
295- CupertinoButton (
296- key: Key ('btn_2' ),
297- onPressed: () {
298- // print('button pressed 2');
299- },
300- child: const Text ('Button 2' ),
288+ home: Page1 (),
289+ routes: {'page2' : (context) => const Page2 ()},
290+ );
291+ }
292+ }
293+
294+ class Page1 extends StatelessWidget {
295+ const Page1 ({Key ? key}) : super (key: key);
296+
297+ @override
298+ Widget build (BuildContext context) {
299+ return Scaffold (
300+ body: Center (
301+ child: Column (
302+ children: [
303+ MaterialButton (
304+ key: Key ('btn_1' ),
305+ onPressed: () {
306+ // print('button pressed');
307+ },
308+ child: const Text ('Button 1' ),
309+ ),
310+ CupertinoButton (
311+ key: Key ('btn_2' ),
312+ onPressed: () {
313+ // print('button pressed 2');
314+ },
315+ child: const Text ('Button 2' ),
316+ ),
317+ IconButton (
318+ key: Key ('btn_3' ),
319+ onPressed: () {
320+ // print('button pressed 3');
321+ },
322+ icon: Icon (
323+ Icons .dark_mode,
324+ semanticLabel: 'My Icon' ,
301325 ),
302- IconButton (
303- key: Key ('btn_3' ),
304- onPressed: () {
305- // print('button pressed 3');
326+ ),
327+ Card (
328+ child: GestureDetector (
329+ key: Key ('btn_4' ),
330+ onTap: () => {
331+ // print('button pressed 4'),
306332 },
307- icon: Icon (
308- Icons .dark_mode,
309- semanticLabel: 'My Icon' ,
333+ child: Stack (
334+ children: [
335+ //fancy card layout
336+ ElevatedButton (
337+ key: Key ('btn_5' ),
338+ onPressed: () => {
339+ // print('button pressed 5'),
340+ },
341+ child: const Text ('Button 5' ),
342+ ),
343+ ],
310344 ),
311345 ),
312- Card (
313- child: GestureDetector (
314- key: Key ('btn_4' ),
315- onTap: () => {
316- // print('button pressed 4'),
317- },
318- child: Stack (
319- children: [
320- //fancy card layout
321- ElevatedButton (
322- key: Key ('btn_5' ),
323- onPressed: () => {
324- // print('button pressed 5'),
325- },
326- child: const Text ('Button 5' ),
327- ),
328- ],
329- ),
330- ),
331- )
332- ],
333- ),
346+ ),
347+ MaterialButton (
348+ key: Key ('btn_go_to_page2' ),
349+ onPressed: () {
350+ Navigator .of (context).pushNamed ('page2' );
351+ },
352+ child: const Text ('Go to page 2' ),
353+ ),
354+ ],
355+ ),
356+ ),
357+ );
358+ }
359+ }
360+
361+ class Page2 extends StatelessWidget {
362+ const Page2 ({Key ? key}) : super (key: key);
363+
364+ @override
365+ Widget build (BuildContext context) {
366+ return Scaffold (
367+ body: Center (
368+ child: Column (
369+ children: [
370+ MaterialButton (
371+ key: Key ('btn_page_2' ),
372+ onPressed: () {
373+ // print('button page 2 pressed');
374+ },
375+ child: const Text ('Button Page 2' ),
376+ ),
377+ ],
334378 ),
335379 ),
336380 );
0 commit comments