banner_theme_test.dart 22.9 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6 7
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
8

9 10 11 12 13 14 15 16 17
void main() {
  test('MaterialBannerThemeData copyWith, ==, hashCode basics', () {
    expect(const MaterialBannerThemeData(), const MaterialBannerThemeData().copyWith());
    expect(const MaterialBannerThemeData().hashCode, const MaterialBannerThemeData().copyWith().hashCode);
  });

  test('MaterialBannerThemeData null fields by default', () {
    const MaterialBannerThemeData bannerTheme = MaterialBannerThemeData();
    expect(bannerTheme.backgroundColor, null);
18 19 20
    expect(bannerTheme.surfaceTintColor, null);
    expect(bannerTheme.shadowColor, null);
    expect(bannerTheme.dividerColor, null);
21
    expect(bannerTheme.contentTextStyle, null);
22 23 24
    expect(bannerTheme.elevation, null);
    expect(bannerTheme.padding, null);
    expect(bannerTheme.leadingPadding, null);
25 26
  });

27
  testWidgets('Default MaterialBannerThemeData debugFillProperties', (WidgetTester tester) async {
28 29 30 31
    final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
    const MaterialBannerThemeData().debugFillProperties(builder);

    final List<String> description = builder.properties
32 33 34
      .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
      .map((DiagnosticsNode node) => node.toString())
      .toList();
35 36 37 38

    expect(description, <String>[]);
  });

39
  testWidgets('MaterialBannerThemeData implements debugFillProperties', (WidgetTester tester) async {
40 41
    final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
    const MaterialBannerThemeData(
42 43 44 45 46 47 48 49
      backgroundColor: Color(0xfffffff0),
      surfaceTintColor: Color(0xfffffff1),
      shadowColor: Color(0xfffffff2),
      dividerColor: Color(0xfffffff3),
      contentTextStyle: TextStyle(color: Color(0xfffffff4)),
      elevation: 4.0,
      padding: EdgeInsets.all(20.0),
      leadingPadding: EdgeInsets.only(left: 8.0),
50 51 52
    ).debugFillProperties(builder);

    final List<String> description = builder.properties
53 54 55
      .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
      .map((DiagnosticsNode node) => node.toString())
      .toList();
56 57

    expect(description, <String>[
58 59 60 61 62 63 64 65
      'backgroundColor: Color(0xfffffff0)',
      'surfaceTintColor: Color(0xfffffff1)',
      'shadowColor: Color(0xfffffff2)',
      'dividerColor: Color(0xfffffff3)',
      'contentTextStyle: TextStyle(inherit: true, color: Color(0xfffffff4))',
      'elevation: 4.0',
      'padding: EdgeInsets.all(20.0)',
      'leadingPadding: EdgeInsets(8.0, 0.0, 0.0, 0.0)',
66 67 68
    ]);
  });

69
  testWidgets('Material3 - Passing no MaterialBannerThemeData returns defaults', (WidgetTester tester) async {
70
    const String contentText = 'Content';
71 72
    final ThemeData theme = ThemeData(useMaterial3: true);
    late final ThemeData localizedTheme;
73

74
    await tester.pumpWidget(MaterialApp(
75
      theme: theme,
76 77 78 79
      builder:(BuildContext context, Widget? child) {
        localizedTheme = Theme.of(context);
        return child!;
      },
80 81 82
      home: Scaffold(
        body: MaterialBanner(
          content: const Text(contentText),
83
          leading: const Icon(Icons.umbrella),
84
          actions: <Widget>[
85
            TextButton(
86 87 88 89 90 91 92 93
              child: const Text('Action'),
              onPressed: () { },
            ),
          ],
        ),
      ),
    ));

94
    final Material material = _getMaterialFromText(tester, contentText);
95
    expect(material.color, theme.colorScheme.surface);
96 97 98 99 100 101 102
    expect(material.surfaceTintColor, theme.colorScheme.surfaceTint);
    expect(material.shadowColor, null);
    expect(material.elevation, 0.0);

    final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
    expect(
      content.text.style,
103
      localizedTheme.textTheme.bodyMedium,
104 105 106 107 108 109 110 111 112 113 114
    );

    final Offset rowTopLeft = tester.getTopLeft(find.byType(Row));
    final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
    final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.umbrella));
    expect(rowTopLeft.dy - materialTopLeft.dy, 2.0); // Default single line top padding.
    expect(rowTopLeft.dx - materialTopLeft.dx, 16.0); // Default single line start padding.
    expect(leadingTopLeft.dy - materialTopLeft.dy, 16); // Default leading padding.
    expect(leadingTopLeft.dx - materialTopLeft.dx, 16); // Default leading padding.

    final Divider divider = tester.widget<Divider>(find.byType(Divider));
115
    expect(divider.color, theme.colorScheme.outlineVariant);
116 117
  });

