How to use Flutter most usable Widgets | Flutter tutorial

We need some basic widgets for creating our first flutter app. Widgets describe what their view should look like given their current configuration and state. When a widget’s state changes, the widget rebuilds its description. Here we dicuss some basic widgets for creating the flutter application.

1. Text Class Widget : –

Text class is like a label in android and iOS. For use this we need to create text class object and assign the propertis and text into them. The Text widget displays a string of text with single style. The string might break across multiple lines or might all be displayed on the same line depending on the layout constraints.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ListViewPractice</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">StatelessWidget</span> </span>{
  Widget build(BuildContext context) {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Container(
      child: <span class="hljs-keyword">new</span> Text( <span class="hljs-string">"data1 one"</span>, textAlign:  TextAlign.end,
      textDirection: TextDirection.rtl,
      textScaleFactor: <span class="hljs-number">2.0</span>,
      overflow: TextOverflow. clip,
      style: <span class="hljs-keyword">new</span> TextStyle(
         color: Colors.red[<span class="hljs-number">500</span>],
         fontSize: <span class="hljs-number">30.0</span>,
         wordSpacing: <span class="hljs-number">15.0</span>,
         letterSpacing: <span class="hljs-number">2.0</span>,
         fontWeight: FontWeight.bold,
         decoration: TextDecoration.underline,
         decorationColor: Colors.green,
         decorationStyle: TextDecorationStyle.solid),
         softWrap:  <span class="hljs-keyword">true</span>,
      )
    );
  }
}

2. IconButton class : –

An icon button is a picture printed on a Material widget that reacts to touches by filling with color (ink).


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ListViewPractice</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">StatelessWidget</span> </span>{
   <span class="hljs-annotation">@override</span>
  Widget build(BuildContext context) {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Scaffold(
      body: <span class="hljs-keyword">new</span> Center(
        child: <span class="hljs-keyword">new</span> Container(
          width: <span class="hljs-number">60.0</span>,
          height: <span class="hljs-number">60.0</span>,
          color: Colors.red,
          child: <span class="hljs-keyword">new</span> IconButton(
            highlightColor: Colors.blue,
            alignment: Alignment.center,
            splashColor: Colors.green,
            disabledColor: Colors.purple,
            padding: <span class="hljs-keyword">new</span> EdgeInsets.all(<span class="hljs-number">0.0</span>),
            icon: <span class="hljs-keyword">new</span> Icon(Icons.add_a_photo), onPressed: ()=&gt;{},),
        ),
      ),
    );
  }
}

<span class="hljs-keyword">void</span> setState() {
  <span class="hljs-built_in">print</span>(<span class="hljs-string">"Button Press"</span>);
}

Download Demo From Here 

Related Post

Comments in C Comments in C Comments in C language are used to provide information about lines of code. It is widely used for documenting code. There are 2 types o...
Firebase Push notification | Swift tutorial Push Notification by firebase in IOS.For Firebase Push notification we need to have paid apple developer account. You need to Enroll into the Apple D...
Variables Variables A variable is a named location in memory that is used to hold a value that can be modified by the program. All variable must be declared be...
Setting Class Path for Java Setting Class Path for Java In this tutorial we are study how we can set the java JDK class path. Java is an open source software, it is is freely...
Loops in java Loops in JAVA Loops are used to execute a set of statements repeatedly until a particular condition is satisfied. Loop is used in programming ...
Create UITableView (Table View) By the use of stor... How to use UITableView in Above IOS 8 and Swift (UITableView) In this tutorial we are study how to use the TableView in Swift. One of the most common...

Leave a Reply

Your email address will not be published. Required fields are marked *

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.