Home > Software design >  Flutter - How to add a button on the middle of a paragraph
Flutter - How to add a button on the middle of a paragraph

Time:01-21

I want to add a TextButton in the middle of a paragraph in a Text widget. Similarly when writing a paragraph and want to add a button to let users route to that screen to get the desired information about something. How could I do that?

Thank you

CodePudding user response:

you can use RichText to make your works clickable. you can use like this :

RichText(
                  text: TextSpan(
                    children: <TextSpan>[
                      TextSpan(text: 'By clicking Sign Up, you agree to our '),
                      TextSpan(
                          text: 'Terms of Service',
                          recognizer: TapGestureRecognizer()
                            ..onTap = () {
                              print('Terms of Service"');
                            }),
                      TextSpan(text: ' and that you have read our '),
                      TextSpan(
                          text: 'Privacy Policy',
                          recognizer: TapGestureRecognizer()
                            ..onTap = () {
                              print('Privacy Policy"');
                            }),
                    ],
                  ),
                ),
  • Related