Libraries and visibility

Usage

import 'dart:html';  // dart: β€” Π˜ΠΌΠΏΠΎΡ€Ρ‚ built-in Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊ
import 'package:test/test.dart';  // package: β€” ΠΈΠΌΠΏΠΎΡ€Ρ‚ всСх ΠΎΡΡ‚Π°Π»ΡŒΠ½Ρ‹Ρ… Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊ ΠΏΠΎ ΠΈΠΌΠ΅Π½ΠΈ 
                                  // ΠΈΠ»ΠΈ ΠΏΠΎ ΠΎΡ‚Π½ΠΎΡΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎΠΌΡƒ ΠΏΡƒΡ‚ΠΈ
import 'dart:html' as myname;

// Import only foo.
import 'package:lib1/lib1.dart' show foo;

// Import all names EXCEPT foo.
import 'package:lib2/lib2.dart' hide foo;

ΠžΡ‚Π»ΠΎΠΆΠ΅Π½Π½Π°Ρ ΠΏΠΎΠ΄Π³Ρ€ΡƒΠ·ΠΊΠ° Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ (deferred loading or lazy loading). Π˜ΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚ΡΡ для ΡΠΊΠΎΡ€Π΅ΠΉΡˆΠ΅ΠΉ ΠΏΠΎΠ΄Π³Ρ€ΡƒΠ·ΠΊΠΈ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊ, Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΡ‹ для старта прилоТСния ΠΈ Ρ‡Ρ‚ΠΎΠ±Ρ‹ Π½Π΅ Π³Ρ€ΡƒΠ·ΠΈΡ‚ΡŒ Ρ€Π΅Π΄ΠΊΠΎ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅ΠΌΡ‹Π΅ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠΈ.

import 'package:greetings/hello.dart' deferred as hello;

Future<void> greet() async {
  // load library when you need via .loadLibrary()
  await hello.loadLibrary();
  hello.printGreeting();
}

Implementing libraries

See Create Library Packages for advice on how to implement a library package, including:

  • How to organize library source code.

  • How to use the export directive.

  • When to use the part directive.

  • When to use the library directive.

  • How to use conditional imports and exports to implement a library that supports multiple platforms.

Last updated