0% found this document useful (0 votes)
4 views1 page

Widgets

The document explains key concepts in Flutter, including MaterialApp, Scaffold, Padding, and Margin, which are essential for building apps with Material Design. It also covers encoding and decoding, detailing the fromJson and toJson methods used for converting between Dart objects and JSON data structures. These methods facilitate the serialization and deserialization processes in Flutter applications.

Uploaded by

vickyrocker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Widgets

The document explains key concepts in Flutter, including MaterialApp, Scaffold, Padding, and Margin, which are essential for building apps with Material Design. It also covers encoding and decoding, detailing the fromJson and toJson methods used for converting between Dart objects and JSON data structures. These methods facilitate the serialization and deserialization processes in Flutter applications.

Uploaded by

vickyrocker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

MaterialApp

MaterialApp is the starting point of your app, it tells Flutter that you are
going to use Material components and follow material design in your app.

Scaffold
Implements the basic Material Design visual layout structure.
Scaffold is used under MaterialApp, it gives you many basic functionalities,
like AppBar, BottomNavigationBar, Drawer, FloatingActionButton etc.

Padding
Padding in Flutter is the space added inside a widget between the content and
the widget's boundary.

Margin
The margin in Flutter is the space added outside a widget's boundary,
creating space around it.

Encoding and Decoding


Encoding and serialization are the same thing—turning a data structure into a
string. Decoding and deserialization are the opposite process—turning a string into
a data structure

fromJson Method:
The fromJson method is used to create a Dart object from a JSON data
structure (typically a Map). It takes a single argument, which is the JSON data in
the form of a Map or a Map-like structure. This method is usually a factory
constructor and is responsible for parsing the JSON data and constructing an
instance of the class.
Purpose:
To create a Dart object from JSON data.
Typical Implementation:
In the fromJson method, you parse the JSON data and use it to initialize the
fields of the Dart object. The method then returns an instance of the class with
the parsed data.

toJson Method:
The toJson method is used to convert a Dart object into a JSON data
structure, typically a Map. It takes no arguments and returns a Map that represents
the Dart object's data in a JSON-friendly format.

Purpose:
To serialize a Dart object into JSON data.
Typical Implementation:
In the toJson method, you create a Map and populate it with the fields of the
Dart object that you want to include in the JSON representation. Each field is
usually mapped to a key in the Map. Finally, you return this Map.

Encoding or Serialization -> Data structure to String


Decoding or Deserialization -> String to Data structure

fromJson -> Create Dart object from a Json Data structure


toJson -> Create a Map from a Dart objects

You might also like