118
  testWidgets('Material3 - Passing no MaterialBannerThemeData returns defaults when presented by ScaffoldMessenger', (WidgetTester tester) async {
119 120
    const String contentText = 'Content';
    const Key tapTarget = Key('tap-target');
121 122
    final ThemeData theme = ThemeData(useMaterial3: true);
    late final ThemeData localizedTheme;
123

124
    await tester.pumpWidget(MaterialApp(
125
      theme: theme,
126 127 128
      home: Scaffold(
        body: Builder(
          builder: (BuildContext context) {
129
            localizedTheme = Theme.of(context);
130 131 132 133 134
            return GestureDetector(
              key: tapTarget,
              onTap: () {
                ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
                  content: const Text(contentText),
135
                  leading: const Icon(Icons.umbrella),
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
                  actions: <Widget>[
                    TextButton(
                      child: const Text('Action'),
                      onPressed: () { },
                    ),
                  ],
                ));
              },
              behavior: HitTestBehavior.opaque,
              child: const SizedBox(
                height: 100.0,
                width: 100.0,
              ),
            );
          },
        ),
      ),
    ));
    await tester.tap(find.byKey(tapTarget));
    await tester.pumpAndSettle();

157
    final Material material = _getMaterialFromText(tester, contentText);
158
    expect(material.color, theme.colorScheme.surface);
159 160 161 162 163 164 165
    expect(material.surfaceTintColor, theme.colorScheme.surfaceTint);
    expect(material.shadowColor, null);
    expect(material.elevation, 0.0);

    final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
    expect(
      content.text.style,
166
      localizedTheme.textTheme.bodyMedium,
167 168 169 170 171 172 173 174 175 176 177
    );

    final Offset rowTopLeft = tester.getTopLeft(find.byType(Row));
    final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
    final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.umbrella));
    expect(rowTopLeft.dy - materialTopLeft.dy, 2.0); // Default single line top padding.
    expect(rowTopLeft.dx - materialTopLeft.dx, 16.0); // Default single line start padding.
    expect(leadingTopLeft.dy - materialTopLeft.dy, 16); // Default leading padding.
    expect(leadingTopLeft.dx - materialTopLeft.dx, 16); // Default leading padding.

    final Divider divider = tester.widget<Divider>(find.byType(Divider));
178
    expect(divider.color, theme.colorScheme.outlineVariant);
179 180
  });

181
  testWidgets('MaterialBanner uses values from MaterialBannerThemeData', (WidgetTester tester) async {
182 183 184 185 186 187 188 189 190
    final MaterialBannerThemeData bannerTheme = _bannerTheme();
    const String contentText = 'Content';
    await tester.pumpWidget(MaterialApp(
      theme: ThemeData(bannerTheme: bannerTheme),
      home: Scaffold(
        body: MaterialBanner(
          leading: const Icon(Icons.ac_unit),
          content: const Text(contentText),
          actions: <Widget>[
191
            TextButton(
192 193 194 195 196 197 198 199
              child: const Text('Action'),
              onPressed: () { },
            ),
          ],
        ),
      ),
    ));

200
    final Material material = _getMaterialFromText(tester, contentText);
201
    expect(material.color, bannerTheme.backgroundColor);
202 203 204 205 206
    expect(material.surfaceTintColor, bannerTheme.surfaceTintColor);
    expect(material.shadowColor, bannerTheme.shadowColor);
    expect(material.elevation, bannerTheme.elevation);

    final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
207 208 209
    expect(content.text.style, bannerTheme.contentTextStyle);

    final Offset contentTopLeft = tester.getTopLeft(_textFinder(contentText));
210
    final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
211
    final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.ac_unit));
212 213 214 215
    expect(contentTopLeft.dy - materialTopLeft.dy, 24);
    expect(contentTopLeft.dx - materialTopLeft.dx, 41);
    expect(leadingTopLeft.dy - materialTopLeft.dy, 19);
    expect(leadingTopLeft.dx - materialTopLeft.dx, 11);
216 217

    expect(find.byType(Divider), findsNothing);
218 219
  });

