Skip to content

[Widget Previewer] ListTileTheme leaks into previewed widgets, causing incorrect background colors #194660

Closed

Description

@sugarcoded1

Steps to reproduce

  1. Create a new Flutter project using flutter create bug.
  2. Replace lib/main.dart with the code sample below.
  3. Launch the Widget Previewer using flutter widget-preview start.
  4. Observe the SwitchListTile background in the preview.
  5. Run the application normally using flutter run and compare the appearance.
  6. Set tileColor: Colors.transparent on the SwitchListTile and observe that the issue disappears.

Expected results

The SwitchListTile should have a transparent background by default.

The Widget Previewer should render the widget identically to normal application execution without introducing unintended styling.

Actual results

The Widget Previewer renders the SwitchListTile with an unexpected dark background, despite no tile background color being configured in the application.

This does not occur during normal application execution.

Further investigation revealed that ListTileTheme.of(context).tileColor returns a dark color (approximately #201E24), while Theme.of(context).listTileTheme.tileColor returns null.

Explicitly setting tileColor: Colors.transparent resolves the issue.

Suspected root cause:

The Widget Previewer defines its own ListTileThemeData in packages/flutter_tools/templates/widget_preview_scaffold/lib/src/theme/theme.dart.tmpl, including:

tileColor: backgroundColor.brighten()

In widget_preview_rendering.dart.tmpl, WidgetPreviewGroupWidget propagates the existing ListTileTheme using ListTileTheme.of(context).copyWith(...).

This appears to allow the previewer's internal styling to leak into the previewed application, even when the application provides its own MaterialApp and ThemeData.

Code sample

Code sample
import 'package:flutter/widget_previews.dart';
import 'package:material_ui/material_ui.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  @Preview()
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _isEnabled = false;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
          backgroundColor: Colors.green,
          body: Builder(
            builder: (context) {
              final inheritedTileColor =
                  ListTileTheme.of(context).tileColor;

              final themeTileColor =
                  Theme.of(context).listTileTheme.tileColor;

              return Column(
                children: [
                  Text('Inherited tile color: $inheritedTileColor'),
                  Text('ThemeData tile color: $themeTileColor'),
                  SizedBox(
                    width: 400,
                    child: SwitchListTile(
                      value: _isEnabled,
                      onChanged: (v) => setState(() => _isEnabled = v),
                    ),
                  ),
                ],
              );
            },
          ),
        ),
    );
  }
}

Screenshots or Video

Dark list tile (should be transparent by default) Image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel beta, 3.50.0-0.1.pre, on macOS 26.5.1 25F80 darwin-arm64, locale en-US) [385ms]
    • Flutter version 3.50.0-0.1.pre on channel beta at /Users/name/Programs/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 07502c7de3 (4 days ago), 2026-10-13 19:03:20 -0700
    • Engine revision b890cddcf8
    • Dart version 3.14.0 (build 3.14.0-315.1.beta)
    • DevTools version 2.61.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-record-use, enable-swift-package-manager,
      omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration, enable-hcpp

[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0-rc1) [1,054ms]
    • Android SDK at /Users/name/Library/Android/sdk
    • Emulator version 37.2.12.0 (build_id 16428233) (CL:N/A)
    • Platform android-36, build-tools 36.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 25.0.3+-15898627-b508.16)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 26.0.1) [1,050ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17A400
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [6ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Connected device (2 available) [5.9s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 26.5.1 25F80 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 155.0.8059.80
    ! Error: Browsing on the local area network for name iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources [527ms]
    • All expected network resources are available.

• No issues found!

Activity

  1. sugarcoded1 commented on Oct 18, 2026

    @sugarcoded1
    Author

    This started happening after upgrading to the latest version of the beta channel.

  2. added
    in triagePresently being triaged by the triage team
    c: regressionIt was better in the past than it is now
    toolAffects the "flutter" command-line tool. See also t: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    a: widget previewsIssues related to the Widget Previewer tooling
    team-toolOwned by Flutter Tool team
    and removed
    in triagePresently being triaged by the triage team
    on Oct 19, 2026
  3. mbcorona commented on Oct 19, 2026

    @mbcorona
    Member

    Hi @sugarcoded1, thanks for the report, and your root cause is right. Reproduced on beta 3.50 with your exact sample.
    Routing to team-tool.

  4. github-actions commented on Nov 12, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: widget previewsIssues related to the Widget Previewer toolingc: regressionIt was better in the past than it is nowhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions