Skip to content

[flutter_adaptive_scaffold] unnecessary rebuilds when checking if breakpoint is active  #146801

@waleedf112

Description

@waleedf112

Steps to reproduce

  1. invoke Breakpoints.<BREAK-POINT>.isActive(context) somewhere in your code.
  2. interact with the app in a way that would change any property of MediaQuery, like changing the OS theme, opening the keyboard, etc.

Code sample

Code sample
class MyScreen extends StatefulWidget {
  const MyScreen({super.key});

  @override
  State<MyScreen> createState() => _MyScreenState();
}

class _MyScreenState extends State<MyScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('last rebuild: ${DateTime.now()}'),
            const TextField(
              decoration: InputDecoration(hintText: 'open keyboard to trigger rebuilds'),
            ),
            FilledButton(
              onPressed: () {
                Breakpoints.small.isActive(context);
              },
              child: const Text('press to trigger the bug'),
            ),
          ],
        ),
      ),
    );
  }
}

What target platforms are you seeing this bug on?

Android, iOS

OS/Browser name and version | Device information

Android 14

Does the problem occur on emulator/simulator as well as on physical devices?

Yes

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.19.5, on macOS 14.3.1 23D60 darwin-arm64, locale en-SA)
    • Flutter version 3.19.5 on channel stable at /Users/waleed/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 300451adae (3 weeks ago), 2024-03-27 21:54:07 -0500
    • Engine revision e76c956498
    • Dart version 3.3.3
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/waleed/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.15.2

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.86.2)
    • VS Code at /Users/waleed/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.86.0

[✓] Connected device (3 available)
    • SM F731B (mobile)           • R5CW7235F3F   • android-arm64 • Android 14 (API 34)
    • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 14 (API 34) (emulator)
    • macOS (desktop)             • macos         • darwin-arm64  • macOS 14.3.1 23D60 darwin-arm64

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

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.19Found to occur in 3.19found in release: 3.22Found to occur in 3.22has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: flutter_adaptive_scaffoldThe flutter_adaptive_scaffold packagepackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions