TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    Dart

    Dart parse() function

    Overview

    Let’s learn about the Dart parse() function in this tutorial. There are different methods to use the parse() function depending on the type of number you want to get as an output.

    Dart parse() Function

    The Dart parse() function converts the numeric string to the number.

    int.parse()

    We can use the int.parse() method to parse a string as an integer. This method takes a string as a parameter and returns an int value.

    double.parse()

    To parse a string as a double, you can use the double.parse() method. This method takes a string as a parameter and returns a double value.

    Example

    /*
    * parse() function demo Program
    * Dart Tutorials – www.TestingDocs.com
    */

    void main(){
         // convert String to double number
         double x =double.parse(“17.96”);
         double y =double.parse(“28.54”);
         double z = x + y;
         print(“The sum of the x, y = ${z}”);
    }

     

    Dart parse Function Demo

    In this example, we have converted two strings to double numbers.
    We have performed add operation on the numbers and printed the output
    to the console screen.

    num.parse()

    To parse a string as a num, which is the superclass of int and double, you can use the num.parse() method.

    Example

    Let’s use the num.parse() method in this example.

    var pi_approx = num.parse(“3.14”);

    In this example, we have converted the string “3.14”  into a number by using the parse() method and then stored it in the variable named pi_approx.

    —

    Dart Tutorials

    Dart tutorial on this website can be found at:

    https://www.testingdocs.com/dart-tutorials-for-beginners/

    More information on Dart:

    https://dart.dev/

    Related Posts

    Dart Compilation Techniques

    Dart /

    Dart Compilation Techniques

    Dart String Interpolation

    Dart /

    Dart String Interpolation

    Dart Lists

    Dart /

    Dart Lists

    Dart /

    Dart String Methods

    Dart Print Expression

    Dart /

    Dart print() function

    ‹ Dart Variable Scopes› Dart Number Methods

    Recent Posts

    • ChatGPT Subscription Plans
    • Stellar Converter for Database
    • Stellar Log Analyzer for MySQL
    • Stellar Repair for MySQL
    • ChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI Features
    • Shaping the Future of Development: Exploring Key Trends in Software Engineering
    • Improving Java Performance with Multithreading
    • Open-source Vector Databases

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com