Skip to content

The page is extremely laggy when switching themes. #3428

@temeipu-offical

Description

@temeipu-offical

When I use Getx to manage multiple theme colors, I find that after switching themes, I need to rebuild all the pages related to the theme color, even when using Theme.of(context). This causes the page loading to be very slow. Are there any optimization ideas?
I discovered that when using Getx to switch themes, the underlying code calls the update() method. Could this be the root cause of the problem?
The version I'm using is ^5.0.0-release-candidate-9.3.2

void setTheme(ThemeData value) {
    if (config.darkTheme == null) {
      config = config.copyWith(theme: value);
    } else {
      if (value.brightness == Brightness.light) {
        config = config.copyWith(theme: value);
      } else {
        config = config.copyWith(darkTheme: value);
      }
    }
    update();
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions