5

Create a sample web application using the Web UI (web_ui) library, e.g., mylib

open mylib.dart, make it a library:

library mylib;

import 'dart:html';
import 'package:web_ui/web_ui.dart';

part 'xclickcounter.dart';
...

open xclickcounter.dart, remove imports and insert:

part of mylib;

web/out/mylib.dart and web/out/xclickcounter.dart get messed up:

The included part ''xclickcounter.dart'' must have a part-of directive

Classes can only mixin other classes

Mixin can only be applied to class

... more errors follow

What am I doing wrong? Please help :(


Edit: if I don't edit generated sample code, wdc will generate code that falls into separate libraries:

  • web/out/xclickcounter.dart => x_click_counter
  • web/out/mylib.dart => mylib_html

Does it mean that if we use web_ui we should not create our own libraries and wdc will do this for us automatically?


Update: if I don't use any library name, similar to what generated sample code does, and only rely on the library names generated by xdc in web/out/... files, I still run into trouble when importing my two components into a 3rd file. Dart Editor will produce the following warning:

The imported libraries 'compa.dart' and 'compb.dart' should not have the same name

The workaround is to name your libraries based on what xdc produces in web/out/... files, that is:

  • compa.dart => x-comp-a
  • compb.dart => x-comp-b

After explicitly placing components into libraries like these the Dart Editor warning disappears.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.