Skip to content

SearchDelegate: appBarTheme method won't change the cursorColor. #52483

@Vellutia

Description

@Vellutia
class CurrencySearch extends SearchDelegate {
  final bool isTop;

  CurrencySearch(this.isTop)
      : super(
          keyboardType: TextInputType.text,
          textInputAction: TextInputAction.none,
        );

  @override
  ThemeData appBarTheme(BuildContext context) {
    assert(context != null);
    final ThemeData theme = Theme.of(context);
    assert(theme != null);
    return theme.copyWith(
      inputDecorationTheme: theme.inputDecorationTheme.copyWith(
        hintStyle: theme.primaryTextTheme.headline6,
      ),
      textTheme: theme.primaryTextTheme,
      // this doesn't work
      cursorColor: Colors.red
    );
  }

I am not sure why, but the color of the cursor won't change. The color only follows the value provided on the MaterialApp.

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      // the cursor color on SearchDelegate follows this
      theme: ThemeData.dark().copyWith(cursorColor: Colors.red),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: MyWidget(),
        ),
      ),
    );
  }
}

flutter doctor -v

[√] Flutter (Channel master, v1.15.20, on Microsoft Windows [Version 10.0.18362.719], locale en-ID)
    • Flutter version 1.15.20 at C:\flutter
    • Framework revision 4049889d9e (2 days ago), 2020-03-10 20:05:41 -0700
    • Engine revision 0e2c8feeeb
    • Dart version 2.8.0 (build 2.8.0-dev.12.0 9983424a3c)


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\feder\AppData\Local\Android\Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 3.5)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 41.1.2
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] VS Code (version 1.43.0)
    • VS Code at C:\Users\feder\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.8.1

[√] Connected device (2 available)
    • Chrome     • chrome     • web-javascript • Google Chrome 80.0.3987.122
    • Web Server • web-server • web-javascript • Flutter Tools

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions