Gabriel Ratener
Gabriel Ratener

Reputation: 605

Unable to import dart library for command line app

When initiating a command line utility in dart, I get the following directory structure:

happy/
  bin/
    main.dart
  lib/
    happy.dart
    user.dart

Where happy.dart, and user.dart are identical except for their containing libraries: happy, and user respectively.

in happy.dart:

library happy; // user in user.dart

int calculate() {
  return 6 * 7;
}

in main.dart I have:

import 'package:happy/happy.dart'; // changing to user underlines this in red

main() {
  print('Hello world: ${happy.calculate()}!');
}

Which works, but when the user library is used instead of happy, the import fails.

Thanks

Upvotes: 0

Views: 155

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657268

Should definitely work if you change it to import 'package:happy/user.dart';

Upvotes: 1

Related Questions