Created
November 12, 2021 01:31
-
-
Save felipecastrosales/1a1d4d11ab4a010a7aae73676233f355 to your computer and use it in GitHub Desktop.
Maps - Null Safety
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main(){ | |
///////////////////////////////////////////////////////////// | |
// // | |
// +-------------------------------------------+ // | |
// | Tipo de Maps | Map Nulo | Item Nulo | // | |
// +--------------------+----------+-----------+ // | |
// 1. | Map<String, int> | Não | Não | // | |
// +--------------------+----------+-----------+ // | |
// 2. | Map<String, int>? | Sim | Não | // | |
// +--------------------+----------+-----------+ // | |
// 3. | Map<String, int?> | Não | Sim | // | |
// +--------------------+----------+-----------+ // | |
// 4. | Map<String, int?>? | Sim | Sim | // | |
// +-------------------------------------------+ // | |
// // | |
///////////////////////////////////////////////////////////// | |
// 1. | |
Map<String, int> mapa1 = {'id': 1}; | |
Map<String, int> mapa11 = {}; | |
print(mapa1); | |
print(mapa11); | |
// 2. | |
Map<String, int>? mapa2; | |
Map<String, int>? mapa22 = null; | |
print(mapa2); | |
print(mapa22); | |
// 3. | |
Map<String, int?> mapa3 = {'id': null}; | |
Map<String, int?> mapa33 = {'id': 1}; | |
print(mapa3); | |
print(mapa33); | |
// 4. | |
Map<String, int?>? mapa4; | |
Map<String, int?>? mapa44 = null; | |
Map<String, int?>? mapa444 = {'id': null}; | |
print(mapa4); | |
print(mapa44); | |
print(mapa444); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment