⚠️ This lesson is retired and might contain outdated information.

Understand Built-in types in Dart

Jermaine Oppong
InstructorJermaine Oppong
Share this video with your friends

Social Share Links

Send Tweet
Published 6 years ago
Updated 2 years ago

In this lesson, we will cover Dart's inbuilt data types. Everything in Dart is an object, and therefore there are no primitive data types. In other words, all types extend a base type named Object. Any identifier without a value is set to null by default. There is no "undefined" value.

Dart is an object-oriented programming language by Google, which aims to help the developer build modern web applications. It covers client, server and now mobile with Flutter. It comes with a range of tools including a virtual machine, core libraries, and package management repository, lending enough ammunition to start your next project.

Learn more at https://dartlang.org

Instructor: [00:00] In Dart, every type is an object, including the built-in types. Numbers can be defined either as an integer or a double. Integers represent whole numbers, while doubles allow you to define floating point digits. You can also perform the usual operations with these numerical types.

[00:19] Strings can be defined with single or double quotes. Strings have support for template literals by default, which means we can contain expressions inside strings without using concatenation. Another feature of template literals are multi-line strings, which you define with triple opening and closing quotes.

[00:44] The recommended way of concatenating long strings is to use the adjacent version. Instead of having the pluses in this example, we could do it without. In fact, if they're very long, you could have them on separate lines. Let's bring these out to the console.

[01:05] Booleans are values that are set as either true or false. Apart from simply printing these out, they can also be used in various operations.

[01:14] Functions are self-contained program segments that carry out a specific task. Functions can also be set as a value to an identifier. Here's an example that calculates the difference between two integers. There's also a shorthand version.

[01:38] A list is a collection of elements with a length. These are similar syntax to other languages. List types also come with the utility of methods to iterate over its elements.

[01:58] Maps represent objects that contain key and value pairs of data. Keys can be accessed using array bracket notation and iterated over using methods like forEach.

[02:13] Runes allow you contain characters that are outside of the UTF-16 set of characters. For example, emojis. Here's an example. Then using the fromCharCodes method of the string constructor, we'll pass in our input.

[02:27] Symbols are a human-readable string that represents an identifier or a source. These identifiers could be library names, instance variables, and methods, for example. We can create symbols using the symbol constructor, or the symbol literal syntax. Let's run.

egghead
egghead
~ 22 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today