Executing Dart basic code using Command line, DartPad and IDE

एक ही Dart file चलाने के तीन तरीके: practice के लिए zero-setup DartPad, असली programs और files के लिए command line का dart run, और आगे आने वाले debugging और Flutter road के लिए IDE।

9 min read · 10 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

एक File, तीन Doors

आपके पास एक working seat script है और, पिछले 2 lessons से, Dart चलाने के पहले से TWO तरीके: किसी भी browser में DartPad, और installed SDK का promise।

Syllabus तीन execution routes को नाम देता है, और वे rivals नहीं हैं: वे आपके week के stages हैं: browser में experiment कीजिए, command line पर verify कीजिए, IDE में build कीजिए। यह छोटा lesson जानने के बारे में है कौन सा door चलना है, और हर door क्या खोल सकता है और क्या नहीं।

Theory

Door 1: Command Line

SDK installed होने के साथ (Flutter के साथ bundled, याद है), कोई भी terminal Dart चलाता है:

  • अपना code app.dart की तरह save कीजिए
  • इसे चलाइए: dart run app.dart (classic shorter dart app.dart भी काम करता है)

Dart VM इसे JIT से execute करता है, और यहाँ, DartPad के unlike, program के पास पूरी machine powers हैं: dart:io काम करता है, files खुलती हैं, fest का registrations.txt reachable है: यह Node की दुनिया है (BCA405-01 Unit 5), Dart edition।

Bonus door within the door: dart compile exe app.dart एक standalone native executable produce करता है: आपके desktop पर AOT।

Practical

app.dart: वही Script, अब Machine Powers के साथ

// Run from a terminal:   dart run app.dart
void main() {
  var events = ['Garba Night', 'Coding Contest', 'Robo Race'];
  int booked = 310;
  int total = 350;

  print('Seats left: ${total - booked}');   // 40
  for (var e in events) {
    print('Event: $e');
  }

  // Here (unlike DartPad) dart:io WOULD work:
  // import 'dart:io';  ... File('log.txt').writeAsStringSync('saved');
}

At a glance

Dart Execute करने के तीन तरीके

RouteSetupPowersBest For
DartPadकुछ नहीं: एक browserसिर्फ़ core language; कोई files नहीं, कोई packages नहींSnippets, practice, sharing
Command LineDart/Flutter SDKसब कुछ: dart:io, packages, compile exeScripts; असल में क्या होता है देखना
IDE (Android Studio / VS Code)SDK + Dart & Flutter pluginsCompletion, error underlines, DEBUGGING, projectsअसली projects; आगे का सारा Flutter work

Theory

Door 3: IDE, और Projects के लिए यह क्यों जीतता है

Android Studio (आपका BCA305-02 घर) या VS Code, हर एक में एक बार installed Dart और Flutter plugins (File, Settings, Plugins, Flutter search कीजिए: यह Dart को साथ खींच लाता है)।

IDE terminal के ऊपर क्या add करता है:

  • completion और live error underlines: mistakes type करते हुए surface होती हैं, run पर नहीं
  • debugging: breakpoints, pause, variables inspect कीजिए, line by line step कीजिए: वह microscope जो simple print() नहीं हो सकता
  • project management: वह many-file structure जो हर Flutter app के पास day 1 से होती है

Unit 3 से आगे, Flutter work को effectively यह door REQUIRE करता है।

Quiz

कौन सी execution route को बिल्कुल कोई installation नहीं चाहिए?

  1. Command line: dart run किसी भी fresh Windows machine पर काम करता है
  2. DartPad: यह पूरी तरह browser में चलता है
  3. IDE: Android Studio Dart built-in के साथ ship होता है
  4. कोई नहीं: हर route को पहले Dart SDK चाहिए
Show the answer

DartPad: यह पूरी तरह browser में चलता है

DartPad की पूरी identity zero-setup है: editor, compiler और console web page में रहते हैं (पर्दे के पीछे JS में compiled, जैसा पिछले lesson ने reveal किया)। Command line (option A) उल्टा है: यह IS installed SDK बात कर रहा है। Option C plugin trap है: Android Studio Android के लिए Java/Kotlin जानते हुए आता है; Dart और Flutter support plugins से add होता है, एक step जिसके बारे में exams पूछना पसंद करते हैं। पूरी table का practical takeaway: आप AAJ किसी भी machine पर Dart सीखना शुरू कर सकते हैं, और जब files और projects demand करें तब SDK पर graduate हो सकते हैं।

Think first

Din के लिए Door Assign कीजिए

आपके असली week के तीन moments: (a) lab PC पर 5 spare minutes यह test करने के लिए Dart का switch कैसे behave करता है, (b) registrations log के लिए file writing practise करना, (c) Unit 3 का पहला Flutter project शुरू करना। हर एक के लिए route चुनिए, deciding constraint के साथ, फिर tap कीजिए।

Show the answer

(a) DartPad: एक ऐसी machine पर zero setup जो आपकी नहीं है; एक switch experiment को कोई files नहीं चाहिए। (b) Command Line: constraint dart:io है, और DartPad का sandbox इसे forbid करता है: सिर्फ़ एक real disk पर real SDK registrations.txt लिख सकता है। (c) IDE: Flutter projects many-filed, device-connected और debug-hungry हैं: plugins के साथ Android Studio इकलौता comfortable घर है। Pattern: CONSTRAINT door चुनता है: setup available है? files चाहिए? project scale?

Watch out

Door-Choosing Slips

DartPad में File I/O Practise करना: import dart:io वहाँ design से fail होता है: disk को touch करने वाली किसी भी चीज़ के लिए command line पर move कीजिए।

Plugins भूल जाना: बिना Dart/Flutter plugins के Android Studio .dart files को plain text की तरह दिखाता है: एक बार install कीजिए, restart कीजिए, done।

dart run बनाम dart compile exe: run VM (JIT) के ज़रिए अभी execute करता है; compile exe एक standalone native binary produce करता है: exam के लिए दोनों spellings जानिए।

Theory

Tooling Tour ख़त्म होता है; Language शुरू होती है

अब आप जानते हैं Dart क्यों exist करता है, कैसे ship होता है, और इसे चलाने के 3 तरीके। Tooling knowledge scaffolding है: इस unit का जो बाकी है वह language खुद है: syntax mega-tour अगला (types, decisions, हर loop जो Dart का है, आपके Java reflexes guide की तरह), फिर functions Dart की genuinely new tricks के साथ। DartPad open, Java eyes on: सबसे fastest second language जो आप कभी सीखेंगे।

Summary

Key takeaways

  • Command line: dart run app.dart JIT VM के through पूरी machine powers के साथ execute करता है (dart:io काम करता है)।
  • dart compile exe एक standalone native executable produce करता है।
  • DartPad: zero install, browser-based, sandboxed: snippets और practice।
  • IDE (Android Studio / VS Code + Dart & Flutter plugins): completion, live errors, breakpoints, projects: Flutter का घर।
  • Constraint route चुनता है: setup, file access, या project scale।
  • Android Studio को plugins एक बार add करने चाहिए: यह Dart-aware ship नहीं होता।
  • Memory hook: खेलने के लिए pad, disk को touch करने के लिए terminal, build करने के लिए IDE।

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Working with DART

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Executing Dart basic code using Command line, DartPad and IDE · Mobile Application Development - 2 (option B) · Gri-Learn