220
  testWidgets('MaterialBanner uses values from MaterialBannerThemeData when presented by ScaffoldMessenger', (WidgetTester tester) async {
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
    final MaterialBannerThemeData bannerTheme = _bannerTheme();
    const String contentText = 'Content';
    const Key tapTarget = Key('tap-target');
    await tester.pumpWidget(MaterialApp(
      theme: ThemeData(bannerTheme: bannerTheme),
      home: Scaffold(
        body: Builder(
          builder: (BuildContext context) {
            return GestureDetector(
              key: tapTarget,
              onTap: () {
                ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
                  leading: const Icon(Icons.ac_unit),
                  content: const Text(contentText),
                  actions: <Widget>[
                    TextButton(
                      child: const Text('Action'),
                      onPressed: () { },
                    ),
                  ],
                ));
              },
              behavior: HitTestBehavior.opaque,
              child: const SizedBox(
                height: 100.0,
                width: 100.0,
              ),
            );
          },
        ),
      ),
    ));
    await tester.tap(find.byKey(tapTarget));
    await tester.pumpAndSettle();

256
    final Material material = _getMaterialFromText(tester, contentText);
257
    expect(material.color, bannerTheme.backgroundColor);
258 259 260 261 262
    expect(material.surfaceTintColor, bannerTheme.surfaceTintColor);
    expect(material.shadowColor, bannerTheme.shadowColor);
    expect(material.elevation, bannerTheme.elevation);

    final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
263 264 265
    expect(content.text.style, bannerTheme.contentTextStyle);

    final Offset contentTopLeft = tester.getTopLeft(_textFinder(contentText));
266
    final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
267
    final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.ac_unit));
268 269 270 271
    expect(contentTopLeft.dy - materialTopLeft.dy, 24);
    expect(contentTopLeft.dx - materialTopLeft.dx, 41);
    expect(leadingTopLeft.dy - materialTopLeft.dy, 19);
    expect(leadingTopLeft.dx - materialTopLeft.dx, 11);
272 273

    expect(find.byType(Divider), findsNothing);
274 275
  });

276
  testWidgets('MaterialBanner widget properties take priority over theme', (WidgetTester tester) async {
277
    const Color backgroundColor = Colors.purple;
278 279
    const Color surfaceTintColor = Colors.red;
    const Color shadowColor = Colors.orange;
280 281 282
    const TextStyle textStyle = TextStyle(color: Colors.green);
    final MaterialBannerThemeData bannerTheme = _bannerTheme();
    const String contentText = 'Content';
283

284 285 286 287 288
    await tester.pumpWidget(MaterialApp(
      theme: ThemeData(bannerTheme: bannerTheme),
      home: Scaffold(
        body: MaterialBanner(
          backgroundColor: backgroundColor,
289 290 291
          surfaceTintColor: surfaceTintColor,
          shadowColor: shadowColor,
          elevation: 6.0,
292 293 294 295
          leading: const Icon(Icons.ac_unit),
          contentTextStyle: textStyle,
          content: const Text(contentText),
          padding: const EdgeInsets.all(10),
296
          leadingPadding: const EdgeInsets.all(12),
297
          actions: <Widget>[
298
            TextButton(
299 300 301 302 303 304 305 306
              child: const Text('Action'),
              onPressed: () { },
            ),
          ],
        ),
      ),
    ));

307
    final Material material = _getMaterialFromText(tester, contentText);
308
    expect(material.color, backgroundColor);
309 310 311 312 313
    expect(material.surfaceTintColor, surfaceTintColor);
    expect(material.shadowColor, shadowColor);
    expect(material.elevation, 6.0);

    final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
314 315 316
    expect(content.text.style, textStyle);

    final Offset contentTopLeft = tester.getTopLeft(_textFinder(contentText));
317
    final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
318
    final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.ac_unit));
319 320 321 322
    expect(contentTopLeft.dy - materialTopLeft.dy, 29);
    expect(contentTopLeft.dx - materialTopLeft.dx, 58);
    expect(leadingTopLeft.dy - materialTopLeft.dy, 24);
    expect(leadingTopLeft.dx - materialTopLeft.dx, 22);
323 324

    expect(find.byType(Divider), findsNothing);
325 326
  });

327
  testWidgets('MaterialBanner widget properties take priority over theme when presented by ScaffoldMessenger', (WidgetTester tester) async {
328
    const Color backgroundColor = Colors.purple;
329
    const double elevation = 6.0;
330 331 332 333
    const TextStyle textStyle = TextStyle(color: Colors.green);
    final MaterialBannerThemeData bannerTheme = _bannerTheme();
    const String contentText = 'Content';
    const Key tapTarget = Key('tap-target');
334

335 336 337 338 339 340 341 342 343 344
    await tester.pumpWidget(MaterialApp(
      theme: ThemeData(bannerTheme: bannerTheme),
      home: Scaffold(
        body: Builder(
          builder: (BuildContext context) {
            return GestureDetector(
              key: tapTarget,
              onTap: () {
                ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
                  backgroundColor: backgroundColor,
345
                  elevation: elevation,
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
                  leading: const Icon(Icons.ac_unit),
                  contentTextStyle: textStyle,
                  content: const Text(contentText),
                  padding: const EdgeInsets.all(10),
                  leadingPadding: const EdgeInsets.all(12),
                  actions: <Widget>[
                    TextButton(
                      child: const Text('Action'),
                      onPressed: () { },
                    ),
                  ],
                ));
              },
              behavior: HitTestBehavior.opaque,
              child: const SizedBox(
                height: 100.0,
                width: 100.0,
              ),
            );
          },
        ),
      ),
    ));
    await tester.tap(find.byKey(tapTarget));
    await tester.pumpAndSettle();

372
    final Material material = _getMaterialFromText(tester, contentText);
373
    expect(material.color, backgroundColor);
374 375 376
    expect(material.elevation, elevation);

    final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
377 378 379
    expect(content.text.style, textStyle);

    final Offset contentTopLeft = tester.getTopLeft(_textFinder(contentText));
380
    final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
381
    final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.ac_unit));
382 383 384 385
    expect(contentTopLeft.dy - materialTopLeft.dy, 29);
    expect(contentTopLeft.dx - materialTopLeft.dx, 58);
    expect(leadingTopLeft.dy - materialTopLeft.dy, 24);
    expect(leadingTopLeft.dx - materialTopLeft.dx, 22);
386 387

    expect(find.byType(Divider), findsNothing);
388 389
  });

390
  testWidgets('MaterialBanner uses color scheme when necessary', (WidgetTester tester) async {
391
    final ColorScheme colorScheme = const ColorScheme.light().copyWith(surface: Colors.purple);
392
    const String contentText = 'Content';
393 394 395 396
    await tester.pumpWidget(MaterialApp(
      theme: ThemeData(colorScheme: colorScheme),
      home: Scaffold(
        body: MaterialBanner(
397
          content: const Text(contentText),
398
          actions: <Widget>[
399
            TextButton(
400 401 402 403 404 405 406 407
              child: const Text('Action'),
              onPressed: () { },
            ),
          ],
        ),
      ),
    ));

408 409
    final Material material = _getMaterialFromText(tester, contentText);
    expect(material.color, colorScheme.surface);
410 411
  });

412
  testWidgets('MaterialBanner uses color scheme when necessary when presented by ScaffoldMessenger', (WidgetTester tester) async {
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
    final ColorScheme colorScheme = const ColorScheme.light().copyWith(surface: Colors.purple);
    const String contentText = 'Content';
    const Key tapTarget = Key('tap-target');
    await tester.pumpWidget(MaterialApp(
      theme: ThemeData(colorScheme: colorScheme),
      home: Scaffold(
        body: Builder(
          builder: (BuildContext context) {
            return GestureDetector(
              key: tapTarget,
              onTap: () {
                ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
                  content: const Text(contentText),
                  actions: <Widget>[
                    TextButton(
                      child: const Text('Action'),
                      onPressed: () { },
                    ),
                  ],
                ));
              },
              behavior: HitTestBehavior.opaque,
              child: const SizedBox(
                height: 100.0,
                width: 100.0,
              ),
            );
          },
        ),
      ),
    ));
    await tester.tap(find.byKey(tapTarget));
    await tester.pumpAndSettle();

447 448
    final Material material = _getMaterialFromText(tester, contentText);
    expect(material.color, colorScheme.surface);
449
  });
