SlideShare une entreprise Scribd logo
1  sur  50
Télécharger pour lire hors ligne
Ahmed Abu Eldahab
GDE Flutter & Dart
@dahabdev
Null Safety in Dart and Flutter ,
The whole Story!
Ahmed Abu Eldahab
Google Developer Expert in Flutter & Dart
Senior Technical Consultant
Kortobaa LLC CTO
/Dahabdev
bit.ly/dahab-youtube
/DahabDev
1960
Tony Hoare
Sir Charles Antony Richard Hoare born 11 January 1934)
- is a British computer scientist. He developed the sorting algorithm
quicksort in 1959–1960.[5] He also developed Hoare logic for
verifying program correctness.
https://en.wikipedia.org/wiki/Tony_Hoare /DahabDev
- In 1960, Hoare left the Soviet Union and began working at Elliott Brothers.
- After 9 months of programming he was asked to design a new
programming language !!
- Most software was still written in machine code.
- In the library was a 23-page booklet entitled "Report on the international
language ALGOL60"
- He used it as a basis for the new language.
- In order to implement error messages, an array had a check to verify
whether its reference was in the bounds!.
- Adding checks to arrays added space and time to the program !.
- Then he went and invented the null pointer. Or he either have to
check every reference.
https://en.wikipedia.org/wiki/Tony_Hoare
Tony Hoare in Moscow 1960
/DahabDev
Variables
String name = ‘Ahmed’;
Type Name Value
/DahabDev
Memory Allocation
String name = ‘Ahmed’;
NameType Init val
Address Value
0012CCGWH80 Ahmed
Identifier
Memory
name
/DahabDev
Variables
String name;
NameType
/DahabDev
Memory Allocation
Identifier
Memory
name
String name;
NameType
?
Nowhere
Null
Pointer
/DahabDev
Null
Pointer/Reference
- A null pointer is a pointer that does
not point to any memory location.
- It represents an invalid memory
location .
- when a null value is assigned to a
pointer then the pointer is considered
as null pointer.
/DahabDev
Null Pointer/Reference Exception (NPE)
- Invoking a method from a null object.
- Accessing or modifying a null object’s field.
- Taking the length of null, as if it were an array.
- Accessing or modifying the slots of null
object, as if it were an array.
/DahabDev
Something was called on null
Something was called on null
/DahabDev
Null Pointer Exception (NPE)
/DahabDev
Tony Hoare
https://en.wikipedia.org/wiki/Tony_Hoare
I call it my billion-dollar mistake. It was the invention of the null
reference in 1965. ... This has led to innumerable errors,
vulnerabilities, and system crashes, which have probably caused
a billion dollars of pain and damage in the last forty years.
2009
/DahabDev
Tony Hoare
https://en.wikipedia.org/wiki/Tony_Hoare
- Null references have historically been a bad idea.
- Programming language designers should be responsible for the
errors in programs written in that language.
- If the billion dollar mistake was the null pointer, the C gets()
function is a multi-billion dollar mistake that created the
opportunity for malware and viruses to thrive (Buffer overflow)
/DahabDev
Important Expressions
Dynamic Type system Static Type system Null Safety
Unsound Null SafetySound Null Safety
/DahabDev
Dart null safety
https://www.youtube.com/watch?v=iYhOU9AuaFs
https://medium.com/dartlang/announcing-dart-nu
ll-safety-beta-87610fee6730
/DahabDev
Dart Null Safety
Null safety is the largest
change we’ve made to Dart
since we replaced the original
unsound optional type system
with a sound static type
system in Dart 2.0.
/DahabDev
https://dartpad.dev
/DahabDev
https://dartpad.dev /DahabDev
Dart
https://dartpad.dev /DahabDev
Dart
https://dartpad.dev /DahabDev
Dart
Dart Null Safety
https://nullsafety.dartpad.dev /DahabDev
Dart Null safety principles
/DahabDev
Dart null safety support is based on the following three core design principles:
● Non-nullable by default. Unless you explicitly tell Dart that a variable can be null, it’s considered non-nullable.
This default was chosen after research found that non-null was by far the most common choice in APIs.
● Incrementally adoptable. You choose what to migrate to null safety, and when. You can migrate incrementally,
mixing null-safe and non-null-safe code in the same project. We provide tools to help you with the migration.
● Fully sound. Dart’s null safety is sound, which enables compiler optimizations. If the type system determines
that something isn’t null, then that thing can never be null. Once you migrate your whole project and its
dependencies to null safety, you reap the full benefits of soundness —- not only fewer bugs, but smaller
binaries and faster execution
https://dart.dev/null-safety
/DahabDev
- All variables are non-nullable by default
- If the variable can have the value null, add ? to its type declaration.
String? name = null;
- If you know that a non-nullable variable will be initialized to a non-null value
before it’s used, but the Dart analyzer doesn’t agree, insert late before the
variable’s type.
late String name;
Dart null safety roles
https://dart.dev/null-safety
/DahabDev
- When using a nullable variable or expression, be sure to handle null values. For
example, you can use an if statement, the ?? operator, or the ?. operator to
handle possible null values.
String value = name ?? ''; // '' if it's null; otherwise, the String
- If you’re sure that an expression with a nullable type isn’t null, you can add ! to
make Dart treat it as non-nullable:
String? name = 'Ahmed';
String value = name!; // `name!` is an String.
// This throws if name is null.
Dart null safety roles
https://dart.dev/null-safety
Dart null safety roles
/DahabDev
- Once you opt into null safety, you can’t use the member access operator (.) if the
operand might be null. Instead, you can use the null-aware version of that
operator (?.):
double? d;
print(d?.floor()); // Uses `?.` instead of `.` to invoke `floor()`.
- If you’re sure that an expression with a nullable type isn’t null, you can add ! to
make Dart treat it as non-nullable:
String? name = 'Ahmed';
String value = name!; // `name!` is an String.
// This throws if name is null.
https://dart.dev/null-safety
list, set, and map
/DahabDev
https://dart.dev/null-safety
list, set, and map
/DahabDev
https://dart.dev/null-safety
/DahabDev
Migrating to null safety steps
https://dart.dev/null-safety/migration-guide
/DahabDev
Migrating to null safety steps
https://dart.dev/null-safety/migration-guide
/DahabDev
Migrating to null safety
https://dart.dev/null-safety/migration-guide
/DahabDev
Migrating to null safety
https://dart.dev/null-safety/migration-guide
/DahabDev
Migrating to null safety
https://dart.dev/null-safety/migration-guide
/DahabDev
Migrating to null safety
https://dart.dev/null-safety/migration-guide
/DahabDev
Migrating to null safety
https://dart.dev/null-safety/migration-guide
Everything is ok?
HIT APPLY MIGRATION BUTTON !
/DahabDev
Migrating to null safety
https://dart.dev/null-safety/migration-guide
/DahabDev
Migrating to null safety
https://dart.dev/null-safety/migration-guide
The analyzer can be wrong sometimes !
/DahabDev
Migrating to null safety
https://dart.dev/null-safety/migration-guide
/DahabDev
How to practice Null safety?
https://nullsafety.dartpad.dev
/DahabDev
Migrating to null safety
Migrating to null safety
/DahabDev
1. Wait for the packages that you depend on to migrate.
2. Migrate your package’s code, preferably using the interactive migration tool.
3. Statically analyze your package’s code.
4. Test to make sure your changes work.
5. If the package is already on pub.dev, publish the null-safe version as a
prerelease version.
https://dart.dev/null-safety
Thanks
bit.ly/dahab-youtube
Ahmed Abu Eldahab
Google Developer Expert in Flutter & Dart
Senior Technical Consultant
Kortobaa LLC CTO
/Dahabdev

Contenu connexe

Tendances

Introduction to Docker - What is it and how is it compared to VM's
Introduction to Docker - What is it and how is it compared to VM'sIntroduction to Docker - What is it and how is it compared to VM's
Introduction to Docker - What is it and how is it compared to VM'sJeremy Haas
 
introduction to flutter ppt - free download
introduction to flutter ppt - free downloadintroduction to flutter ppt - free download
introduction to flutter ppt - free downloadRajatPalankar2
 
Exceptions in Java
Exceptions in JavaExceptions in Java
Exceptions in JavaVadym Lotar
 
Build responsive applications with google flutter
Build responsive applications with  google flutterBuild responsive applications with  google flutter
Build responsive applications with google flutterAhmed Abu Eldahab
 
Docker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker, Inc.
 
Flutter talkshow
Flutter talkshowFlutter talkshow
Flutter talkshowNhan Cao
 
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...Edureka!
 
Introduction to the Dart language
Introduction to the Dart languageIntroduction to the Dart language
Introduction to the Dart languageJana Moudrá
 
AEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser CachingAEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser CachingAndrew Khoury
 
Docker, Docker Compose and Docker Swarm
Docker, Docker Compose and Docker SwarmDocker, Docker Compose and Docker Swarm
Docker, Docker Compose and Docker SwarmCarlos E. Salazar
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cyclemyrajendra
 
Semmle Codeql
Semmle Codeql Semmle Codeql
Semmle Codeql M. S.
 

Tendances (20)

Introduction to Docker - What is it and how is it compared to VM's
Introduction to Docker - What is it and how is it compared to VM'sIntroduction to Docker - What is it and how is it compared to VM's
Introduction to Docker - What is it and how is it compared to VM's
 
Intro To Docker
Intro To DockerIntro To Docker
Intro To Docker
 
introduction to flutter ppt - free download
introduction to flutter ppt - free downloadintroduction to flutter ppt - free download
introduction to flutter ppt - free download
 
Exceptions in Java
Exceptions in JavaExceptions in Java
Exceptions in Java
 
Build responsive applications with google flutter
Build responsive applications with  google flutterBuild responsive applications with  google flutter
Build responsive applications with google flutter
 
Docker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker 101: Introduction to Docker
Docker 101: Introduction to Docker
 
Flutter talkshow
Flutter talkshowFlutter talkshow
Flutter talkshow
 
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Tr...
 
Rust vs C++
Rust vs C++Rust vs C++
Rust vs C++
 
Flutter
FlutterFlutter
Flutter
 
Generics
GenericsGenerics
Generics
 
Rust programming-language
Rust programming-languageRust programming-language
Rust programming-language
 
Introduction to the Dart language
Introduction to the Dart languageIntroduction to the Dart language
Introduction to the Dart language
 
Flutter Intro
Flutter IntroFlutter Intro
Flutter Intro
 
AEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser CachingAEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser Caching
 
Oop in kotlin
Oop in kotlinOop in kotlin
Oop in kotlin
 
Docker, Docker Compose and Docker Swarm
Docker, Docker Compose and Docker SwarmDocker, Docker Compose and Docker Swarm
Docker, Docker Compose and Docker Swarm
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
 
Flutter introduction
Flutter introductionFlutter introduction
Flutter introduction
 
Semmle Codeql
Semmle Codeql Semmle Codeql
Semmle Codeql
 

Similaire à Null safety in dart and flutter , the whole story!

Porting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidPorting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidVlatko Kosturjak
 
Hacking - high school intro
Hacking - high school introHacking - high school intro
Hacking - high school introPeter Hlavaty
 
hover.in at CUFP 2009
hover.in at CUFP 2009hover.in at CUFP 2009
hover.in at CUFP 2009Bhasker Kode
 
Open event (show&tell april 2016)
Open event (show&tell april 2016)Open event (show&tell april 2016)
Open event (show&tell april 2016)Jorge López-Lago
 
