0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Flutter] TextFieldのキーボードをデフォルトで日本語キーボードに設定する

Posted at

現状

日本語入力したいのに英語キーボードが表示される。
日本語キーボードに切り替える手間があるので、デフォルトで日本語キーボードにしたい。

手順

flutter_localizations をインストール

pubspec.yaml に以下を追加

dependencies:
  flutter_localizations:
    sdk: flutter

追加した状態で以下を実行

flutter pub get

main.dart を修正する

main.dartの MaterialApp 内に以下を追加する

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

MaterialApp(
  supportedLocales: const [Locale('ja', 'JP')],
  localizationsDelegates: const [
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
    DefaultCupertinoLocalizations.delegate,
  ],
  ..省略..
)

hot reload して動作確認

デフォルトで日本語キーボードが表示されるようになった🎉

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?