Skip to content

CupertinoSheetRoute - Top area buttons have visual feedback but don't trigger onPressed actions #166965

@len0529

Description

@len0529

Steps to reproduce

  1. Create a CupertinoSheet with multiple rows of buttons
  2. Place some buttons near the very top of the sheet
  3. Place identical buttons slightly lower in the sheet
  4. Observe that the top buttons only show visual feedback but don't trigger actions
  5. The identical buttons placed slightly lower work properly

Expected results

All buttons should respond to taps and trigger their onPressed callbacks.

Actual results

Buttons in the topmost area show visual feedback when tapped but don't trigger their onPressed callbacks. The same buttons placed slightly lower work correctly.

Code sample

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

/// Flutter code sample for [showCupertinoSheet].

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

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

  @override
  Widget build(BuildContext context) {
    return const CupertinoApp(title: 'Cupertino Sheet', home: HomePage());
  }
}

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

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      navigationBar: const CupertinoNavigationBar(
        middle: Text('Sheet Example'),
        automaticBackgroundVisibility: false,
      ),
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            CupertinoButton.filled(
              onPressed: () {
                showCupertinoSheet<void>(
                  context: context,
                  useNestedNavigation: true,
                  pageBuilder: (BuildContext context) => const _SheetScaffold(),
                );
              },
              child: const Text('Open Sheet'),
            ),
            const SizedBox(height: 20),
            CupertinoButton.filled(
              onPressed: () {
                showCupertinoSheet<void>(
                  context: context,
                  useNestedNavigation: true,
                  pageBuilder:
                      (BuildContext context) => const _CupertinoStyleSheet(),
                );
              },
              child: const Text('Open Cupertino Style Sheet'),
            ),
          ],
        ),
      ),
    );
  }
}

class _SheetScaffold extends StatelessWidget {
  const _SheetScaffold();

  @override
  Widget build(BuildContext context) {
    return const CupertinoPageScaffold(
      child: _SheetBody(title: 'CupertinoSheetRoute'),
    );
  }
}

class _SheetBody extends StatelessWidget {
  const _SheetBody({required this.title});

  final String title;

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        CupertinoButton.filled(
          onPressed: () {
            CupertinoSheetRoute.popSheet(context);
          },
          child: const Text('Pop Whole Sheet1(Can not click)'),
        ),
        CupertinoButton.filled(
          onPressed: () {
            CupertinoSheetRoute.popSheet(context);
          },
          child: const Text('Pop Whole Sheet2(Can click)'),
        ),
        CupertinoButton.filled(
          onPressed: () {
            CupertinoSheetRoute.popSheet(context);
          },
          child: const Text('Pop Whole Sheet3(Can click)'),
        ),
      ],
    );
  }
}

class _CupertinoStyleSheet extends StatelessWidget {
  const _CupertinoStyleSheet();

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      child: Material(child: _CupertinoSheetContent()),
    );
  }
}

class _CupertinoSheetContent extends StatefulWidget {
  @override
  State<_CupertinoSheetContent> createState() => _CupertinoSheetContentState();
}

class _CupertinoSheetContentState extends State<_CupertinoSheetContent> {
  final _textController = TextEditingController();
  bool _isLoading = false;

  @override
  void dispose() {
    _textController.dispose();
    super.dispose();
  }

  void _save() {
    setState(() {
      _isLoading = true;
    });
    Future.delayed(const Duration(seconds: 1), () {
      if (mounted) {
        setState(() {
          _isLoading = false;
        });
        CupertinoSheetRoute.popSheet(context);
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
          child: Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  CupertinoButton(
                    padding: EdgeInsets.zero,
                    onPressed: () {
                      CupertinoSheetRoute.popSheet(context);
                    },
                    child: const Text(
                      'Cancel (x)',
                      style: TextStyle(
                        fontSize: 17,
                        fontWeight: FontWeight.w400,
                      ),
                    ),
                  ),
                  CupertinoButton(
                    padding: EdgeInsets.zero,
                    onPressed: _isLoading ? null : _save,
                    child:
                        _isLoading
                            ? const CupertinoActivityIndicator()
                            : const Text(
                              'Save(x)',
                              style: TextStyle(
                                fontSize: 17,
                                fontWeight: FontWeight.w600,
                                color: CupertinoColors.activeBlue,
                              ),
                            ),
                  ),
                ],
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  CupertinoButton(
                    padding: EdgeInsets.zero,
                    onPressed: () {
                      CupertinoSheetRoute.popSheet(context);
                    },
                    child: const Text(
                      'Cancel (v)',
                      style: TextStyle(
                        fontSize: 17,
                        fontWeight: FontWeight.w400,
                      ),
                    ),
                  ),
                  CupertinoButton(
                    padding: EdgeInsets.zero,
                    onPressed: _isLoading ? null : _save,
                    child:
                        _isLoading
                            ? const CupertinoActivityIndicator()
                            : const Text(
                              'Save(v)',
                              style: TextStyle(
                                fontSize: 17,
                                fontWeight: FontWeight.w600,
                                color: CupertinoColors.activeBlue,
                              ),
                            ),
                  ),
                ],
              ),
            ],
          ),
        ),
        const Padding(
          padding: EdgeInsets.fromLTRB(16, 0, 16, 8),
          child: Text(
            'New Note',
            style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
          ),
        ),

        const Divider(height: 1),

        Expanded(
          child: CupertinoTextField(
            controller: _textController,
            placeholder: 'Type something...',
            style: const TextStyle(fontSize: 17),
            maxLines: null,
            keyboardType: TextInputType.multiline,
          ),
        ),
      ],
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
2025-04-11.3.00.02.mov

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.2, on macOS 15.3.2 24D81 darwin-arm64, locale zh-Hant-TW)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 16.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.3)
[✓] VS Code (version 1.99.0)
[✓] Connected device (5 available)
[✓] Network resources

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: cupertinoflutter/packages/flutter/cupertino repositoryfound in release: 3.29Found to occur in 3.29found in release: 3.31Found to occur in 3.31frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-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