question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running a flutter project from within vscode no longer follows the system theme

See original GitHub issue

Describe the bug When I run flutter apps with the theme and darkTheme properties set from within code, the launched application does not follow the linux desktop dark theme and the android emulators system theme.

To Reproduce Steps to reproduce the behavior: Create a new flutter application Change the theme property to a light theme and the darkTheme property to a dark theme. Switch your system theme to a dark theme in Android or Linux GNOME desktop

Expected behavior The flutter app follows the system theme “brightness” and switch from dark to light

Screenshots From within vscode: no From within vscode with the android emulator: Peek_2021-07-02_00-05

From the terminal: ya From intellij: yayaya From intellij with android as the target: int

Versions (please complete the following information):

  • VS Code version: 1.57.1
  • Dart extension version: v3.24.0
  • Dart/Flutter SDK version: Flutter version 2.3.0-17.0.pre.622, but this happens with all channels (stable, dev, beta, master)

Additional information: this worked perfectly fine until some days ago

Edit: vscode snap or .deb - same behaviour 😦

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
DanTupcommented, Jul 6, 2021

@Feichtmeier this ended up being a bit more of a refactor than I’d expected so I don’t plan to release it in a patch. It’ll be included in the next release likely around the end of the month.

However I have now set up nightly builds so if you’d like the fix before then you could grab the latest one (right now it’s mostly the same as the last release build but with this and a few other minor fixes). You can download it from the artifacts on the most recent job here:

https://github.com/Dart-Code/Dart-Code/actions/workflows/nightly-build.yml

Some instructions on installing are here:

https://dartcode.org/docs/installing-a-preview-release/

VS Code should automatically move you back to the stable release once it’s out (it will auto-update as long as the version number on the marketplace is newer).

1reaction
DanTupcommented, Jul 5, 2021

Looks like when we ask the app for the BrightnessOverride value we get the _resolved_ value but our code assumes it was the override value. This means when we try to restore the values (which is normally after a Hot Restart, although we’re currently doing this on startup too) we can end up adding an override for the brightness (of the current resolved value). This only started happening recently because restoring the toggles had become broken (and was fixed as part of #3426).

I haven’t fully thought it through, but I think a reasonable fix (that won’t re-introduce #3426) would be:

  • Stop storing the local state of these debug extensions unless they’ve been explicitly through VS Code (eg. by running the Toggle Foo commands)
  • Always update the current state for an extension before toggling, in case it was changed by another tool (this avoids issues where it has to be run twice to have any effect)
  • If we see an event that another tool changed a setting, remove it from our state (so we would no longer restore it)

We can’t tell when the system is modifying the theme though, so if you toggle the theme in VS Code (with Toggle Brightness) we will still set an override that prevents the system toggle from working for the rest of the debug session - but I think that’s resonably understandble.

@jacob314 @jonahwilliams FYI in case you have better ideas. I wonder if it would be better if the tool handled restoring these, since it knows both the resolved and overridden value, and avoids any confusion with who should restore them?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Target of URI doesn't exist 'package:flutter/material.dart ...
Show activity on this post. Open the command palette (ctrl+shift+p), type flutter: get packages (should autocomplete); after it resolves open ...
Read more >
Visual Studio Code - Flutter documentation
Run app in debug, profile, or release mode · Open the launch.json file in VS Code. If you do not have a launch....
Read more >
May 2022 (version 1.68) - Visual Studio Code
Learn what is new in the Visual Studio Code May 2022 Release (1.68)
Read more >
Creating Flavors for Flutter app (VS Code & Android Studio)
Using VS Code · 1. Press ⌘⇧D if you are not in debug tab yet. · 2. Click on configuration beside play button....
Read more >
10 Best Visual Studio Code Extensions for Flutter Development
You might be familiar with installing extensions in VS Code. However, for newbies, I have explained it here. Click on the extension icons...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found