Created
June 17, 2022 06:44
-
-
Save ntatko/9b1baa000692cc1486420834f5dd33a6 to your computer and use it in GitHub Desktop.
Introduction to types in Dart
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
| /// DART TYPES | |
| void main() { | |
| // numbers | |
| int? integer = null; | |
| double? fraction = 1.0; | |
| // strings | |
| String thisString = "this is a string. 😜"; | |
| // booleans | |
| bool isReady = false; // true | |
| // List | |
| List list1 = [1, 2, 3, 4, 5, "thing", false]; | |
| List<String>? list2 = ["a", "b", "c"]; | |
| List<int> list3 = [1, 2, 3, 4, 5]; | |
| List<int> list4 = [1, 2, 3, 4, 5]; | |
| List<int> list5 = [5, 4, 3, 2, 1]; | |
| // Map | |
| Map map1 = {'key': 'value', 'key2': 'value2', 1: false, false: "yes"}; | |
| Map<String, String> map2 = {'key': 'value', 'key2': 'value2'}; | |
| Map<String, dynamic>? map3 = {'key': 4, 'key2': "abc"}; | |
| // Set | |
| Set set1 = {1, 2, 3, 4, 5}; | |
| Set<int> set2 = {5, 4, 3, 2, 1}; | |
| Set<String> set3 = {"5", "4", "3", "2", "1"}; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment