Skip to content

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

@VibrantTower

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.

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_trackerf: material designflutter/packages/flutter/material repository.found 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 onr: 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