Posts

Important widget Row & Column with Example

Image
  In this article, we’re going to learn how to use rows & columns in a flutter with an example. This Topic is very very important in flutter development, without Rows & Columns you cannot build UI. Column  A Column widget displays its children vertically. It takes a children property containing an array of List . The children align vertically without taking up the full height of the screen. Each child widget can be embedded in an Expanded widget to fill available space. You can use CrossAxisAlignment, MainAxisAlignment, and MainAxisSize to align and size how much space is occupied on the main axis. Column(   crossAxisAlignment: CrossAxisAlignment.center,  mainAxisAlignment: MainAxisAlignment.spaceEvenly,  mainAxisSize: MainAxisSize.max,  children: <Widget>[  Text('Column 1'),  Divider(),  Text('Column 2'),  Divider(),  Text('Column 3'),  ], ), Row A Row widget displays its children horizontally. It takes a c...

The Creating ListViews in Flutter

Image
  What is  ListView ? ListView  is used to group several items in an array and display them in a scrollable list. The list can be scrolled vertically, horizontally, or displayed in a grid: ListView s are common in UI frameworks and are one of the most popular UI widgets in the world. In fact, any mobile app or project must use  ListView  in some capacity Exploring the types of ListView We’ll start with looking at the types of ListViews and later look at the other features and neat modifications for it. Let’s look at the types of ListViews there are: ListView ListView.builder ListView.separated ListView.custom ListView This is the default constructor of the ListView class. A ListView simply takes a list of children and makes it scrollable. Usually, this should be used with a  small number of children  as the List will also construct the invisible elements in the list and a large number of elements may render this inefficient. ListView(   children: ...

POST, DELETE and PUT Requests

Image
  Preparation Before starting we’ll need to add http as a dependency, so let’s edit our  pubspec.yaml  file and add http: dependencies : http : <latest_version> Then we’ll just need to do a good old  flutter pub get  and import it in our file. I will use as a test case an ideal API Wrapper in order to call a single function to do all the work for us: POST, DELETE and PUT Those three methods work similarly to GET but we expect to add some body parameters. Fear not gentle developer! With the call we can add a String body with a jsonEncoded  Map<String,String>  which will be body parameters: then we only need to use http package with  post ,  delete  or  put  method: Ex import 'dart:convert' ; import 'package:flutter/material.dart' ; import 'package:http/http.dart' as http ; void main () { runApp( const MyApp ()) ; } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super (key: key) ; // This wi...

UNDERSTANDING THE JSON FORMAT

  On this page, you will learn about the structures of JSON. you will also learn different forms of storing data in JSON. The JSON format is text-based and is independent of programming languages, meaning any of them can use it. It’s a great way to exchange data between different programs because it is human-readable text. JSON uses the key/value pair, and the key is enclosed in quotation marks followed by a colon and then the value like "id":"100". You use a comma (,) to separate multiple key/value pairs. Table 13.1 shows some examples. TYPE SAMPLE Object { "id": "100", "name": "Vacation" } Array with values only ["Family", "Friends", "Fun"] Array with key/value [     {        "id": "100",        "name": "Vacation"     },     {       ...