-1

Does anyone have a suggestion on how to italicize the text, "Connecting", in Flutter?

'String title = 'Connecting';'

I have tried variations on TextStyle but cannot get to work.

5
  • api.flutter.dev/flutter/painting/TextStyle-class.html
    – Da2ny
    Commented Sep 14, 2021 at 3:54
  • Thank you @Da2ny, but I could not get the suggestions in that link to work Commented Sep 14, 2021 at 4:31
  • 2
    'String title=Text('Connecting', style: TextStyle(fontStyle: FontStyle.italic),);' Commented Sep 14, 2021 at 4:49
  • above does not work Commented Sep 14, 2021 at 4:51
  • Just a Text('Connecting', style: TextStyle(fontStyle: FontStyle.italic),) without assignment works Commented Jun 23, 2023 at 2:33

1 Answer 1

14

This is how you can achieve a 'Connecting' String in Flutter.

In Example, there is a Text Widget which is print your String and it takes text style property to give italic font size.

UPDATE: Using RichText Widget

Example:

import 'package:flutter/material.dart';

class TextItalic extends StatefulWidget {
  const TextItalic({Key key}) : super(key: key);

  @override
  _TextItalicState createState() => _TextItalicState();
}

class _TextItalicState extends State<TextItalic> {
  String title = 'Connecting';
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: RichText(
          text: TextSpan(children: <TextSpan>[
    TextSpan(
        text: "Any Text",
        style: TextStyle(color: Colors.black)),
    TextSpan(
        text: title,
        style: TextStyle(fontStyle: FontStyle.italic),
    TextSpan(
        text: "any Text",
        style: TextStyle(color: Colors.black)),
         ]), 
        ),
      ),
    );
  }
}

I hope you will get the idea, if this will help you then give the right tick and flag up, Happy Fluttering.

3
  • Thank you Tushar for the detailed reply, but I just need help on styling that one string line, not sure how to implement italic from your example above Commented Sep 14, 2021 at 5:55
  • can you provide your code for better understanding?Thank you Commented Sep 14, 2021 at 5:58
  • I Update my answer please look at it if it'll help you. Commented Sep 14, 2021 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.