Logo

dev-resources.site

for different kinds of informations.

var, final, const in dart programming

Published at
12/31/2024
Categories
dart
programming
beginners
flutter
Author
amirul897
Author
9 person written this
amirul897
open
var, final, const in dart programming

Dart āĻĒā§āĻ°ā§‹āĻ—ā§āĻ°āĻžāĻŽāĻŋāĻ‚ āĻ˛ā§āĻ¯āĻžāĻ™ā§āĻ—ā§āĻ¯āĻŧā§‡āĻœā§‡ var, final, āĻāĻŦāĻ‚ const āĻāĻ° āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ° āĻ­āĻŋāĻ¨ā§āĻ¨ āĻ­āĻŋāĻ¨ā§āĻ¨ āĻ•ā§āĻˇā§‡āĻ¤ā§āĻ°ā§‡ āĻšāĻ¯āĻŧāĨ¤ āĻāĻ—ā§āĻ˛ā§‹ āĻŽā§‚āĻ˛āĻ¤ āĻ­ā§‡āĻ°āĻŋāĻ¯āĻŧā§‡āĻŦāĻ˛ā§‡āĻ° āĻ§āĻ°āĻŖ āĻāĻŦāĻ‚ āĻŽāĻžāĻ¨ā§‡āĻ° āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨āĻļā§€āĻ˛āĻ¤āĻž āĻ¨āĻŋāĻ¯āĻŧāĻ¨ā§āĻ¤ā§āĻ°āĻŖ āĻ•āĻ°ā§‡āĨ¤

1. var (Variable):

āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ°: var āĻĻāĻŋāĻ¯āĻŧā§‡ āĻāĻŽāĻ¨ āĻāĻ•āĻŸāĻŋ āĻ­ā§‡āĻ°āĻŋāĻ¯āĻŧā§‡āĻŦāĻ˛ āĻ˜ā§‹āĻˇāĻŖāĻž āĻ•āĻ°āĻž āĻšāĻ¯āĻŧ āĻ¯āĻžāĻ° āĻŽāĻžāĻ¨ āĻĒāĻ°āĻŦāĻ°ā§āĻ¤ā§€āĻ¤ā§‡ āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ āĻ•āĻ°āĻž āĻ¯āĻžāĻ¯āĻŧāĨ¤

āĻŦāĻŋāĻļā§‡āĻˇāĻ¤ā§āĻŦ: āĻĒā§āĻ°āĻĨāĻŽā§‡ āĻāĻ•āĻŸāĻŋ āĻŽāĻžāĻ¨ āĻ…ā§āĻ¯āĻžāĻ¸āĻžāĻ‡āĻ¨ āĻ•āĻ°āĻ˛ā§‡, Dart āĻ¸ā§‡āĻ‡ āĻŽāĻžāĻ¨ āĻ…āĻ¨ā§āĻ¯āĻžāĻ¯āĻŧā§€ āĻŸāĻžāĻ‡āĻĒ āĻ¨āĻŋāĻ°ā§āĻ§āĻžāĻ°āĻŖ āĻ•āĻ°ā§‡āĨ¤
āĻŽāĻžāĻ¨ āĻāĻ•āĻŦāĻžāĻ° āĻ¸ā§‡āĻŸ āĻ•āĻ°āĻžāĻ° āĻĒāĻ°ā§‡, āĻ­ā§‡āĻ°āĻŋāĻ¯āĻŧā§‡āĻŦāĻ˛ā§‡āĻ° āĻŸāĻžāĻ‡āĻĒ āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ āĻ•āĻ°āĻž āĻ¯āĻžāĻ¯āĻŧ āĻ¨āĻž, āĻ¤āĻŦā§‡ āĻŽāĻžāĻ¨ āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ āĻ•āĻ°āĻž āĻ¯āĻžāĻ¯āĻŧāĨ¤

āĻ‰āĻĻāĻžāĻšāĻ°āĻŖ:

void main() {
  var name = 'Amirul';  // āĻŸāĻžāĻ‡āĻĒ āĻāĻ–āĻžāĻ¨ā§‡ String
  name = 'Islam';       // āĻāĻŸāĻŋ āĻ āĻŋāĻ• āĻ†āĻ›ā§‡, āĻ•āĻžāĻ°āĻŖ āĻŽāĻžāĻ¨ āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ āĻ•āĻ°āĻž āĻ¯āĻžāĻ¯āĻŧ
  print(name);          // āĻ†āĻ‰āĻŸāĻĒā§āĻŸ: Islam
}
Enter fullscreen mode Exit fullscreen mode

2. final:

āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ°: final āĻĻāĻŋāĻ¯āĻŧā§‡ āĻāĻŽāĻ¨ āĻāĻ•āĻŸāĻŋ āĻ­ā§‡āĻ°āĻŋāĻ¯āĻŧā§‡āĻŦāĻ˛ āĻ˜ā§‹āĻˇāĻŖāĻž āĻ•āĻ°āĻž āĻšāĻ¯āĻŧ āĻ¯āĻžāĻ° āĻŽāĻžāĻ¨ āĻāĻ•āĻŦāĻžāĻ° āĻ¸ā§‡āĻŸ āĻ•āĻ°āĻžāĻ° āĻĒāĻ°ā§‡ āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ āĻ•āĻ°āĻž āĻ¯āĻžāĻ¯āĻŧ āĻ¨āĻžāĨ¤

āĻŦāĻŋāĻļā§‡āĻˇāĻ¤ā§āĻŦ: āĻ­ā§‡āĻ°āĻŋāĻ¯āĻŧā§‡āĻŦāĻ˛ā§‡āĻ° āĻŽāĻžāĻ¨ āĻāĻ•āĻŦāĻžāĻ° āĻ¸ā§‡āĻŸ āĻšāĻ˛ā§‡, āĻ¸ā§‡āĻŸāĻž āĻ…āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ā§€āĻ¯āĻŧ āĻšāĻ¯āĻŧā§‡ āĻ¯āĻžāĻ¯āĻŧāĨ¤
āĻ¸āĻžāĻ§āĻžāĻ°āĻŖāĻ¤ āĻ•āĻ¨āĻ¸ā§āĻŸā§āĻ¯āĻžāĻ¨ā§āĻŸ āĻ•āĻŋāĻ¨ā§āĻ¤ā§ āĻ°āĻžāĻ¨āĻŸāĻžāĻ‡āĻŽā§‡ āĻ¨āĻŋāĻ°ā§āĻ§āĻžāĻ°āĻŋāĻ¤ āĻŽāĻžāĻ¨ā§‡āĻ° āĻœāĻ¨ā§āĻ¯ final āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ° āĻ•āĻ°āĻž āĻšāĻ¯āĻŧāĨ¤

āĻ‰āĻĻāĻžāĻšāĻ°āĻŖ:

void main() {
  final age = 25;    // āĻāĻŸāĻŋ āĻāĻ•āĻŦāĻžāĻ° āĻ¸ā§‡āĻŸ āĻ•āĻ°āĻžāĻ° āĻĒāĻ°ā§‡ āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ āĻ•āĻ°āĻž āĻ¯āĻžāĻŦā§‡ āĻ¨āĻž
  // age = 30;       // āĻāĻ°āĻ°: āĻĢāĻžāĻ‡āĻ¨āĻžāĻ˛ āĻ­ā§‡āĻ°āĻŋāĻ¯āĻŧā§‡āĻŦāĻ˛ā§‡āĻ° āĻŽāĻžāĻ¨ āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ āĻ•āĻ°āĻž āĻ¯āĻžāĻ¯āĻŧ āĻ¨āĻž
  print(age);        // āĻ†āĻ‰āĻŸāĻĒā§āĻŸ: 25
}
Enter fullscreen mode Exit fullscreen mode

3. const:

āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ°: const āĻĻāĻŋāĻ¯āĻŧā§‡ āĻāĻŽāĻ¨ āĻāĻ•āĻŸāĻŋ āĻ­ā§‡āĻ°āĻŋāĻ¯āĻŧā§‡āĻŦāĻ˛ āĻ˜ā§‹āĻˇāĻŖāĻž āĻ•āĻ°āĻž āĻšāĻ¯āĻŧ āĻ¯āĻžāĻ° āĻŽāĻžāĻ¨ āĻ•āĻŽā§āĻĒāĻžāĻ‡āĻ˛ āĻŸāĻžāĻ‡āĻŽā§‡āĻ‡ āĻ¨āĻŋāĻ°ā§āĻ§āĻžāĻ°āĻŋāĻ¤ āĻāĻŦāĻ‚ āĻ…āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ā§€āĻ¯āĻŧ āĻĨāĻžāĻ•ā§‡āĨ¤

āĻŦāĻŋāĻļā§‡āĻˇāĻ¤ā§āĻŦ: const āĻŽāĻžāĻ¨ āĻāĻ•ā§‡āĻŦāĻžāĻ°ā§‡ āĻ¸ā§āĻĨāĻŋāĻ° āĻāĻŦāĻ‚ āĻ•āĻŽā§āĻĒāĻžāĻ‡āĻ˛ āĻŸāĻžāĻ‡āĻŽā§‡ āĻĢāĻŋāĻ•ā§āĻ¸āĻĄāĨ¤
āĻāĻŸāĻŋ āĻļā§āĻ§ā§ āĻ¸ā§āĻŸā§āĻ¯āĻžāĻŸāĻŋāĻ• āĻŽāĻžāĻ¨ (āĻ¯ā§‡āĻŽāĻ¨ āĻ¸āĻ‚āĻ–ā§āĻ¯āĻž, āĻ¸ā§āĻŸā§āĻ°āĻŋāĻ‚) āĻ¸āĻ‚āĻ°āĻ•ā§āĻˇāĻŖā§‡ āĻŦā§āĻ¯āĻŦāĻšā§ƒāĻ¤ āĻšāĻ¯āĻŧāĨ¤

āĻ‰āĻĻāĻžāĻšāĻ°āĻŖ:

void main() {
  const pi = 3.1416;   // āĻŽāĻžāĻ¨ āĻ•āĻŽā§āĻĒāĻžāĻ‡āĻ˛ āĻŸāĻžāĻ‡āĻŽā§‡āĻ‡ āĻ¨āĻŋāĻ°ā§āĻ§āĻžāĻ°āĻŋāĻ¤
  // pi = 3.14;        // āĻāĻ°āĻ°: āĻ•āĻ¨āĻ¸ā§āĻŸ āĻ­ā§‡āĻ°āĻŋāĻ¯āĻŧā§‡āĻŦāĻ˛ā§‡āĻ° āĻŽāĻžāĻ¨ āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ āĻ•āĻ°āĻž āĻ¯āĻžāĻ¯āĻŧ āĻ¨āĻž
  print(pi);           // āĻ†āĻ‰āĻŸāĻĒā§āĻŸ: 3.1416
}
Enter fullscreen mode Exit fullscreen mode

āĻ¸āĻ‚āĻ•ā§āĻˇā§‡āĻĒā§‡:
var: āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨āĻļā§€āĻ˛ āĻŽāĻžāĻ¨ āĻ°āĻžāĻ–ā§‡āĨ¤
final: āĻāĻ•āĻŦāĻžāĻ° āĻŽāĻžāĻ¨ āĻ¸ā§‡āĻŸ āĻšāĻ˛ā§‡ āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ āĻšāĻ¯āĻŧ āĻ¨āĻž (āĻ°āĻžāĻ¨āĻŸāĻžāĻ‡āĻŽā§‡ āĻ¨āĻŋāĻ°ā§āĻ§āĻžāĻ°āĻŋāĻ¤ āĻšāĻ¤ā§‡ āĻĒāĻžāĻ°ā§‡)āĨ¤
const: āĻ¸āĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āĻ…āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ā§€āĻ¯āĻŧ āĻāĻŦāĻ‚ āĻ•āĻŽā§āĻĒāĻžāĻ‡āĻ˛ āĻŸāĻžāĻ‡āĻŽā§‡ āĻ¨āĻŋāĻ°ā§āĻ§āĻžāĻ°āĻŋāĻ¤āĨ¤

dart Article's
30 articles in total
Favicon
Flutter vs React Native in 2025: A Comprehensive Comparison
Favicon
Deploying Flutter Web Apps using Globe.dev
Favicon
Journey to Clean Architecture: Wrestling with a 10k Line Flutter Legacy Codebase
Favicon
5 Essential Flutter Widgets Every Developer Should Master
Favicon
Mastering Nested Navigation in Flutter with `go_router` and a Bottom Nav Bar
Favicon
Flutter for Beginners: From Installation to Your First App
Favicon
Building a Beautiful Login Screen in Flutter: A Complete Guide
Favicon
Flutter Design Pattern Bussines Logic Component (BLOC)
Favicon
Create Different Type of Flavor on Flutter Application
Favicon
Handling PathAccessException in iOS for File Download
Favicon
Common mistakes in Flutter article series
Favicon
Design Pattern in Flutter MVVM
Favicon
7 Ways to Refactor Your Flutter Application
Favicon
WebRTC vs Agora Video SDK vs ZegoCloud for Video Calling in Flutter: A Comprehensive Comparison
Favicon
From Chaos to Control: The Day I Learned the Magic of Debouncing in Flutter 🚀
Favicon
Syntax of comments in dart
Favicon
My first Dart program
Favicon
Integrate the Gemini REST API in Flutter: Unlock Powerful Generative Language Models for Your Next App
Favicon
Dart Operators Explained in Bangla
Favicon
Control Flow Statements (switch and case) in Dart (Bangla)
Favicon
break, continue in Dart programming (Bangla)
Favicon
Control Flow Statements ( for, while, do-while ) in dart (Bangla)
Favicon
Control Flow Statements ( if, else, else if) in dart (Bangla)
Favicon
Type inference in Dart programming (Bangla)
Favicon
var, final, const in dart programming
Favicon
We are in Top 5 Flutter Of The Year Apps List
Favicon
Class in dart
Favicon
Function in dart
Favicon
Map in Dart
Favicon
List in Dart

Featured ones: