banner_theme_test.dart 23.2 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
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
9

10 11 12 13 14 15 16 17 18
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);
19 20 21
    expect(bannerTheme.surfaceTintColor, null);
    expect(bannerTheme.shadowColor, null);
    expect(bannerTheme.dividerColor, null);
22
    expect(bannerTheme.contentTextStyle, null);
23 24 25
    expect(bannerTheme.elevation, null);
    expect(bannerTheme.padding, null);
    expect(bannerTheme.leadingPadding, null);
26 27
  });

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

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

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

40
  testWidgetsWithLeakTracking('MaterialBannerThemeData implements debugFillProperties', (WidgetTester tester) async {
41 42
    final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
    const MaterialBannerThemeData(
43 44 45 46 47 48 49 50
      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),
51 52 53
    ).debugFillProperties(builder);

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

    expect(description, <String>[
59 60 61 62 63 64 65 66
      '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)',
67 68 69
    ]);
  });

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

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

95
    final Material material = _getMaterialFromText(tester, contentText);
96
    expect(material.color, theme.colorScheme.surface);
97 98 99 100 101 102 103
    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,
104
      localizedTheme.textTheme.bodyMedium,
105 106 107 108 109 110 111 112 113 114 115
    );

    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));
116
    expect(divider.color, theme.colorScheme.outlineVariant);
117 118
  });

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

125
    await tester.pumpWidget(MaterialApp(
126
      theme: theme,
127 128 129
      home: Scaffold(
        body: Builder(
          builder: (BuildContext context) {
130
            localizedTheme = Theme.of(context);
131 132 133 134 135
            return GestureDetector(
              key: tapTarget,
              onTap: () {
                ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
                  content: const Text(contentText),
136
                  leading: const Icon(Icons.umbrella),
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
                  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();

158
    final Material material = _getMaterialFromText(tester, contentText);
159
    expect(material.color, theme.colorScheme.surface);
160 161 162 163 164 165 166
    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,
167
      localizedTheme.textTheme.bodyMedium,
168 169 170 171 172 173 174 175 176 177 178
    );

    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));
179
    expect(divider.color, theme.colorScheme.outlineVariant);
180 181
  });

182
  testWidgetsWithLeakTracking('MaterialBanner uses values from MaterialBannerThemeData', (WidgetTester tester) async {
183 184 185 186 187 188 189 190 191
    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>[
192
            TextButton(
193 194 195 196 197 198 199 200
              child: const Text('Action'),
              onPressed: () { },
            ),
          ],
        ),
      ),
    ));

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

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

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

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

221
  testWidgetsWithLeakTracking('MaterialBanner uses values from MaterialBannerThemeData when presented by ScaffoldMessenger', (WidgetTester tester) async {
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 256
    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();

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

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

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

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

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

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

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

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

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

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

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

336 337 338 339 340 341 342 343 344 345
    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,
346
                  elevation: elevation,
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 372
                  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();

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

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

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

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

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

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

413
  testWidgetsWithLeakTracking('MaterialBanner uses color scheme when necessary when presented by ScaffoldMessenger', (WidgetTester tester) async {
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 447
    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();

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

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

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

      await tester.pumpWidget(MaterialApp(
461
        theme: ThemeData(useMaterial3: false),
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 502
        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);
    });

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

      await tester.pumpWidget(MaterialApp(
508
        theme: ThemeData(useMaterial3: false),
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 565
        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);
    });
  });
566 567 568 569 570
}

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

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

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

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

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