LoginSignup
0
0

More than 1 year has passed since last update.

FlutterでiOSのselectionHandleColorを設定する方法

Last updated at Posted at 2022-09-08

概要

iOSにおいて、テキスト選択時のハンドルカラーをtextSelectionThemeで変更することができず、つまずいたので方法を紹介します。

スクリーンショット 2022-09-09 0.07.35.png

Androidの場合

テキスト選択時の設定は全てtextSelectionThemeで設定できます。

ThemeData(
  // ...省略...
  textSelectionTheme: TextSelectionThemeData(
    selectionColor: selectionColor,
    cursorColor: cursorColor,
    selectionHandleColor: selectionHandleColor,
  ),
  // ...省略...
);

iOSの場合

selectionColorcursorColortextSelectionThemeで設定することができますが、セレクト時のハンドルカラーについては、selectionHandleColorを設定してもprimarySwatchの色のままになってしまいます。
iOSでは、selectionHandleの色を変更するために、cupertinoOverrideThemeを用いる必要があります。

ThemeData(
  // ...省略...
  textSelectionTheme: TextSelectionThemeData(
    selectionColor: selectionColor,
    cursorColor: cursorColor,
    selectionHandleColor: selectionHandleColor,
  ),
  cupertinoOverrideTheme: CupertinoThemeData(
    primaryColor: selectionHandleColor,
  ),
  // ...省略...
);

参考文献

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0