Skip to content

fix(ui): let dialogs below StreamChat follow the app's brightness - #3005

Merged
renefloor merged 2 commits into
masterfrom
fix/stream-chat-theme-dialogs
Oct 14, 2026
Merged

renefloor merged 2 commits into
masterfrom
fix/stream-chat-theme-dialogs

Conversation

@renefloor

@renefloor renefloor commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Submit a pull request

Linear: FLU-

Github Issue: #

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

StreamChat wraps its child in a Theme carrying the StreamTheme extension. showDialog and showModalBottomSheet copy every Theme between the caller and the root navigator into the route when it opens, so a dialog opened below StreamChat kept the colors of the moment it opened and did not follow a light/dark switch.

A dialog is not a descendant of the screen that opened it. It is a separate route in the root navigator's overlay, so StreamChat's Theme can never notify it of a change:

MaterialApp
└─ Theme (MaterialApp's)                  ← ancestor of everything below
   └─ Navigator (root)
      └─ Overlay
         ├─ Route with StreamChat above the screens
         │  └─ StreamChat
         │     └─ Theme (StreamChat's)    ← only notifies this branch
         │        └─ Screen
         │           └─ showDialog(context) called here
         │
         └─ DialogRoute
            └─ Theme (captured copy)      ← built by InheritedTheme.capture
               └─ dialog

InheritedTheme.capture bridges the two branches by copying the ThemeData values into the dialog route. It only copies, so the dialog keeps the values from the moment it opened. Without a Theme between the caller and the navigator nothing is copied, and the dialog reads MaterialApp's Theme, which is an ancestor of its branch and does notify it.

The Theme is now only inserted when the app has not registered a StreamTheme itself. An app that registers one, such as the Stream Video sample app (GetStream/stream-video-flutter#1378), gets dialogs that follow the app theme.

Tested in stream_chat_test.dart: a dialog opened below StreamChat gets the dark StreamTheme after the brightness changes. It failed before this change.

Screenshots / Videos

Before After
img img

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Dialogs and bottom sheets opened within StreamChat now reflect the app’s current light or dark theme when brightness changes.
    • Text entered in a chat screen is preserved when switching to dark mode, even if only the light theme defines chat-specific colors.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f108d1fd-1016-451f-b514-8e7bf2add52f
📥 Commits

Reviewing files that changed from the base of the PR and between 4d39b4a and c8d4688.

📒 Files selected for processing: 3
  • packages/stream_chat_flutter/CHANGELOG.md
  • packages/stream_chat_flutter/lib/src/stream_chat.dart
  • packages/stream_chat_flutter/test/src/stream_chat_test.dart

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

StreamChat now retains an existing StreamTheme extension and preserves subtree state when theme registration changes. Tests cover dialog theme updates and text-field state across a light-to-dark brightness change.

Changes: StreamChat theme updates

Layer / File(s) Summary
Theme injection and state preservation
packages/stream_chat_flutter/lib/src/stream_chat.dart, packages/stream_chat_flutter/test/src/stream_chat_test.dart, packages/stream_chat_flutter/CHANGELOG.md
StreamChatState.build adds the inherited StreamTheme only when the app theme does not already contain one, and keys the chat subtree. Tests check dialog theme updates and text-field state after a brightness change. The changelog describes the dialog and bottom-sheet color issue.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: xsahil03x

Merge Risk: ⚪ Minimal · up to c8d46

The theme update is ready to merge after normal checks.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: dialogs below StreamChat now follow the app's light or dark brightness.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@xsahil03x xsahil03x left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is right for apps that register their own StreamTheme. One regression to address before merging, plus a test and a changelog tweak.

Comment thread packages/stream_chat_flutter/lib/src/stream_chat.dart
Comment thread packages/stream_chat_flutter/test/src/stream_chat_test.dart
Comment thread packages/stream_chat_flutter/CHANGELOG.md Outdated
renefloor and others added 2 commits October 14, 2026 10:45
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Key the subtree so switching between a light and dark theme where only one
registers a StreamTheme no longer unmounts everything below StreamChat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@renefloor
renefloor force-pushed the fix/stream-chat-theme-dialogs branch from 59cbcc5 to c8d4688 Compare October 14, 2026 08:46
@renefloor
renefloor marked this pull request as ready for review October 14, 2026 08:47
@renefloor
renefloor enabled auto-merge (squash) October 14, 2026 08:47
@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.27%. Comparing base (4d39b4a) to head (c8d4688).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3005   +/-   ##
=======================================
  Coverage   78.27%   78.27%           
=======================================
  Files         450      450           
  Lines       29347    29350    +3     
=======================================
+ Hits        22970    22973    +3     
  Misses       6377     6377           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@renefloor
renefloor merged commit 15c4d67 into master Oct 14, 2026
36 checks passed
@renefloor
renefloor deleted the fix/stream-chat-theme-dialogs branch October 14, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants