Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
bbc1a61
Add missing title for day 22
triallax May 3, 2020
47463ff
Fix some typos
triallax May 3, 2020
baebb16
Merge branch 'master' into fix-typos
triallax May 3, 2020
1609f51
Merge pull request #5 from mhmdanas/fix-typos
erluxman May 4, 2020
fd00d19
Simplify title
triallax May 4, 2020
d915cbe
Merge remote-tracking branch 'upstream/master' into add-day22-title
triallax May 4, 2020
0faa284
Merge pull request #4 from mhmdanas/add-day22-title
erluxman May 4, 2020
59f455b
added week 5 tips
erluxman May 10, 2020
f88aef8
Merge pull request #6 from erluxman/week_5
erluxman May 10, 2020
a2123c8
added week 6 tips
erluxman May 18, 2020
05af181
Merge branch 'master' of github.com:erluxman/awesomefluttertips into …
erluxman May 18, 2020
364e051
Merge pull request #7 from erluxman/week_6
erluxman May 18, 2020
7dde8d1
added week 7 tips
erluxman May 25, 2020
e171d2f
Merge pull request #9 from erluxman/week_7
erluxman May 25, 2020
dcab2d0
added 7 more tips
erluxman May 31, 2020
a11f362
Merge pull request #10 from erluxman/week_8
erluxman May 31, 2020
ed30f17
completed week9
erluxman Jun 7, 2020
a7ddac6
added flare and SVG sample app demo
erluxman Jun 7, 2020
be55a1c
Merge pull request #11 from erluxman/week_9
erluxman Jun 7, 2020
73bd6ba
added comparing gifs sideby side
erluxman Jun 7, 2020
f1de6e5
Merge pull request #12 from erluxman/week_9
erluxman Jun 7, 2020
8e66c67
started modularizing the tips
erluxman Jun 7, 2020
330f0ba
making links more distinct
erluxman Jun 7, 2020
f9da5c5
changed style for current page
erluxman Jun 7, 2020
4e075b8
separating previous and next tips
erluxman Jun 7, 2020
e663287
separating previous and next tips second page
erluxman Jun 7, 2020
8348567
Fix formatting
erluxman Jun 7, 2020
75b550f
applied formatting to all pages
erluxman Jun 7, 2020
5e72e2d
Merge pull request #13 from erluxman/modularization
erluxman Jun 7, 2020
2c745d2
fixed lint issues
erluxman Jun 7, 2020
ec25ad5
fixed lint issues
erluxman Jun 7, 2020
37e11de
added partial week 10 updates
erluxman Jun 12, 2020
73918b4
Improve adding build badge tip
erluxman Jun 12, 2020
12dd146
added codecoverage tips
erluxman Jun 13, 2020
3423de5
added video link
erluxman Jun 13, 2020
4df8d81
updated video url
erluxman Jun 13, 2020
99a0aca
uploaded week 10 tips
erluxman Jun 14, 2020
40a2e40
Updated Page number
erluxman Jun 14, 2020
dcbe781
Added week 11 tips
erluxman Jun 21, 2020
36b25c7
Update README.md
erluxman Jun 24, 2020
0cea085
Update README.md
erluxman Jun 24, 2020
38e62e3
Added week 12 tips
erluxman Jun 29, 2020
4c50237
Merge branch 'master' of github.com:erluxman/awesomefluttertips
erluxman Jun 29, 2020
609cbb5
Update README.md
erluxman Jul 4, 2020
ab2c351
Added week 13
erluxman Jul 5, 2020
4b0511a
Merge pull request #15 from erluxman/week_13
erluxman Jul 5, 2020
b8c9fef
added week 14
erluxman Jul 12, 2020
4bf25ba
Merge pull request #16 from erluxman/week_14
erluxman Jul 12, 2020
43e2b5c
completed 100th items
erluxman Jul 13, 2020
73071bb
Merge branch 'master' of github.com:erluxman/awesomefluttertips
erluxman Jul 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 161 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1180,4 +1180,164 @@ ___`Widget/Image()`___ -Inside-> ___`ClipRRect()`___ -Inside-> ___`Container()`_
),

[try in codepen](https://codepen.io/erluxman/pen/abvxvOz)
![](assets/49circularImage.png)
![](assets/49circularImage.png)


## #Day 50 Use `a is! A` instead of `!(a is A)`

Flutter has special keyword to check if an instance ___`is not a type`___.

var name = "Hello World";

// ✅✅Right way✅✅
assert(name is String);

//❌❌Wrong way❌❌
assert(!(name is int));

// ✅✅Right way✅✅
assert( name is! int);


## #Day51 Named constructor.

Have you been using static methods to initialze Objects with name?

Use named constructor :

class Color {
Color({this.r, this.b, this.g});
int r = 0, g = 0, b = 0;

// ❌ static method
static Color red() => Color(r: 255,g: 0,b:255);
// ✅ named constructor
Color.red() {
r = 255;
}

// ❌ static method
static Color cyan() => Color(r:0, b: 128, g: 128);
// ✅ named constructor
Color.cyan(): g = 128, b = 128;
// ✅ named constructor
Color.cyan() {
g = 128;
b = 128;
}
}

## #Day52 Imports on Steroids 💉💉

___`as :`___ If we import two or more libraries that have conflicting identifiers, we can use them with `prefix.` given after `as` keyword.

`import 'package:library.dart' as lib;`


___`show :`___ Show only certain class and hide everything else from it.

`import 'dart:math' show max,tan;`


___`hide :`___ Hide only certain class & show everything else from it.

`import 'dart:core' hide String;`

![](assets/52importonsteroid.png)

## #Day53 final vs const

`final and const` in dart are confusing to the level we think both of them are same. Let's see their diffrences

| ___`final`___ (global / static / member variables) | ___`const`___ (static / global variables) |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
| Has single value of a `member or static or global variable` from start to end. | Has single value of a `static or global variable` from start to end. |
| Different objects of same type can have different final values in same member varaible. | Different objects of same type cannot have different const values in same varaible. (i.e. `const members should be static`) |
| Should be initialzed `before constructor is called`. | Should be `strictly initialized during declaration`. |
| Only the `final` declared `member/staic/global variable` objects are immutable, their content variables may not. i.e. variables inside final objects can be udpated / reassigned if they are not final themselves. | All `const` declared `Golbal/static` variable objects including all their internal content varibales are immutable and cannot be changed. |
| Can be `intialized` with `immutable/ mutable / calculated values` determined at `compile time or runtime`. | Can be `initialized` with `only immutable values` with all their immutable internal varaibles, determined at `compile time`. |

We can take example of various computers and how they can be compared with dart modifiers.
![](assets/53finalvsconstant.png)

## #Day54 FutureBuilder

If you want to display data from API backend or any async source, use FutureBuilder.

FutureBuilder will automatically give you Widget with default value until the data arrives from API/ async Source.

As soon as the real data arrives, it will rebuild the Widget with actual data.

Just provide the async function / source that will return the values asynchronously along with initial(default) data.

It works very similar to `StreamBuilder`

//Future Builder
FutureBuilder<List<Player>>(
initialData: [],
future: FakePlayersAPI().getPlayers(),
builder: (context, snapshot) {
if (snapshot.data.isEmpty) return CircularProgressIndicator()
else return PlayersListWidget(snapshot.data)
}
)

//Fake Backed API.
class FakePlayersAPI {
Future<List<Player>> getPlayers() async {
await Future.delayed(Duration(seconds: 1));
return _players;
}

Future<String> getPlayerStory() async {
await Future.delayed(Duration(seconds: 1));
return playerStoryText;
}
}


[try on codepen](https://codepen.io/erluxman/pen/PoPrgbR)


![](assets/54futurebuilder.gif)


## #Day55 `Get` the easy Navigation library.

Bored of writing `PageRoute`,`context` and `builder` without actual use of them just to navigate to different Widget? Use `get: ^version` library.

Also this gives us superpower to `navigate/show dialog/ BottomSheet/ Snackbar` without`BuildContext`, there might be cool patterns to be developed with this freedom.

1. Just Replace your MaterialApp with `GetMaterialApp`.
2. Start navigating like this :

//Go to next screen
Get.to(NextScreen());

//Show dialog
Get.dialog(MyDialogWidget());

//Show bottom sheet
Get.bottomSheet(MyButtomSheetWidget)

//Show snackbar
Get.snackbar(title, subTitle);


[visit library](https://pub.dev/packages/get)

[demo](https://gist.github.com/erluxman/2d1723e3395325fb5511809f6f95e21b)

![](assets/55getlib.gif)

## #Day56 `pub outdated`

Maintaining latest versions of pub dependencies is pain. Even worse, every latest versions are compatible.

From dart 2.8 onwards, the command `pub outdated` gives you the overview of your dependencies and possible upgrades in ___**`Resolvable column`**___.

![](assets/56outdated.png)

🚨🚨Tip: use `flutter pub outdated` if `pub outdated` can't find Flutter SDK.


Binary file added assets/52importonsteroid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/53finalvsconstant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/54futurebuilder.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/55getlib.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/56outdated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.