Why Rust? by Edd Barrett (codeHarbour December 2019)
Why Rust? by Edd Barrett (codeHarbour December 2019)Why Rust? by Edd Barrett (codeHarbour December 2019)
Why Rust? by Edd Barrett (codeHarbour December 2019)Alex Cachia
 
ITI MDW 2018 Event Talk "building beautiful apps using google flutter"
ITI MDW 2018 Event Talk "building beautiful apps using google flutter"ITI MDW 2018 Event Talk "building beautiful apps using google flutter"
ITI MDW 2018 Event Talk "building beautiful apps using google flutter"Ahmed Abu Eldahab
 
Introduction to r
Introduction to rIntroduction to r
Introduction to rgslicraf
 
Sinfonier: How I turned my grandmother into a data analyst - Fran J. Gomez - ...
Sinfonier: How I turned my grandmother into a data analyst - Fran J. Gomez - ...Sinfonier: How I turned my grandmother into a data analyst - Fran J. Gomez - ...
Sinfonier: How I turned my grandmother into a data analyst - Fran J. Gomez - ...Codemotion
 
Beautiful Bash: Let's make reading and writing bash scripts fun again!
Beautiful Bash: Let's make reading and writing bash scripts fun again!Beautiful Bash: Let's make reading and writing bash scripts fun again!
Beautiful Bash: Let's make reading and writing bash scripts fun again!Aaron Zauner
 
AVTOKYO2013.5 Detail of CVE-2013-4787 (Master Key Vulnerability)
AVTOKYO2013.5 Detail of CVE-2013-4787 (Master Key Vulnerability)AVTOKYO2013.5 Detail of CVE-2013-4787 (Master Key Vulnerability)
AVTOKYO2013.5 Detail of CVE-2013-4787 (Master Key Vulnerability)雅太 西田
 
Fluid, Fluent APIs
Fluid, Fluent APIsFluid, Fluent APIs
Fluid, Fluent APIsErik Rose
 
Bigdata presentation
Bigdata presentationBigdata presentation
Bigdata presentationYonas Gidey
 
Bigdata Presentation
Bigdata PresentationBigdata Presentation
Bigdata PresentationYonas Gidey
 
Simplest-Ownage-Human-Observed… - Routers
 Simplest-Ownage-Human-Observed… - Routers Simplest-Ownage-Human-Observed… - Routers
Simplest-Ownage-Human-Observed… - RoutersLogicaltrust pl
 
Filip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routersFilip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routersYury Chemerkin
 
LibreSSL, one year later
LibreSSL, one year laterLibreSSL, one year later
LibreSSL, one year laterGiovanni Bechis
 
Culture And Aesthetic Revisited
Culture And Aesthetic RevisitedCulture And Aesthetic Revisited
Culture And Aesthetic RevisitedAdam Keys
 
Php training100%placement-in-mumbai
Php training100%placement-in-mumbaiPhp training100%placement-in-mumbai
Php training100%placement-in-mumbaivibrantuser
 

Similaire à Null safety in dart and flutter , the whole story! (20)

Porting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidPorting your favourite cmdline tool to Android
Porting your favourite cmdline tool to Android
 
Hacking - high school intro
Hacking - high school introHacking - high school intro
Hacking - high school intro
 
hover.in at CUFP 2009
hover.in at CUFP 2009hover.in at CUFP 2009
hover.in at CUFP 2009
 
Open event (show&tell april 2016)
Open event (show&tell april 2016)Open event (show&tell april 2016)
Open event (show&tell april 2016)
 
Why Rust? by Edd Barrett (codeHarbour December 2019)
Why Rust? by Edd Barrett (codeHarbour December 2019)Why Rust? by Edd Barrett (codeHarbour December 2019)
Why Rust? by Edd Barrett (codeHarbour December 2019)
 
ITI MDW 2018 Event Talk "building beautiful apps using google flutter"
ITI MDW 2018 Event Talk "building beautiful apps using google flutter"ITI MDW 2018 Event Talk "building beautiful apps using google flutter"
ITI MDW 2018 Event Talk "building beautiful apps using google flutter"
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
Sinfonier: How I turned my grandmother into a data analyst - Fran J. Gomez - ...
Sinfonier: How I turned my grandmother into a data analyst - Fran J. Gomez - ...Sinfonier: How I turned my grandmother into a data analyst - Fran J. Gomez - ...
Sinfonier: How I turned my grandmother into a data analyst - Fran J. Gomez - ...
 
Beautiful Bash: Let's make reading and writing bash scripts fun again!
Beautiful Bash: Let's make reading and writing bash scripts fun again!Beautiful Bash: Let's make reading and writing bash scripts fun again!
Beautiful Bash: Let's make reading and writing bash scripts fun again!
 
UnDeveloper Studio
UnDeveloper StudioUnDeveloper Studio
UnDeveloper Studio
 
AVTOKYO2013.5 Detail of CVE-2013-4787 (Master Key Vulnerability)
AVTOKYO2013.5 Detail of CVE-2013-4787 (Master Key Vulnerability)AVTOKYO2013.5 Detail of CVE-2013-4787 (Master Key Vulnerability)
AVTOKYO2013.5 Detail of CVE-2013-4787 (Master Key Vulnerability)
 
Fluid, Fluent APIs
Fluid, Fluent APIsFluid, Fluent APIs
Fluid, Fluent APIs
 
Bigdata presentation
Bigdata presentationBigdata presentation
Bigdata presentation
 
Bigdata Presentation
Bigdata PresentationBigdata Presentation
Bigdata Presentation
 
Simplest-Ownage-Human-Observed… - Routers
 Simplest-Ownage-Human-Observed… - Routers Simplest-Ownage-Human-Observed… - Routers
Simplest-Ownage-Human-Observed… - Routers
 
Filip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routersFilip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routers
 
LibreSSL, one year later
LibreSSL, one year laterLibreSSL, one year later
LibreSSL, one year later
 
Culture And Aesthetic Revisited
Culture And Aesthetic RevisitedCulture And Aesthetic Revisited
Culture And Aesthetic Revisited
 
Opensource
OpensourceOpensource
Opensource
 
Php training100%placement-in-mumbai
Php training100%placement-in-mumbaiPhp training100%placement-in-mumbai
Php training100%placement-in-mumbai
 

Plus de Ahmed Abu Eldahab

The Flutter Job Market At The Moment
The Flutter Job Market At The MomentThe Flutter Job Market At The Moment
The Flutter Job Market At The MomentAhmed Abu Eldahab
 
Flutter A year of creativity!
Flutter A year of creativity!Flutter A year of creativity!
Flutter A year of creativity!Ahmed Abu Eldahab
 
Flutter latest updates and features 2022
Flutter latest updates and features 2022Flutter latest updates and features 2022
Flutter latest updates and features 2022Ahmed Abu Eldahab
 
Flutter 2.8 features and updates
Flutter 2.8 features and updatesFlutter 2.8 features and updates
Flutter 2.8 features and updatesAhmed Abu Eldahab
 
What's new in flutter and dart in 2020
 What's new in flutter and dart in 2020   What's new in flutter and dart in 2020
What's new in flutter and dart in 2020 Ahmed Abu Eldahab
 
Becoming a software developer
Becoming a software developerBecoming a software developer
Becoming a software developerAhmed Abu Eldahab
 
Build web applications using google flutter part 2
Build web applications using google flutter part 2Build web applications using google flutter part 2
Build web applications using google flutter part 2Ahmed Abu Eldahab
 
Build web applications using google flutter
Build web applications using google flutterBuild web applications using google flutter
Build web applications using google flutterAhmed Abu Eldahab
 
Google flutter the easy and practical way
Google flutter the easy and practical wayGoogle flutter the easy and practical way
Google flutter the easy and practical wayAhmed Abu Eldahab
 
Cybersecurity in an IoT and Mobile World
Cybersecurity in an IoT and Mobile WorldCybersecurity in an IoT and Mobile World
Cybersecurity in an IoT and Mobile WorldAhmed Abu Eldahab
 
Flutter state management from zero to hero
Flutter state management from zero to heroFlutter state management from zero to hero
Flutter state management from zero to heroAhmed Abu Eldahab
 
Flutter state management from zero to hero
Flutter state management from zero to heroFlutter state management from zero to hero
Flutter state management from zero to heroAhmed Abu Eldahab
 
Building your actions for Google Assistant
Building your actions for Google AssistantBuilding your actions for Google Assistant
Building your actions for Google AssistantAhmed Abu Eldahab
 
Building beautiful apps with Google flutter
Building beautiful apps with Google flutterBuilding beautiful apps with Google flutter
Building beautiful apps with Google flutterAhmed Abu Eldahab
 
Building Successful Apps with Google Firebase
Building Successful Apps with Google FirebaseBuilding Successful Apps with Google Firebase
Building Successful Apps with Google FirebaseAhmed Abu Eldahab
 
Flutter beyond hello world GCDC Egypt Devfest 2019
Flutter beyond hello world GCDC Egypt  Devfest 2019Flutter beyond hello world GCDC Egypt  Devfest 2019
Flutter beyond hello world GCDC Egypt Devfest 2019Ahmed Abu Eldahab
 
Flutter beyond Hello world talk
Flutter beyond Hello world talkFlutter beyond Hello world talk
Flutter beyond Hello world talkAhmed Abu Eldahab
 

Plus de Ahmed Abu Eldahab (20)

The Flutter Job Market At The Moment
The Flutter Job Market At The MomentThe Flutter Job Market At The Moment
The Flutter Job Market At The Moment
 
Flutter A year of creativity!
Flutter A year of creativity!Flutter A year of creativity!
Flutter A year of creativity!
 
Flutter latest updates and features 2022
Flutter latest updates and features 2022Flutter latest updates and features 2022
Flutter latest updates and features 2022
 
Flutter 2.8 features and updates
Flutter 2.8 features and updatesFlutter 2.8 features and updates
Flutter 2.8 features and updates
 
6 x1 flutter_talk
6 x1 flutter_talk6 x1 flutter_talk
6 x1 flutter_talk
 
What's new in flutter and dart in 2020
 What's new in flutter and dart in 2020   What's new in flutter and dart in 2020
What's new in flutter and dart in 2020
 
Becoming a software developer
Becoming a software developerBecoming a software developer
Becoming a software developer
 
Build web applications using google flutter part 2
Build web applications using google flutter part 2Build web applications using google flutter part 2
Build web applications using google flutter part 2
 
Build web applications using google flutter
Build web applications using google flutterBuild web applications using google flutter
Build web applications using google flutter
 
Google flutter the easy and practical way
Google flutter the easy and practical wayGoogle flutter the easy and practical way
Google flutter the easy and practical way
 
Cybersecurity in an IoT and Mobile World
Cybersecurity in an IoT and Mobile WorldCybersecurity in an IoT and Mobile World
Cybersecurity in an IoT and Mobile World
 
Flutter state management from zero to hero
Flutter state management from zero to heroFlutter state management from zero to hero
Flutter state management from zero to hero
 
Flutter state management from zero to hero
Flutter state management from zero to heroFlutter state management from zero to hero
Flutter state management from zero to hero
 
Building your actions for Google Assistant
Building your actions for Google AssistantBuilding your actions for Google Assistant
Building your actions for Google Assistant
 
Building beautiful apps with Google flutter
Building beautiful apps with Google flutterBuilding beautiful apps with Google flutter
Building beautiful apps with Google flutter
 
