devtools icon indicating copy to clipboard operation
devtools copied to clipboard

Support editing textScaleFactor, brightness, etc. in devtools

Open bryanoltman opened this issue 2 years ago • 9 comments

The ability to switch between dark/light mode, adjust text scale, switch target platform (iOS, Android, etc.) would allow devs to quickly verify that their widget functions as expected in a variety of environments.

To illustrate the benefit this would provide, the current flow for switching between dark/light mode on an iOS simulator is:

  • Open the Settings app
  • Open the Developer page
  • Toggle "Dark appearance"

Even worse, changing text scale:

  • Open the Settings app
  • Open the Accessibility page
  • Open the Display & Text Size page
  • Open the Larger Text page
  • Drag the slider up or down to adjust text scale

Having a way to do this without so many clicks and without having to leave the app would be phenomenal.

https://pub.dev/packages/device_preview demonstrates a version of the functionality that would be great to have as part of DevTools.

bryanoltman avatar Jul 13 '22 20:07 bryanoltman

We would need to add functionality in the Flutter framework to change these settings, and then expose hooks via service extensions that DevTools can call. @goderbauer does functionality already exist in the framework to change these settings? Would adding this functionality be trivial?

kenzieschmoll avatar Jul 13 '22 20:07 kenzieschmoll

dark/light mode, adjust text scale, switch target platform

Two if these are already exposed on the command line when you do a flutter run. From the help command:

o Simulate different operating systems.                                      (defaultTargetPlatform)
b Toggle platform brightness (dark and light mode).                        (debugBrightnessOverride)

So, for those two we should already have all the hooks necessary in place and devtools could just call the same hooks flutter_tools is currently calling here.

Adding "text scale" to this seem reasonably straight forward and could follow the same path we already use for the other two options.

goderbauer avatar Jul 13 '22 21:07 goderbauer

@goderbauer do these options exist outside of the CLI? For example, if I launched my app from VS Code, how would I access this functionality?

bryanoltman avatar Jul 13 '22 21:07 bryanoltman

A service extension already exists for the target platform - we just need to expose this in DevTools (https://github.com/flutter/devtools/issues/2780). For the toggle platform brightness, I suspect we'll have to add the service extension first and then expose it from DevTools. Same for the text scale option once the functionality for changing it exists in the framework.

kenzieschmoll avatar Jul 13 '22 22:07 kenzieschmoll

if I launched my app from VS Code, how would I access this functionality?

I am not familiar with the VS Code plugin, so I don't know if the functionality is exposed there. The plugin could call into the same APIs the CLI tool is using, though. @DanTup may know if the feature already exists.

For the toggle platform brightness, I suspect we'll have to add the service extension first and then expose it from DevTools.

Can you just use this one? https://github.com/flutter/flutter/blob/526ca0d498120e93efbdd25f8824825dd7b6b13f/packages/flutter/lib/src/foundation/binding.dart#L498

Same for the text scale option once the functionality for changing it exists in the framework.

Correct, I don't think we have this one exposed yet. Shouldn't be a problem, though.

goderbauer avatar Jul 13 '22 22:07 goderbauer

I am not familiar with the VS Code plugin so I don't know if the functionality is exposed there.

@DanTup does VS code expose toggles like this outside of the embedded DevTools? Would it be better to just expose these through the inspector so that both IDEs can benefit?

Can you just use this one? https://github.com/flutter/flutter/blob/526ca0d498120e93efbdd25f8824825dd7b6b13f/packages/flutter/lib/src/foundation/binding.dart#L498

Yep - didn't know a service extension to toggle the debug bool already existed, but that's exactly what we need.

kenzieschmoll avatar Jul 13 '22 22:07 kenzieschmoll

We do already expose some of these services as commands in VS Code (in the command palette). There's already brightness toggle and target platform, but we don't have text scale factor.:

Screenshot 2022-07-14 at 09 54 17

If you're not actively using DevTools then there's probably some value having them exposed here, although it may make sense to just stick to the simplest/most common ones to reduce the maintenance (and have a larger set in DevTools).

DanTup avatar Jul 14 '22 08:07 DanTup

Oh interesting! I've been developing Flutter in VS Code for something like 3 years now and had no idea those commands existed.

bryanoltman avatar Jul 14 '22 14:07 bryanoltman

@chingjun when we start working on VSCode support, I assume these vm services functions will work the same way inside Google?

xster avatar Jul 15 '22 22:07 xster

device_preview has not been maintained for over a year. The development experience would be great if devtools supported similar functionality.

KoheiKanagu avatar Aug 19 '23 12:08 KoheiKanagu