450 451

  group('Material 2', () {
452 453 454
    // These tests are only relevant for Material 2. Once Material 2
    // support is deprecated and the APIs are removed, these tests
    // can be deleted.
455

456
    testWidgets('Material2 - Passing no MaterialBannerThemeData returns defaults', (WidgetTester tester) async {
457 458 459
      const String contentText = 'Content';

      await tester.pumpWidget(MaterialApp(
460
        theme: ThemeData(useMaterial3: false),
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501
        home: Scaffold(
          body: MaterialBanner(
            content: const Text(contentText),
            leading: const Icon(Icons.umbrella),
            actions: <Widget>[
              TextButton(
                child: const Text('Action'),
                onPressed: () { },
              ),
            ],
          ),
        ),
      ));

      final Material material = _getMaterialFromText(tester, contentText);
      expect(material.color, const Color(0xffffffff));
      expect(material.surfaceTintColor, null);
      expect(material.shadowColor, null);
      expect(material.elevation, 0.0);

      final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
      // Default value for ThemeData.typography is Typography.material2014()
      expect(
        content.text.style,
        Typography.material2014().englishLike.bodyText2!.merge(
          Typography.material2014().black.bodyText2,
        ),
      );

      final Offset rowTopLeft = tester.getTopLeft(find.byType(Row));
      final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
      final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.umbrella));
      expect(rowTopLeft.dy - materialTopLeft.dy, 2.0); // Default single line top padding.
      expect(rowTopLeft.dx - materialTopLeft.dx, 16.0); // Default single line start padding.
      expect(leadingTopLeft.dy - materialTopLeft.dy, 16); // Default leading padding.
      expect(leadingTopLeft.dx - materialTopLeft.dx, 16); // Default leading padding.

      final Divider divider = tester.widget<Divider>(find.byType(Divider));
      expect(divider.color, null);
    });

502
    testWidgets('Material2 - Passing no MaterialBannerThemeData returns defaults when presented by ScaffoldMessenger', (WidgetTester tester) async {
503 504 505 506
      const String contentText = 'Content';
      const Key tapTarget = Key('tap-target');

      await tester.pumpWidget(MaterialApp(
507
        theme: ThemeData(useMaterial3: false),
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564
        home: Scaffold(
          body: Builder(
            builder: (BuildContext context) {
              return GestureDetector(
                key: tapTarget,
                onTap: () {
                  ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
                    content: const Text(contentText),
                    leading: const Icon(Icons.umbrella),
                    actions: <Widget>[
                      TextButton(
                        child: const Text('Action'),
                        onPressed: () { },
                      ),
                    ],
                  ));
                },
                behavior: HitTestBehavior.opaque,
                child: const SizedBox(
                  height: 100.0,
                  width: 100.0,
                ),
              );
            },
          ),
        ),
      ));
      await tester.tap(find.byKey(tapTarget));
      await tester.pumpAndSettle();

      final Material material = _getMaterialFromText(tester, contentText);
      expect(material.color, const Color(0xffffffff));
      expect(material.surfaceTintColor, null);
      expect(material.shadowColor, null);
      expect(material.elevation, 0.0);

      final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
      // Default value for ThemeData.typography is Typography.material2014()
      expect(
        content.text.style,
        Typography.material2014().englishLike.bodyText2!.merge(
          Typography.material2014().black.bodyText2,
        ),
      );

      final Offset rowTopLeft = tester.getTopLeft(find.byType(Row));
      final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
      final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.umbrella));
      expect(rowTopLeft.dy - materialTopLeft.dy, 2.0); // Default single line top padding.
      expect(rowTopLeft.dx - materialTopLeft.dx, 16.0); // Default single line start padding.
      expect(leadingTopLeft.dy - materialTopLeft.dy, 16); // Default leading padding.
      expect(leadingTopLeft.dx - materialTopLeft.dx, 16); // Default leading padding.

      final Divider divider = tester.widget<Divider>(find.byType(Divider));
      expect(divider.color, null);
    });
  });
565 566 567 568 569
}

MaterialBannerThemeData _bannerTheme() {
  return const MaterialBannerThemeData(
    backgroundColor: Colors.orange,
570 571 572
    surfaceTintColor: Colors.yellow,
    shadowColor: Colors.red,
    dividerColor: Colors.green,
573
    contentTextStyle: TextStyle(color: Colors.pink),
574
    elevation: 4.0,
575
    padding: EdgeInsets.all(5),
576
    leadingPadding: EdgeInsets.all(6),
577 578 579
  );
}

580 581
Material _getMaterialFromText(WidgetTester tester, String text) {
  return tester.widget<Material>(find.widgetWithText(Material, text).first);
582 583
}

584 585
Finder _materialFinder() {
  return find.descendant(of: find.byType(MaterialBanner), matching: find.byType(Material)).first;
586 587 588
}

RenderParagraph _getTextRenderObjectFromDialog(WidgetTester tester, String text) {
589
  return tester.element<StatelessElement>(_textFinder(text)).renderObject! as RenderParagraph;
590 591 592 593
}

Finder _textFinder(String text) {
  return find.descendant(of: find.byType(MaterialBanner), matching: find.text(text));
594
}