Building Successful Apps with Google Firebase
Building Successful Apps with Google FirebaseBuilding Successful Apps with Google Firebase
Building Successful Apps with Google Firebase
 
Flutter beyond hello world
Flutter beyond hello worldFlutter beyond hello world
Flutter beyond hello world
 
Flutter beyond hello world GCDC Egypt Devfest 2019
Flutter beyond hello world GCDC Egypt  Devfest 2019Flutter beyond hello world GCDC Egypt  Devfest 2019
Flutter beyond hello world GCDC Egypt Devfest 2019
 
Flutter beyond Hello world talk
Flutter beyond Hello world talkFlutter beyond Hello world talk
Flutter beyond Hello world talk
 
Flutter beyond hello world
Flutter beyond hello worldFlutter beyond hello world
Flutter beyond hello world
 

Dernier

The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 

Dernier (20)

The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 

Null safety in dart and flutter , the whole story!

  • 1. Ahmed Abu Eldahab GDE Flutter & Dart @dahabdev Null Safety in Dart and Flutter , The whole Story!
  • 2. Ahmed Abu Eldahab Google Developer Expert in Flutter & Dart Senior Technical Consultant Kortobaa LLC CTO /Dahabdev
  • 5. Tony Hoare Sir Charles Antony Richard Hoare born 11 January 1934) - is a British computer scientist. He developed the sorting algorithm quicksort in 1959–1960.[5] He also developed Hoare logic for verifying program correctness. https://en.wikipedia.org/wiki/Tony_Hoare /DahabDev
  • 6. - In 1960, Hoare left the Soviet Union and began working at Elliott Brothers. - After 9 months of programming he was asked to design a new programming language !! - Most software was still written in machine code. - In the library was a 23-page booklet entitled "Report on the international language ALGOL60" - He used it as a basis for the new language. - In order to implement error messages, an array had a check to verify whether its reference was in the bounds!. - Adding checks to arrays added space and time to the program !. - Then he went and invented the null pointer. Or he either have to check every reference. https://en.wikipedia.org/wiki/Tony_Hoare Tony Hoare in Moscow 1960 /DahabDev
  • 7. Variables String name = ‘Ahmed’; Type Name Value /DahabDev
  • 8. Memory Allocation String name = ‘Ahmed’; NameType Init val Address Value 0012CCGWH80 Ahmed Identifier Memory name /DahabDev
  • 11. Null Pointer/Reference - A null pointer is a pointer that does not point to any memory location. - It represents an invalid memory location . - when a null value is assigned to a pointer then the pointer is considered as null pointer. /DahabDev
  • 12. Null Pointer/Reference Exception (NPE) - Invoking a method from a null object. - Accessing or modifying a null object’s field. - Taking the length of null, as if it were an array. - Accessing or modifying the slots of null object, as if it were an array. /DahabDev
  • 13.
  • 15. Something was called on null /DahabDev
  • 16. Null Pointer Exception (NPE) /DahabDev
  • 17. Tony Hoare https://en.wikipedia.org/wiki/Tony_Hoare I call it my billion-dollar mistake. It was the invention of the null reference in 1965. ... This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years. 2009 /DahabDev
  • 18. Tony Hoare https://en.wikipedia.org/wiki/Tony_Hoare - Null references have historically been a bad idea. - Programming language designers should be responsible for the errors in programs written in that language. - If the billion dollar mistake was the null pointer, the C gets() function is a multi-billion dollar mistake that created the opportunity for malware and viruses to thrive (Buffer overflow) /DahabDev
  • 19.
  • 20. Important Expressions Dynamic Type system Static Type system Null Safety Unsound Null SafetySound Null Safety /DahabDev
  • 22. Dart Null Safety Null safety is the largest change we’ve made to Dart since we replaced the original unsound optional type system with a sound static type system in Dart 2.0. /DahabDev
  • 28. Dart Null safety principles /DahabDev Dart null safety support is based on the following three core design principles: ● Non-nullable by default. Unless you explicitly tell Dart that a variable can be null, it’s considered non-nullable. This default was chosen after research found that non-null was by far the most common choice in APIs. ● Incrementally adoptable. You choose what to migrate to null safety, and when. You can migrate incrementally, mixing null-safe and non-null-safe code in the same project. We provide tools to help you with the migration. ● Fully sound. Dart’s null safety is sound, which enables compiler optimizations. If the type system determines that something isn’t null, then that thing can never be null. Once you migrate your whole project and its dependencies to null safety, you reap the full benefits of soundness —- not only fewer bugs, but smaller binaries and faster execution https://dart.dev/null-safety
  • 29. /DahabDev - All variables are non-nullable by default - If the variable can have the value null, add ? to its type declaration. String? name = null; - If you know that a non-nullable variable will be initialized to a non-null value before it’s used, but the Dart analyzer doesn’t agree, insert late before the variable’s type. late String name; Dart null safety roles https://dart.dev/null-safety
  • 30. /DahabDev - When using a nullable variable or expression, be sure to handle null values. For example, you can use an if statement, the ?? operator, or the ?. operator to handle possible null values. String value = name ?? ''; // '' if it's null; otherwise, the String - If you’re sure that an expression with a nullable type isn’t null, you can add ! to make Dart treat it as non-nullable: String? name = 'Ahmed'; String value = name!; // `name!` is an String. // This throws if name is null. Dart null safety roles https://dart.dev/null-safety
  • 31. Dart null safety roles /DahabDev - Once you opt into null safety, you can’t use the member access operator (.) if the operand might be null. Instead, you can use the null-aware version of that operator (?.): double? d; print(d?.floor()); // Uses `?.` instead of `.` to invoke `floor()`. - If you’re sure that an expression with a nullable type isn’t null, you can add ! to make Dart treat it as non-nullable: String? name = 'Ahmed'; String value = name!; // `name!` is an String. // This throws if name is null. https://dart.dev/null-safety
  • 32. list, set, and map /DahabDev https://dart.dev/null-safety
  • 33. list, set, and map /DahabDev https://dart.dev/null-safety
  • 34. /DahabDev Migrating to null safety steps https://dart.dev/null-safety/migration-guide
  • 35. /DahabDev Migrating to null safety steps https://dart.dev/null-safety/migration-guide
  • 36. /DahabDev Migrating to null safety https://dart.dev/null-safety/migration-guide
  • 37. /DahabDev Migrating to null safety https://dart.dev/null-safety/migration-guide
  • 38. /DahabDev Migrating to null safety https://dart.dev/null-safety/migration-guide
  • 39. /DahabDev Migrating to null safety https://dart.dev/null-safety/migration-guide
  • 40. /DahabDev Migrating to null safety https://dart.dev/null-safety/migration-guide Everything is ok? HIT APPLY MIGRATION BUTTON !
  • 41. /DahabDev Migrating to null safety https://dart.dev/null-safety/migration-guide
  • 42. /DahabDev Migrating to null safety https://dart.dev/null-safety/migration-guide The analyzer can be wrong sometimes !
  • 43. /DahabDev Migrating to null safety https://dart.dev/null-safety/migration-guide
  • 44. /DahabDev How to practice Null safety? https://nullsafety.dartpad.dev
  • 46. Migrating to null safety /DahabDev 1. Wait for the packages that you depend on to migrate. 2. Migrate your package’s code, preferably using the interactive migration tool. 3. Statically analyze your package’s code. 4. Test to make sure your changes work. 5. If the package is already on pub.dev, publish the null-safe version as a prerelease version. https://dart.dev/null-safety
  • 48.
  • 50. Ahmed Abu Eldahab Google Developer Expert in Flutter & Dart Senior Technical Consultant Kortobaa LLC CTO /Dahabdev