Skip to content

Nesting PointerInterceptor platform views with Dropdown will cause crash on iOS #151535

@wenkaifan0720

Description

@wenkaifan0720

Steps to reproduce

  1. Create a DropdownButton wrapped in a PointerInterceptor.
  2. Populate the items in the DropdownButton with some widget that is also wrapped in a PointerInterceptor.
  3. Launch on iOS and click on the dropdown. The app will crash in a few seconds.

Expected results

The app doesn't crash.

Actual results

The app crashes within a few seconds.

Code sample

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

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String? selected = "apple";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: PointerInterceptor(
            child: Padding(
              padding: MediaQuery.viewInsetsOf(context),
              child: Container(
                height: MediaQuery.sizeOf(context).height * 1,
                padding: EdgeInsets.all(40),
                child: DropdownButton<String>(
                  value: selected,
                  onChanged: (val) {
                    setState(() {
                      selected = val;
                    });
                  },
                  items: [
                    "apple",
                    "banana",
                    "cherry",
                    "dragonfruit",
                    "elderberry",
                    "fig",
                    "grape",
                    "honeydew",
                    "kiwi",
                    "lemon",
                    "mango",
                    "nectarine",
                    "orange",
                    "papaya",
                    "quince",
                  ]
                      .map(
                        (option) => DropdownMenuItem(
                      value: option,
                      child: PointerInterceptor(child: Text(option)),
                    ),
                  )
                      .toList(),
                ),
              ),
            )),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
Lost connection to device.
Error executing osascript: -2

the Dart compiler exited unexpectedly.

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] VS Code (version 1.91.0)
[✓] Connected device (4 available)
    ! Error: Browsing on the local area network for iPad (2). Ensure the device is unlocked and attached with a cable or
      associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

• No issues found!

Metadata

Metadata

Assignees

Labels

a: platform-viewsEmbedding Android/iOS views in Flutter appsc: crashStack traces logged to the consolee: OS-version specificAffects only some versions of the relevant operating systemengineflutter/engine related. See also e: labels.found in release: 3.22Found to occur in 3.22found in release: 3.24Found to occur in 3.24has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions