Skip to content

CupertinoTextField not changing background color when disabled #78010

Closed

Description

@HarukaMa

Steps to Reproduce

  1. Run flutter create bug.
  2. Change content of lib/main.dart to:
import 'package:flutter/cupertino.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CupertinoApp(
      title: 'Flutter Demo',
      theme: CupertinoThemeData(),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      child: SafeArea(
        child: Padding(
          padding: const EdgeInsets.all(20.0),
          child: Column(
            children: [
              CupertinoTextField(
                enabled: true,
              ),
              CupertinoTextField(
                enabled: false,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
  1. Observe that two CupertinoTextFields have same background color.

Expected results: According to the document, disabled text field should have light gray background.

Actual results: Disabled text field still have white background (verified using Digital Color Meter.app).

Logs
# MrX @ MacBook-Pro in /tmp/test [18:03:09] C:64
$ flutter analyze
Analyzing test...
No issues found! (ran in 2.9s)
# MrX @ MacBook-Pro in /tmp/test [18:03:26] C:64
$ flutter doctor -v
[✓] Flutter (Channel stable, 2.0.1, on Mac OS X 10.15.7 19H15 darwin-x64, locale ja-JP)
    • Flutter version 2.0.1 at /Users/MrX/flutter
    • Framework revision c5a4b4029c (8 days ago), 2021-03-04 09:47:48 -0800
    • Engine revision 40441def69
    • Dart version 2.12.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/MrX/Library/Android/sdk
    • Platform android-30, build-tools 29.0.2
    • Java binary at: /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_222-b10)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /Applications/Chromium.app/Contents/MacOS/Chromium

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.2)
    • IntelliJ at /Users/MrX/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 54.0.3
    • Dart plugin version 203.7759

[✓] Connected device (3 available)
    • はるかのiPhone (Dead) (mobile) • *snip* • ios            • iOS 13.6.1
    • iPhone 12 mini (mobile)    • 7CC41F12-75AD-4B4D-B086-EB0D6E9FDA5A     • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
    • Chrome (web)               • chrome                                   • web-javascript • Chromium 87.0.4280.88
    ! Error: はるかのiPhone is busy: Waiting for Device. Xcode will continue when はるかのiPhone is finished. (code -10)
    ! Error: はるかのiPhone (Dead) is busy: Copying cache files from device. Xcode will continue when はるかのiPhone (Dead) is finished. (code -10)

! Doctor found issues in 1 category.

Activity

  1. pedromassangocode commented on Mar 12, 2021

    @pedromassangocode

    Screen Shot 2021-03-12 at 12 07 14

    flutter doctor -v
    [✓] Flutter (Channel stable, 2.0.1, on macOS 11.2.2 20D80 darwin-x64, locale en-AO)
        • Flutter version 2.0.1 at /Users/pedromassango/Code/flutter_stable
        • Framework revision c5a4b4029c (8 days ago), 2021-03-04 09:47:48 -0800
        • Engine revision 40441def69
        • Dart version 2.12.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
        • Android SDK at /Users/pedromassango/Library/Android/sdk
        • Platform android-30, build-tools 30.0.2
        • ANDROID_HOME = /Users/pedromassango/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_242-release-1644-b3-6915495)
        • All Android licenses accepted.
    
    [!] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.4, Build version 12D4e
        ! CocoaPods 1.9.3 out of date (1.10.0 is recommended).
            CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
            Without CocoaPods, plugins will not work on iOS or macOS.
            For more info, see https://flutter.dev/platform-plugins
          To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.1)
        • 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 1.8.0_242-release-1644-b3-6915495)
    
    [✓] IntelliJ IDEA Community Edition (version 2020.3.2)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 54.0.3
        • Dart plugin version 203.7759
    
    [✓] VS Code (version 1.54.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.16.0
    
    [✓] Connected device (2 available)
        • macOS (desktop) • macos  • darwin-x64     • macOS 11.2.2 20D80 darwin-x64
        • Chrome (web)    • chrome • web-javascript • Google Chrome 89.0.4389.82
    
    ! Doctor found issues in 1 category.
    [✓] Flutter (Channel master, 2.1.0-11.0.pre.228, on macOS 11.2.2 20D80 darwin-x64, locale en-AO)
        • Flutter version 2.1.0-11.0.pre.228 at /Users/pedromassango/Code/flutter_master
        • Framework revision 2daac9201a (2 minutes ago), 2021-03-11 22:18:15 -0800
        • Engine revision 1b68503bc8
        • Dart version 2.13.0 (build 2.13.0-125.0.dev)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
        • Android SDK at /Users/pedromassango/Library/Android/sdk
        • Platform android-30, build-tools 30.0.2
        • ANDROID_HOME = /Users/pedromassango/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_242-release-1644-b3-6915495)
        • All Android licenses accepted.
    
    [!] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.4, Build version 12D4e
        ! CocoaPods 1.9.3 out of date (1.10.0 is recommended).
            CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
            Without CocoaPods, plugins will not work on iOS or macOS.
            For more info, see https://flutter.dev/platform-plugins
          To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.1)
        • 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 1.8.0_242-release-1644-b3-6915495)
    
    [✓] IntelliJ IDEA Community Edition (version 2020.3.2)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 54.0.3
        • Dart plugin version 203.7759
    
    [✓] VS Code (version 1.54.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.16.0
    
    [✓] Connected device (2 available)
        • macOS (desktop) • macos  • darwin-x64     • macOS 11.2.2 20D80 darwin-x64
        • Chrome (web)    • chrome • web-javascript • Google Chrome 89.0.4389.82
    
    ! Doctor found issues in 1 category.
  2. added
    p: cupertino_uicupertino_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    a: text inputEntering text in a text field or keyboard related problems
    and removed
    in triagePresently being triaged by the triage team
    on Mar 12, 2021
  3. HarukaMa commented on Mar 12, 2021

    @HarukaMa
    ContributorAuthor

    Seems like the issue is on

    color: enabled ? decorationColor : (decorationColor ?? disabledColor),

    Why decorationColor is always preferred even when the widget is disabled?

    Changing to

          color: enabled ? decorationColor : disabledColor,

    seems fixes this:
    image
    (the order is not the same on my testing code)

  4. github-actions commented on Aug 4, 2021

    @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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: text inputEntering text in a text field or keyboard related problemsfound in release: 2.1Found to occur in 2.1frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cupertino_uicupertino_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions