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 Constants

    Overview

    Dart Constants are immutable objects, which means that they can’t be changed or modified during the execution of the Dart program. Once we initialize the constant with a value, it cannot be reassigned in the program. Dart will throw an exception if we try to modify the constant.

    Dart Constants

    The Dart constants can be defined using the following keywords:

    • final keyword
    • const keyword

    These keywords can be used with or without a data type name.

    final keyword

    The final keyword denotes a single-time assignment of the variable. We can define the constant by using the final keyword. The general syntax to define a constant using the final keyword is as follows:

    final constant_name;

    final data_type constant_name

    Example

    final int MAX_ELEMENTS = 10;

    const keyword

    The const keyword represents the compile-time constant. We can define a constant by using the const keyword. The syntax is as follows:

    const constant_name

    const data_type constant_name

    Example

    const String bank_name=”Bank of America”;

     

    —

    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 dynamic variable› Dart Assignment Operators

    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