Skip to content

PageView item does not dispose when widget with NoSplash.splashFactory is tapped #136441

Closed

Description

@VibrantTower

Is there an existing issue for this?

Steps to reproduce

  1. Click on the button in a PageView item
  2. Swipe the PageView to the next item

Expected results

  1. The PageView item should dispose when the FilledButton is tapped

I'm able to fix this issue by removing ThemeData(splashFactory: NoSplash.splashFactory) (every item will dispose correctly), but my app requires this custom theme.

Actual results

  1. The PageView item does not dispose, only if the button is tapped and the splash factory is NoSplash.splashFactory

Code sample

Code sample
import 'package:flutter/material.dart';

void main() => runApp(const PageViewExampleApp());

class PageViewExampleApp extends StatelessWidget {
  const PageViewExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(splashFactory: NoSplash.splashFactory),
      home: Scaffold(
        appBar: AppBar(title: const Text('PageView Sample')),
        body: const PageViewExample(),
      ),
    );
  }
}

class PageViewExample extends StatelessWidget {
  const PageViewExample({super.key});

  @override
  Widget build(BuildContext context) {
    final PageController controller = PageController();
    return PageView(
      controller: controller,
      children: const <Widget>[
        Page(pageNumber: 1),
        Page(pageNumber: 2),
        Page(pageNumber: 3),
      ],
    );
  }
}

class Page extends StatefulWidget {
  final int pageNumber;

  const Page({
    super.key,
    required this.pageNumber,
  });

  @override
  State<Page> createState() => _PageState();
}

