Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call a top level function that has the same name as variable in Dart?

Tags:

dart

Simplified code example:

int value() => 1;
main() {
  int value = value(); // Error here: 'value' isn't a function 
}

Is there a way to specify that I want to call a function?

If no, why is it impossible?

like image 305
Anton Ivinskyi Avatar asked Aug 06 '17 17:08

Anton Ivinskyi


1 Answers

You can use an import prefix

import 'this_file.dart' as foo;

int value() => 1;
main() {
  int value = foo.value(); // Error here: 'value' isn't a function 
}
like image 123
Günter Zöchbauer Avatar answered Jan 02 '23 22:01

Günter Zöchbauer