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

Introduction to JVM Introduction to JVM JVM stands for Java Virtual Machine. It works as an engine that derives the Java Code. The JVM does not understand Java ty...
Drag and Drop Collection View cell in IOS 11 &... Drag and Drop Collection View cell in IOS 11 & swift 4 In this tutorial we are explain how to drag and drop collection view cell in two collectio...
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...
E-Mail Format Formal Email / Letter Format A formal email is in general sent to someone you don’t know well or to someone who’s in authority. Examples of someone w...
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 ...
Array An array is a collection of similar kind of data elements stored in adjacent memory locations and are referred to by a single array-name. The first el...

Leave a Reply

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