Skip to main content

Command Palette

Search for a command to run...

Dynamic Keyword in Dart

Updated
1 min read
Dynamic Keyword in Dart
V

"Hello World, I'm Vinit Mepani, a coding virtuoso driven by passion, fueled by curiosity, and always poised to conquer challenges. Picture me as a digital explorer, navigating through the vast realms of code, forever in pursuit of innovation.

In the enchanting kingdom of algorithms and syntax, I wield my keyboard as a magical wand, casting spells of logic and crafting solutions to digital enigmas. With each line of code, I embark on an odyssey of learning, embracing the ever-evolving landscape of technology.

Eager to decode the secrets of the programming universe, I see challenges not as obstacles but as thrilling quests, opportunities to push boundaries and uncover new dimensions in the realm of possibilities.

In this symphony of zeros and ones, I am Vinit Mepani, a coder by passion, an adventurer in the digital wilderness, and a seeker of knowledge in the enchanting world of code. Join me on this quest, and let's create digital wonders together!"

  • Dart dynamic type In Dart, when a variable is declared as a dynamic type, it can store any value, such as int , String and float . The value of a dynamic variable can change over time within the program.
// dynamic type  
void main()
{
  // declaring and assigning value to variable a 
  // of type dynamic
  dynamic a = 40;
  print(a);
  // reassigning value to a
  a= "Dart";
  print(a);
  // reassigning value to a
  a= 10.4;
  print(a);
}
  • In here , We declare a variable named a of dynamic type and assign an integer value to it. than we print the value after that agian we have assign a string value to it. and print the value and in the last we have print assign float value and print it

    • Like in var we can done this type of process , because var support only one data type at that time which is the biggest different between var and dynamic keyword.

Learn Dart

Part 1 of 50

Dive into the Dart Language Series for an easy grasp of Dart programming essentials.

More from this blog

Vinit Mepani (Flutter Developer)

270 posts

"Vinit Mepani, passionate coder! Dive into my Dart and Flutter journey on the blog. Let's master these tech wonders together. Happy coding! 🚀"