class _PageState extends State<Page> {
  @override
  void dispose() {
    print("Disposed page: ${widget.pageNumber}");
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: FilledButton(
        onPressed: () {},
        child: Text('Page ${widget.pageNumber}'),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
screen_recording.mp4

If the user does not tap the button, the PageView item widget will dispose. If the user taps the button without a splash factory, the PageView item will not dispose.

Logs

Logs
Restarted application in 709ms.
flutter: Disposed page: 1

Flutter Doctor output

Doctor output
[✓] Flutter (Channel master, 3.16.0-10.0.pre.46, on macOS 13.6 22G120
    darwin-x64, locale en-US)
    • Flutter version 3.16.0-10.0.pre.46 on channel master at
      /Users/jcode/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c0d19ca561 (4 hours ago), 2023-10-11 23:33:07
      -0400
    • Engine revision d00fabf0b9
    • Dart version 3.3.0 (build 3.3.0-14.0.dev)
    • DevTools version 2.28.1

[!] Android toolchain - develop for Android devices (Android SDK version
    33.0.2)
    • Android SDK at /Users/jcode/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more
      details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See
      https://flutter.dev/docs/get-started/install/macos#android-setup
      for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.13.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google
      Chrome

[✓] Android Studio (version 2022.3)
    • 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.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.83.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.74.0

[✓] Connected device (3 available)
    • iPhone 14 Pro Max (mobile) • 85347627-43C3-4413-7D7D-04A2C4412FC2 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)            • macos                                • darwin-x64     • macOS 13.6 22G120 darwin-x64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 117.0.5938.149

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

! Doctor found issues in 1 category.

Activity

  1. dam-ease commented on Oct 12, 2023

    @dam-ease

    Hi @VibrantTower. Thanks for filing this. I can reproduce this on the latest master and stable channels following the steps highlighted above.
    Also, this isn't peculiar to buttons, replacing the FilledButton widget with InkWell also reproduces this issue.

    Code Sample with InkWell

    import 'package:flutter/material.dart';
    
    void main() => runApp(const PageViewExampleApp());
    
    class PageViewExampleApp extends StatelessWidget {
      const PageViewExampleApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          theme: ThemeData(splashFactory: NoSplash.splashFactory),
          home: Scaffold(
            appBar: AppBar(title: const Text('PageView Sample')),
            body: const PageViewExample(),
          ),
        );
      }
    }
    
    class PageViewExample extends StatelessWidget {
      const PageViewExample({super.key});
    
      @override
      Widget build(BuildContext context) {
        final PageController controller = PageController();
        return PageView(
          controller: controller,
          children: const <Widget>[
            Page(pageNumber: 1),
            Page(pageNumber: 2),
            Page(pageNumber: 3),
          ],
        );
      }
    }
    
    class Page extends StatefulWidget {
      final int pageNumber;
    
      const Page({
        super.key,
        required this.pageNumber,
      });
    
      @override
      State<Page> createState() => _PageState();
    }
    
    class _PageState extends State<Page> {
      @override
      void dispose() {
        print("Disposed page: ${widget.pageNumber}");
        super.dispose();
      }
    
      @override
      Widget build(BuildContext context) {
        return Center(
          child: InkWell(
            onTap: () {},
            child: Text('Page ${widget.pageNumber}'),
          ),
        );
      }
    }
    

    stable, master flutter doctor -v

    [✓] Flutter (Channel stable, 3.13.7, on macOS 13.0 22A380 darwin-arm64, locale
        en-NG)
        • Flutter version 3.13.7 on channel stable at
          /Users/damilolaalimi/sdks/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 2f708eb839 (3 days ago), 2023-10-09 09:58:08 -0500
        • Engine revision a794cf2681
        • Dart version 3.1.3
        • DevTools version 2.25.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/damilolaalimi/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • ANDROID_HOME = /Users/damilolaalimi/Library/Android/sdk
        • Java binary at: /Applications/Android
          Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build
          17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14E300c
        • CocoaPods version 1.12.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.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.6+0-17.0.6b802.4-9586694)
    
    [!] Android Studio (version unknown)
        • Android Studio at /Users/damilolaalimi/Downloads/Android Studio
          Preview.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
        ✗ Unable to determine Android Studio version.
        • Java version OpenJDK Runtime Environment (build
          17.0.7+0-17.0.7b1000.6-10550314)
    
    [✓] VS Code (version 1.82.3)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.50.0
    
    [✓] Connected device (4 available)
        • sdk gphone64 arm64 (mobile) • emulator-5556                        •
          android-arm64  • Android 14 (API 34) (emulator)
        • iPhone XS (mobile)          • 3CFD1268-0D52-486E-A12E-6E136E972D94 • ios
          • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
        • macOS (desktop)             • macos                                •
          darwin-arm64   • macOS 13.0 22A380 darwin-arm64
        • Chrome (web)                • chrome                               •
          web-javascript • Google Chrome 117.0.5938.149
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
    [✓] Flutter (Channel master, 3.16.0-10.0.pre.46, on macOS 13.0 22A380 darwin-arm64, locale en-NG)
        • Flutter version 3.16.0-10.0.pre.46 on channel master at /Users/damilolaalimi/fvm/versions/master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision c0d19ca561 (7 hours ago), 2023-10-11 23:33:07 -0400
        • Engine revision d00fabf0b9
        • Dart version 3.3.0 (build 3.3.0-14.0.dev)
        • DevTools version 2.28.1
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/damilolaalimi/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • ANDROID_HOME = /Users/damilolaalimi/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14E300c
        • CocoaPods version 1.12.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.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.6+0-17.0.6b802.4-9586694)
    
    [!] Android Studio (version unknown)
        • Android Studio at /Users/damilolaalimi/Downloads/Android Studio Preview.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
        ✗ Unable to determine Android Studio version.
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    
    [✓] VS Code (version 1.82.3)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.50.0
    
    [✓] Connected device (4 available)
        • sdk gphone64 arm64 (mobile) • emulator-5556                        • android-arm64  • Android 14 (API 34) (emulator)
        • iPhone XS (mobile)          • 3CFD1268-0D52-486E-A12E-6E136E972D94 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
        • macOS (desktop)             • macos                                • darwin-arm64   • macOS 13.0 22A380 darwin-arm64
        • Chrome (web)                • chrome                               • web-javascript • Google Chrome 117.0.5938.149
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    

  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on Oct 12, 2023
  3. changed the title [-]PageView item does not dispose if tapping NoSplash.splashFactory button[/-] [+]PageView item does not dispose when widget with `splashFactory: NoSplash.splashFactory` is tapped[/+] on Oct 13, 2023
  4. changed the title [-]PageView item does not dispose when widget with `splashFactory: NoSplash.splashFactory` is tapped[/-] [+]`PageView` item does not dispose when widget with `NoSplash.splashFactory` is tapped[/+] on Oct 13, 2023
  5. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on Oct 18, 2023
  6. added a commit that references this issue on Nov 16, 2023
    d345ff0
  7. added
    a: leak trackingIssues and PRs related to memory leaks detected by leak_tracker
    on Nov 16, 2023
  8. added
    r: fixedIssue is closed as already fixed in a newer version
    on Nov 20, 2023
  9. github-actions commented on Dec 4, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  10. locked as resolved and limited conversation to collaborators on Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: leak trackingIssues and PRs related to memory leaks detected by leak_trackerfound in release: 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions