Default Value & Type Conversion in Dart

Default Value & Type Conversion in Dart

  • As we know in dart there are total 4 data type which is int ,String, double and bool. in where bool in only use for True and False.

  • But other three data type can use interchange , but there is catch that we can not one data type another in same object.

  • So, Using this interchange data type with together we can use conversion in dart.

  • There are 4 Conversion that we can use

    1. String to Int

    2. String to double

    3. Int to String

    4. double to String

      We will see this four conversion with example one by one.

    • Here , we declare a = 10 with int data type and var for b but we use " int.parse() " with b variable to change data type into int.

    • and this same work for double , we have to just change int.parse() to "double.parse()".

  • For changing data type int/ double to String we just have to use .toString() method.

  • here , we can see that in a variable we have declare value as 10 which in int type so we have use .toString() method to convert into string and we can also check data type with " .runtimeType "