k4zek4ge
10/29/2019 - 10:14 AM

Richtext clickable

import 'package:flutter/material.dart';

Container(
    padding: EdgeInsets.all(10),
    child: Center(
      child: RichText(
        text: TextSpan(
            text: 'Don\'t have an account?',
            style: TextStyle(
                color: Colors.black, fontSize: 18),
            children: <TextSpan>[
              TextSpan(text: ' Sign up',
                  style: TextStyle(
                      color: Colors.blueAccent, fontSize: 18),
                  recognizer: TapGestureRecognizer()
                    ..onTap = () {
                      // navigate to desired screen
                    }
              )
            ]
        ),
      ),
    )
)

Container(
    color: Colors.black,
    padding: EdgeInsets.all(10),
    child: Center(
        child: RichText(
          text: TextSpan(
              text: 'GitHub is a development platform inspired by the way you work. From ',
              style: TextStyle(
                  color: Colors.grey,
                  fontSize: 20,
                  fontWeight: FontWeight.bold),
              children: <TextSpan>[
                TextSpan(text: 'open source',
                    style: TextStyle(
                        color: Colors.white,
                        fontSize: 20,
                        fontWeight: FontWeight.bold,
                        decoration: TextDecoration.underline),
                    recognizer: TapGestureRecognizer()
                      ..onTap = () {
                        // open desired screen
                      }
                ),
                TextSpan(
                    text: ' to ',
                    style: TextStyle(color: Colors.grey,
                        fontSize: 20,
                        fontWeight: FontWeight.bold)
                ),
                TextSpan(
                    text: 'business,',
                    style: TextStyle(
                        color: Colors.white,
                        fontSize: 20,
                        fontWeight: FontWeight.bold,
                        decoration: TextDecoration.underline),
                    recognizer: TapGestureRecognizer()
                      ..onTap = () {
                        // open desired screen
                      }
                ),
                TextSpan(
                    text: ' you can host and review code, manage projects, and build software alongside 36 million developers.',
                    style: TextStyle(color: Colors.grey,
                        fontSize: 20,
                        fontWeight: FontWeight.bold)
                )
              ]
          ),
        )
    )
)