Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Dart Programming Part #2 - Variables
Nitin Reddy
Nitin Reddy

Posted on

     

Dart Programming Part #2 - Variables

In this post, our agenda will be to focus on variables and data types in dart and a few fundamental concepts that should be kept in mind.

You can declare a variable with the keyword ‘var’ and 'dynamic' in thedart.

Example #1

Alt Text

where name is a variable that stores a string value, you can override the value with an integer or any other type of value.

Alt Text

You can also use type for a variable. In the above example, "myName" is a variable of String that can only store string values and if you try to override the value with a different type of value you will get a warning.

You can also use keywords like final, const, and dynamic to create a new variable. final and const are used to declare a variable whose value cannot be modified later.

Example with "final":
Alt Text

Example with "dynamic":
Alt Text

All variables in dart are a reference to objects which contain values and actions.

Dart contains six special types that are-

  • Integers
  • Floating-point numbers
  • String
  • Lists
  • Maps
  • booleans

We will go in-depth on types in the next article.
Let me know if you like or dislike the article. I will improve upon the suggestions and feedbacks.

Happy learning, stay healthy and stay safe, thank you!!

Top comments(2)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
madrafj profile image
Ahmad Rafsanjani
Ex Python Lover, currently a React Lover
  • Location
    Bekasi, Indonesia
  • Work
    Freelance Front End Developer
  • Joined

Need moooore of this..

CollapseExpand
 
nitinreddy3 profile image
Nitin Reddy
Seasoned JavaScript Developer who loves to explore other programming languages like Python. A problem solver, tech lover by heart. Loves reading booking, and cooking. 🤩🚀🔬
  • Email
  • Location
    Pune, India
  • Education
    CS Graduate
  • Work
    Senior Software Engineer at IglooInsure
  • Joined

Sure then.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Seasoned JavaScript Developer who loves to explore other programming languages like Python. A problem solver, tech lover by heart. Loves reading booking, and cooking. 🤩🚀🔬
  • Location
    Pune, India
  • Education
    CS Graduate
  • Work
    Senior Software Engineer at IglooInsure
  • Joined

More fromNitin Reddy

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp