Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8580515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:50:51+00:00 2026-06-11T20:50:51+00:00

Dart has a concept of final . Most dynamic languages don’t have this concept.

  • 0

Dart has a concept of final. Most dynamic languages don’t have this concept.

What is final and what do I use it for?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:50:52+00:00Added an answer on June 11, 2026 at 8:50 pm

    final variables can contain any value, but once assigned, a final variable can’t be reassigned to any other value.

    For example:

    main() {
      final msg = 'hello';
      msg = 'not allowed'; // **ERROR**, program won't compile
    }
    

    final can also be used for instance variables in an object. A final field of a class must be set before the constructor body is run. A final field will not have an implicit setter created for it, because you can’t set a new value on a final variable.

    class Point {
      final num x, y;
      Point(this.x, this.y);
    }
    
    main() {
      var p = new Point(1, 1);
      print(p.x); // 1
      p.x = 2; // WARNING, no such method
    }
    

    It’s important to realize that final affects the variable, but not the object pointed to by the variable. That is, final doesn’t make the variable’s object immutable.

    For example:

    class Address {
      String city;
      String state;
      Address(this.city, this.state);
    }
    
    main() {
      final address = new Address("anytown", "hi");
      address.city = 'waikiki';
      print(address.city); // waikiki
    }
    

    In the above example, the address variable is marked as final, so it will always point to the object instantiated by the new Address("anytown", "hi") constructor. However, the object itself has state that is mutable, so it’s perfectly valid to change the city. The only thing prevented by final is reassigning the address variable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to use Dart's noSuchMethod() , but this code noSuchMethod(InvocationMirror invocation) {
Some languages like Dart use mirror based reflection so, in simple terms, what is
this seems to not be possible with dart? i.e. to have a class method
Notice: This question is obsolete; the interface declaration syntax has been removed from Dart:
I have this Google Dart test program: #import('dart:io'); main() { var s = new
Dart has the concept of compile-time constants. A compile-time constant is parsed and created
I am experimenting with Dart. I have created an on click event like so:
I'm having a good old play with Redis Webdis Dart I wrote this #import('dart:html');
I understand that Dart has just been released, and while it's not entirely stable
I'm using an image of a dart board in this example as it's a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.