Posts

Showing posts from August, 2022

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: <Widget>[     ItemOne(),     Item

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 widget is the root of your applicatio

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"     },     {       "id&

The Asynchronous programming: futures, async, await in Flutter

Image
                    This Article teaches you how to write asynchronous code using futures and the  async  and  await  keywords.  What is synchronous learning? Definition explained Synchronicity means doing something at the same time, and learning, it's no different.  Synchronous learning  refers to a learning event in which a group of participants is engaged in  learning at the same time. What is asynchronous learning?  Definition explained If synchronous learning takes place at the same time,  asynchronous learning refers to the opposite .  The instructor, the learner, and other participants are not engaged in the learning process at the same time.  There is no real-time interaction with other people. Why asynchronous code matters Asynchronous operations let your program complete work while waiting for another operation to finish. Here are some common asynchronous operations: Fetching data over a network. Writing to a database. Reading data from a file. What is a future? A future