{"id":2087,"date":"2022-04-07T18:58:31","date_gmt":"2022-04-07T18:58:31","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=2087"},"modified":"2022-04-07T18:58:31","modified_gmt":"2022-04-07T18:58:31","slug":"flutter-text","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/04\/07\/flutter-text\/","title":{"rendered":"Flutter Text"},"content":{"rendered":"\n<p>A Text is a widget in Flutter that allows us to&nbsp;<strong>display a string of text with a single line in our application<\/strong>. Depending on the layout constraints, we can break the string across multiple lines or might all be displayed on the same line. If we do not specify any styling to the text widget, it will use the closest&nbsp;<strong>DefaultTextStyle<\/strong>&nbsp;class style. This class does not have any explicit style. In this article, we are going to learn how to use a Text widget and how to style it in our application.<\/p>\n\n\n\n<p>Here is a simple example to understand this widget. This example shows our\u00a0<strong>project&#8217;s title<\/strong>\u00a0in the application bar and a\u00a0<strong>message<\/strong>\u00a0in the application&#8217;s body.<a href=\"https:\/\/www.javatpoint.com\/flutter-text#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/flutter-text#\"><\/a><a href=\"https:\/\/www.javatpoint.com\/flutter-text#\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter\/material.dart';  \n  \nvoid main() { runApp(MyApp()); }  \n  \nclass MyApp extends StatelessWidget {  \n  @override  \n  Widget build(BuildContext context) {  \n    return MaterialApp(  \n        theme: ThemeData(  \n          primarySwatch: Colors.green,  \n        ),  \n        home: MyTextPage()  \n    );  \n  }  \n}  \nclass MyTextPage extends StatelessWidget {  \n  @override  \n  Widget build(BuildContext context) {  \n    return Scaffold(  \n      appBar: AppBar(  \n          title:Text(\"Text Widget Example\")  \n      ),  \n      body: Center(  \n          child:Text(\"Welcome to Javatpoint\")  \n      ),  \n    );  \n  }  \n}<\/code><\/pre>\n\n\n\n<p>In the above code, we have used a&nbsp;<strong>MaterialApp<\/strong>&nbsp;widget that calls the home screen using the&nbsp;<strong>MyTextPage()<\/strong>&nbsp;class. This class contains the&nbsp;<strong>scaffold<\/strong>&nbsp;widget, which has&nbsp;<strong>appBar<\/strong>&nbsp;and&nbsp;<strong>body<\/strong>&nbsp;where we have used the&nbsp;<strong>Text<\/strong>&nbsp;widget to display the title and body, respectively. It is a simple scenario of Text widget where we have to pass the string that we want to display on our page.<\/p>\n\n\n\n<p>When we run this application in the emulator or device, we should get the UI similar to the below screenshot:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static.javatpoint.com\/tutorial\/flutter\/images\/flutter-text.png\" alt=\"Flutter Text\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>A Text is a widget in Flutter that allows us to&nbsp;display a string of text with a single line in our application. Depending on the layout constraints, we can break the string across multiple lines or might all be displayed on the same line. If we do not specify any styling to the text widget, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[503],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/2087"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=2087"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/2087\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=2087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=2087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=2087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}