Dart by Example: Libraries

libraries are imported using the import keyword:

  1. // app.dart
  2. library app;
  3. import 'utils.dart';
  4. main() {
  5. print(shout('Welcome'));
  6. print(whisper('Welcome'));
  7. }
  8.  

libraries can be split into parts using the part and part of syntax:

  1. // utils.dart
  2. library utils;
  3. part 'whisper.dart';
  4. String shout(String inp) => inp.toUpperCase() + '!!!';
  5.  
  1. // whisper.dart
  2. part of utils;
  3. String whisper(String inp) => inp.toLowerCase() + '...';
  4.  
  1. $ app.dart
  2. WELCOME!!!
  3. welcome...

by @jryanio | source | license