Skip to content

Cupertino alert action buttons don't display properly on web #49877

@guidezpl

Description

@guidezpl

Steps to Reproduce

Run the following self-contained app on web.

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

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  // This widget is the root of your application.
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'textfield repro',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: CupertinoAlertDemo(),
    );
  }
}

class CupertinoAlertDemo extends StatefulWidget {
  const CupertinoAlertDemo({
    Key key,
  }) : super(key: key);

  @override
  _CupertinoAlertDemoState createState() => _CupertinoAlertDemoState();
}

class _CupertinoAlertDemoState extends State<CupertinoAlertDemo> {
  String lastSelectedValue;

  void _showDemoDialog({BuildContext context, Widget child}) {
    showCupertinoDialog<String>(
      context: context,
      builder: (context) => child,
    ).then((value) {
      if (value != null) {
        setState(() {
          lastSelectedValue = value;
        });
      }
    });
  }

  void _onAlertPress(BuildContext context) {
    _showDemoDialog(
      context: context,
      child: CupertinoAlertDialog(
        title: Text('Title'),
        actions: [
          CupertinoDialogAction(
            child: Text('Discard'),
            isDestructiveAction: true,
            onPressed: () =>
                Navigator.of(context, rootNavigator: true).pop('Discard'),
          ),
          CupertinoDialogAction(
            child: Text('Cancel'),
            isDefaultAction: true,
            onPressed: () =>
                Navigator.of(context, rootNavigator: true).pop('Cancel'),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      navigationBar: CupertinoNavigationBar(
        automaticallyImplyLeading: false,
      ),
      child: Builder(
        builder: (context) {
          return Column(
            children: [
              Expanded(
                child: Center(
                  child: CupertinoButton.filled(
                    child: Text(
                      'Show alert',
                    ),
                    onPressed: () {
                      _onAlertPress(context);
                    },
                  ),
                ),
              ),
            ],
          );
        },
      ),
    );
  }
}

Expected results:
Screenshot 2020-01-31 at 12 12 41

Actual results:
Screenshot 2020-01-31 at 12 12 37

Logs
▶ flutter run --verbose -d chrome
[  +18 ms] executing: [/Users/plg/development/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +27 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] fabeb2a16f1d008ab8230f450c49141d35669798
[        ] executing: [/Users/plg/development/flutter/] git describe --match v*.*.* --first-parent --long --tags
[  +11 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v1.14.6-0-gfabeb2a16
[   +5 ms] executing: [/Users/plg/development/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[   +5 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/dev
[        ] executing: [/Users/plg/development/flutter/] git ls-remote --get-url origin
[   +4 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +34 ms] executing: [/Users/plg/development/flutter/] git rev-parse --abbrev-ref HEAD
[   +5 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] dev
[   +4 ms] executing: sw_vers -productName
[  +13 ms] Exit code 0 from: sw_vers -productName
[        ] Mac OS X
[        ] executing: sw_vers -productVersion
[  +11 ms] Exit code 0 from: sw_vers -productVersion
[        ] 10.15.2
[        ] executing: sw_vers -buildVersion
[  +13 ms] Exit code 0 from: sw_vers -buildVersion
[        ] 19C57
[  +20 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +1 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +28 ms] executing: /Users/plg/Library/Android/sdk/platform-tools/adb devices -l
[   +7 ms] Exit code 0 from: /Users/plg/Library/Android/sdk/platform-tools/adb devices -l
[        ] List of devices attached
[   +9 ms] executing: /Users/plg/development/flutter/bin/cache/artifacts/libimobiledevice/idevice_id -h
[ +309 ms] executing: /usr/bin/xcode-select --print-path
[   +7 ms] Exit code 0 from: /usr/bin/xcode-select --print-path
[        ] /Applications/Xcode.app/Contents/Developer
[        ] executing: /usr/bin/xcodebuild -version
[  +87 ms] Exit code 0 from: /usr/bin/xcodebuild -version
[        ] Xcode 11.3.1
           Build version 11C505
[   +3 ms] /usr/bin/xcrun simctl list --json devices
[  +84 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +139 ms] Generating
/Users/plg/development/flutter_app/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
[  +92 ms] Launching lib/main.dart on Chrome in debug mode...
[        ] Building application for the web...
[+5135 ms] Starting daemon...
[ +119 ms] Initializing inputs
[  +10 ms] Reading cached asset graph...
[ +147 ms] Reading cached asset graph completed, took 144ms

[ +134 ms] Checking for updates since last build...
[ +400 ms] Checking for updates since last build completed, took 400ms

[   +8 ms] Initializing inputs
[   +2 ms] Reading cached asset graph...
[        ] Reading cached asset graph completed, took 144ms
[        ] Checking for updates since last build...
[        ] Checking for updates since last build completed, took 400ms
[ +614 ms] About to build [web]...
[   +3 ms] Running build...
[+1086 ms] 1.1s elapsed, 9/10 actions completed.
[ +136 ms] Running build completed, took 1.1s

[        ] Caching finalized dependency graph...
[   +1 ms] Caching finalized dependency graph completed, took 91ms

[   +4 ms] Succeeded after 1.2s with 14 outputs (14 actions)

[   +7 ms] Building application for the web... (completed in 7.8s)
[        ] Attempting to connect to browser instance..
[+2628 ms] Debug service listening on ws://127.0.0.1:62248/F6KLx-tqsrw=

[ +258 ms]       Failed to load asset at path: packages/build_web_compilers/src/dev_compiler/dart_sdk.js.

                          Status code: 404

                          Headers:
                          {
                      "date": "Fri, 31 Jan 2020 11:13:50 GMT",
                      "content-length": "9",
                      "x-frame-options": "SAMEORIGIN",
                      "content-type": "text/plain; charset=utf-8",
                      "x-xss-protection": "1; mode=block",
                      "x-content-type-options": "nosniff",
                      "server": "dart:io with Shelf",
                      "via": "1.1 shelf_proxy"
                    }

                          Content:
                          Not Found}

[  +15 ms] Attempting to connect to browser instance.. (completed in 2.9s)
[   +1 ms] Warning: Flutter's support for web development is not stable yet and hasn't
[        ] been thoroughly tested in production environments.
[        ] For more information see https://flutter.dev/web
[        ] 🔥  To hot restart changes while running, press "r". To hot restart (and refresh the browser), press "R".
[   +1 ms] For a more detailed help message, press "h". To quit, press "q".
[   +7 ms] Debug service listening on ws://127.0.0.1:62248/F6KLx-tqsrw=

flutter doctor -v
[✓] Flutter (Channel dev, v1.14.6, on Mac OS X 10.15.2 19C57, locale en-DE)
    • Flutter version 1.14.6 at /Users/plg/development/flutter
    • Framework revision fabeb2a16f (3 days ago), 2020-01-28 07:56:51 -0800
    • Engine revision c4229bfbba
    • Dart version 2.8.0 (build 2.8.0-dev.5.0 fc3af737c7)


[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/plg/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-stable, build-tools 29.0.2
    • ANDROID_SDK_ROOT = /Users/plg/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C505
    • CocoaPods version 1.8.4

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

[✓] Android Studio
    • Android Studio at /Applications/Android Studio with Blaze.app/Contents
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (5 available)
    • Material Flutter iPad • 00008027-000260981187002E • ios            • iOS 13.3.1
    • Pierre-Louis’ iPhone  • 00008030-001878D22E28802E • ios            • iOS 13.3.1
    • macOS                 • macOS                     • darwin-x64     • Mac OS X
      10.15.2 19C57
    • Chrome                • chrome                    • web-javascript • Google Chrome
      79.0.3945.130
    • Web Server            • web-server                • web-javascript • Flutter Tools

• No issues found!

Metadata

Metadata

Assignees

Labels

customer: galleryRelating to flutter/gallery repository. Please transfer non-framework issues there.customer: web10f: cupertinoflutter/packages/flutter/cupertino repositoryframeworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions