Flutter #day8

Flutter #day8

ยท

2 min read

Table of contents

No heading

No headings in the article.

Stateless vs Stateful

A simple difference would be, if we want to interact with a widget, it should be stateful like a button or icon button etc. and if we do want it to change then we can use stateless like text or an icon.

Named function vs. Anonymous Function

void hello() {}

onPressed: () {}

DataTypes

In Dart, we don't need to explicitly mention datatypes.(Dart is a statically typed language)

for ex:- var hello = 'shreshtha'

this is the syntax and the variable hello is set as string datatype

while we can change the contents of hello but changing it to any other datatype would result in an error.

Statically typed vs Dynamically typed languages.

Statically typed languages are those that need their datatypes defined before and type checking is done at compile time.

ex:- java,cpp,dart.

Dynamically typed languages don't need explicit declarations of datatypes and type checking is done at runtime.

ex:- javascript.

but there's a way to make dart a kind of dynamically typed :-

var a = 'hello'

this makes variable a statically typed string variable and you can't change it's datatype.

var a;

a= 'hello'

a= 113

while this enables us to use it as dynamically typed.

Other way:

String s='hello'; (static)

dynamic c = 123; (dynamic)

Built two apps(a dice app and a decision-making ball app)

uses a simple stateful widget concept, a math library to generate a random number, saved images, a text button with the image in it, and simply changes images on clicking.

Xylophone App:-

Learned a bit about flutter packages, was trying to use an audio player package but turns out my flutter got stuck at resolving dependency - _ -

got it, deleted the project, and rebuilt a new one, this time manually adding the dependency and running the flutter pub get command.

My gradle build sucks -_- so done for the day, we'll continue tomorrow.

ย