Skip to content

Unable to Change TextSelectionHandleColor using Theme Widget #34640

@vijayaragavangkf

Description

@vijayaragavangkf

I am trying to change textSelectionColor and textSelectionHandleColor for particular TextField(not all). When I used Theme Widget as parent for that TextField it still uses the textSelectionHandleColor from MaterialApp. The textSelectionColor is woking fine.

Example Code:

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Summa App",
      theme: ThemeData(
        textSelectionHandleColor: Colors.red,
      ),
      home: MyTextField(),
    );
  }
}

class MyTextField extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Builder(
          builder: (context2){
            return Theme(
              data: Theme.of(context2).copyWith(
                textSelectionHandleColor: Colors.green,  //Not being used
              ),
              child: TextField(),
            );
          },
        ),
      ),
    );
  }
}

Flutter Doctor:

[√] Flutter (Channel stable, v1.5.4-hotfix.2, on Microsoft Windows [Version 10.0.16299.1087], locale en-IN)
    • Flutter version 1.5.4-hotfix.2 at D:\Installed\FlutterSDK
    • Framework revision 7a4c33425d (7 weeks ago), 2019-04-29 11:05:24 -0700
    • Engine revision 52c7a1e849
    • Dart version 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:\Users\Flower\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[√] Android Studio (version 3.4)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 36.1.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[√] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

• No issues found!

Metadata

Metadata

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