Executing Dart basic code using Command line, DartPad and IDE

ત્રણ ways same Dart file ને run કરવા: DartPad zero-setup practice માટે, command line નું dart run real programs અને files માટે, અને IDE debugging અને Flutter road ahead માટે.

9 min read · 10 cards · 2 checks

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


Theory

એક file, ત્રણ doors

તમારી પાસે working seat script છે અને, last 2 lessons થી, Dart ને run કરવા માટે બે ways already છે: કોઈ પણ browser માં DartPad, અને installed SDK નું promise.

syllabus ત્રણ execution routes ને names કરે છે, અને તેઓ rivals નથી: તેઓ તમારા week ના stages છે: browser માં experiment કરો, command line પર verify કરો, IDE માં build કરો. આ short lesson એ જાણવા વિશે છે કે કઈ door માં walk કરવું, અને દરેક door શું open કરી શકે છે અને શું નહીં.

Theory

Door 1: command line

SDK installed સાથે (Flutter સાથે bundled, remember), કોઈ પણ terminal Dart ને runs કરે છે:

  • તમારા code ને app.dart તરીકે save કરો
  • તેને run કરો: dart run app.dart (classic shorter dart app.dart પણ work કરે છે)

Dart VM તેને JIT દ્વારા executes કરે છે, અને અહીં, DartPad થી અલગ, program પાસે full machine powers છે: dart:io work કરે છે, files open થાય છે, fest ના registrations.txt reachable છે: આ Node નું world છે (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: same script, હવે machine powers સાથે

// terminal થી Run કરો:   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');
  }

  // અહીં (DartPad થી અલગ) dart:io work કરતું હોત:
  // import 'dart:io';  ... File('log.txt').writeAsStringSync('saved');
}

At a glance

ત્રણ ways Dart ને execute કરવા

RouteSetupPowersBest for
DartPadકોઈ નહીં: browserફક્ત core language; કોઈ files નહીં, કોઈ packages નહીંSnippets, practice, sharing
Command lineDart/Flutter SDKબધું: dart:io, packages, compile exeScripts; શું really happens તે જોવું
IDE (Android Studio / VS Code)SDK + Dart & Flutter pluginsCompletion, live errors, breakpoints, projectsReal projects; બધું Flutter work ahead

Theory

Door 3: IDE, અને શા માટે તે projects માટે wins કરે છે

Android Studio (તમારું BCA305-02 home) અથવા VS Code, દરેક Dart અને Flutter plugins સાથે installed once (File, Settings, Plugins, Flutter ને search કરો: તે Dart ને સાથે pull કરે છે).

શું IDE terminal પર add કરે છે:

  • completion અને live error underlines: mistakes type કરતા તમે surfacing થાય છે, run પર નહીં
  • debugging: breakpoints, pause, variables ને inspect કરો, line by line step: microscope જે simple print() નથી હોઈ શકતું
  • project management: many-file structure જે દરેક Flutter app ને day 1 થી છે

Unit 3 થી onward, Flutter work effectively આ door ને REQUIRES કરે છે.

Quiz

કયું execution route કોઈ installation ને require નથી કરતું at all?

  1. command line: dart run કોઈ પણ fresh Windows machine પર work કરે છે
  2. DartPad: તે entirely browser માં runs થાય છે
  3. IDE: Android Studio Dart ને built in સાથે ships કરે છે
  4. કોઈ નહીં: દરેક route ને પહેલાં Dart SDK ની જરૂર છે
Show the answer

DartPad: તે entirely browser માં runs થાય છે

DartPad ની whole identity એ zero-setup છે: editor, compiler અને console web page માં live થાય છે (behind scenes JS માં compiled, જેમ last lesson revealed કર્યું). command line (option A) એ opposite છે: તે IS installed SDK talking છે. Option C એ plugin trap છે: Android Studio Java/Kotlin ને Android માટે જાણીને arrive થાય છે; Dart અને Flutter support ને plugins દ્વારા added કરવામાં આવે છે, એક step જે exams like asking about છે. whole table નો practical takeaway: તમે Dart ને learn કરવાનું TODAY કોઈ પણ machine પર start કરી શકો છો, અને SDK પર graduate થઈ શકો છો જ્યારે files અને projects demand કરે.

Think first

door ને day સાથે assign કરો

તમારા actual week ના ત્રણ moments: (a) lab PC પર 5 spare minutes test કરવા માટે કે Dart નું switch કેવું behave કરે છે, (b) registrations log માટે file writing ને practise કરવું, (c) Unit 3 નું first Flutter project start કરવું. દરેક માટે route ને pick કરો, deciding constraint સાથે, પછી tap.

Show the answer

(a) DartPad: zero setup machine પર જે તમારી નથી; switch experiment ને કોઈ files ની જરૂર નથી. (b) Command line: dart:io એ constraint છે, અને DartPad નું sandbox તેને forbids કરે છે: ફક્ત real SDK real disk પર registrations.txt ને write કરે છે. (c) IDE: Flutter projects many-filed છે, device-connected અને debug-hungry છે: plugins સાથે Android Studio એ only comfortable home છે. pattern: constraint door ને pick કરે છે: setup available? files needed? project scale?

Watch out

Door-choosing slips

DartPad માં file I/O ને Practising કરવું: import dart:io ત્યાં fails થાય છે design દ્વારા: disk ને touch કરતી કંઈ માટે command line પર move થાઓ.

plugins ને Forgetting કરવા: Dart/Flutter plugins વગરનું Android Studio .dart files ને plain text તરીકે show કરે છે: install once, restart, done.

dart run vs dart compile exe: run હમણાં execute કરે છે VM દ્વારા (JIT); compile exe standalone native binary ને produce કરે છે: exam માટે બંને spellings ને know કરો.

Theory

tooling tour ends; language begins

તમે હવે જાણો છો કે શા માટે Dart exists કરે છે, તે કેવી રીતે ships કરે છે, અને તેને run કરવાની 3 ways. tooling knowledge એ scaffolding છે: શું આ unit નું બાકીનું છે તે language itself છે: next syntax mega-tour (types, decisions, દરેક loop જે Dart own કરે છે, તમારા Java reflexes ને guide તરીકે), પછી functions Dart ના genuinely new tricks સાથે. DartPad open, Java eyes on: fastest second language જે તમે ever learn કરશો.

Summary

Key takeaways

  • Command line: dart run app.dart JIT VM દ્વારા execute કરે છે full machine powers સાથે (dart:io work કરે છે).
  • 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 નું home.
  • constraint route ને pick કરે છે: setup, file access, અથવા project scale.
  • Android Studio ને plugins added કરવાની જરૂર છે once: તે Dart-aware સાથે ship નથી કરતું.
  • Memory hook: play કરવા 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