@@ -306,123 +306,67 @@ void main() {
306
306
..update (const LibraryName (< String > ['core' ]), createCoreWidgets ());
307
307
addTearDown (runtime.dispose);
308
308
final DynamicContent data = DynamicContent ();
309
-
310
- // Test Flexible with default values
311
- runtime.update (const LibraryName (< String > ['test' ]), parseLibraryFile ('''
312
- import core;
313
- widget root = Directionality(
314
- textDirection: "ltr",
315
- child: Column(
316
- children: [
317
- Flexible(
318
- child: Text(text: "Default flexible"),
319
- ),
320
- ],
309
+
310
+ // Helper function to create test widget with Flexible content
311
+ String createFlexibleTestWidget (String flexibleContent) {
312
+ return '''
313
+ import core;
314
+ widget root = Directionality(
315
+ textDirection: "ltr",
316
+ child: Column(
317
+ children: [
318
+ $flexibleContent
319
+ ],
320
+ ),
321
+ );
322
+ ''' ;
323
+ }
324
+
325
+ // Helper function to pump widget and verify
326
+ Future <void > pumpTestWidget (String flexibleContent) async {
327
+ runtime.update (const LibraryName (< String > ['test' ]),
328
+ parseLibraryFile (createFlexibleTestWidget (flexibleContent)));
329
+ await tester.pumpWidget (
330
+ RemoteWidget (
331
+ runtime: runtime,
332
+ data: data,
333
+ widget: const FullyQualifiedWidgetName (LibraryName (< String > ['test' ]), 'root' ),
321
334
),
322
335
);
323
- ''' ));
324
-
325
- await tester.pumpWidget (
326
- RemoteWidget (
327
- runtime: runtime,
328
- data: data,
329
- widget: const FullyQualifiedWidgetName (LibraryName (< String > ['test' ]), 'root' ),
330
- ),
331
- );
332
- await tester.pump ();
336
+ await tester.pumpAndSettle ();
337
+ }
338
+
339
+ // Test Flexible with default values
340
+ await pumpTestWidget ('Flexible(child: Text(text: "Default flexible"))' );
333
341
expect (find.byType (Flexible ), findsOneWidget);
334
342
final Flexible defaultFlexible = tester.widget <Flexible >(find.byType (Flexible ));
335
343
expect (defaultFlexible.flex, equals (1 ));
336
344
expect (defaultFlexible.fit, equals (FlexFit .loose));
337
345
338
346
// Test Flexible with custom flex value
339
- runtime.update (const LibraryName (< String > ['test' ]), parseLibraryFile ('''
340
- import core;
341
- widget root = Directionality(
342
- textDirection: "ltr",
343
- child: Column(
344
- children: [
345
- Flexible(
346
- flex: 3,
347
- child: Text(text: "Custom flex"),
348
- ),
349
- ],
350
- ),
351
- );
352
- ''' ));
353
- await tester.pumpAndSettle ();
347
+ await pumpTestWidget ('Flexible(flex: 3, child: Text(text: "Custom flex"))' );
354
348
final Flexible customFlexFlexible = tester.widget <Flexible >(find.byType (Flexible ));
355
349
expect (customFlexFlexible.flex, equals (3 ));
356
350
expect (customFlexFlexible.fit, equals (FlexFit .loose));
357
351
358
352
// Test Flexible with fit: "tight"
359
- runtime.update (const LibraryName (< String > ['test' ]), parseLibraryFile ('''
360
- import core;
361
- widget root = Directionality(
362
- textDirection: "ltr",
363
- child: Column(
364
- children: [
365
- Flexible(
366
- flex: 2,
367
- fit: "tight",
368
- child: Text(text: "Tight fit"),
369
- ),
370
- ],
371
- ),
372
- );
373
- ''' ));
374
- await tester.pumpAndSettle ();
353
+ await pumpTestWidget ('Flexible(flex: 2, fit: "tight", child: Text(text: "Tight fit"))' );
375
354
final Flexible tightFlexible = tester.widget <Flexible >(find.byType (Flexible ));
376
355
expect (tightFlexible.flex, equals (2 ));
377
356
expect (tightFlexible.fit, equals (FlexFit .tight));
378
357
379
358
// Test Flexible with fit: "loose"
380
- runtime.update (const LibraryName (< String > ['test' ]), parseLibraryFile ('''
381
- import core;
382
- widget root = Directionality(
383
- textDirection: "ltr",
384
- child: Column(
385
- children: [
386
- Flexible(
387
- flex: 4,
388
- fit: "loose",
389
- child: Text(text: "Loose fit"),
390
- ),
391
- ],
392
- ),
393
- );
394
- ''' ));
395
- await tester.pumpAndSettle ();
359
+ await pumpTestWidget ('Flexible(flex: 4, fit: "loose", child: Text(text: "Loose fit"))' );
396
360
final Flexible looseFlexible = tester.widget <Flexible >(find.byType (Flexible ));
397
361
expect (looseFlexible.flex, equals (4 ));
398
362
expect (looseFlexible.fit, equals (FlexFit .loose));
399
363
400
364
// Test multiple Flexible widgets in a Column
401
- runtime.update (const LibraryName (< String > ['test' ]), parseLibraryFile ('''
402
- import core;
403
- widget root = Directionality(
404
- textDirection: "ltr",
405
- child: Column(
406
- children: [
407
- Flexible(
408
- flex: 1,
409
- fit: "loose",
410
- child: Text(text: "First"),
411
- ),
412
- Flexible(
413
- flex: 2,
414
- fit: "tight",
415
- child: Text(text: "Second"),
416
- ),
417
- Flexible(
418
- flex: 1,
419
- child: Text(text: "Third"),
420
- ),
421
- ],
422
- ),
423
- );
424
- ''' ));
425
- await tester.pumpAndSettle ();
365
+ await pumpTestWidget ('''
366
+ Flexible(flex: 1, fit: "loose", child: Text(text: "First")),
367
+ Flexible(flex: 2, fit: "tight", child: Text(text: "Second")),
368
+ Flexible(flex: 1, child: Text(text: "Third"))
369
+ ''' );
426
370
expect (find.byType (Flexible ), findsNWidgets (3 ));
427
371
428
372
final List <Flexible > flexibleWidgets = tester.widgetList <Flexible >(find.byType (Flexible )).toList ();
0 commit comments