LoginSignup
4
1

More than 3 years have passed since last update.

Flutterでテキスト内リンクを作る

Posted at

はじめに

業務でテキスト内リンクを作成するためにRichTextを使ったので、備忘録代わりにまとめてみます。

動作イメージ

スクリーンショット 2021-02-26 16.19.09.png

実装

RichText(
    text: TextSpan(children: [
  const TextSpan(
      text: 'お問合わせは',
      style: TextStyle(color: Colors.black)),
  TextSpan(
      text: 'こちら',
      style: const TextStyle(color: Colors.blue),
      recognizer: TapGestureRecognizer()
        ..onTap = () {
          // タップ時
        }),
  const TextSpan(
      text: 'からお願いします。',
      style: TextStyle(color: Colors.black))
]))

その他

テキストの一部をイタリック体にしたり、下線を引くこともできるようです。

4
1
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
4
1