I decided to implement the functional underscore.js library in Dart.
I wrote the functions in 'underscore.dart' with some example functions shown below:
library underscore;
List _filter (ff, List s) => return s..retainWhere(ff);
List _dropWhile(ff,List s) => s.skipWhile(ff).toList();
In my main Dart program, I then added the import statement
import 'underscore.dart';
However, I got the persistent error on that line of 'Unused Import', and so none of the functions were recognised.
It did work, though, when I redefined 'underscore.dart' as 'part of mainProg' and made 'mainProg' a library in its own right.
Further testing shows that it is the underscores on the function names that is causing the problem.
Any ideas?
with reference to the Flutter tutorial, I encountered an underscore, _ . I know that in Java, _ is used as a naming convention for a private variable.
In C++, an underscore usually indicates a private member variable. In C#, I usually see it used only when defining the underlying private member variable for a public property. Other private member variables would not have an underscore.
A variable name can only contain alpha-numeric characters and underscores ( a-z, A-Z , 0-9 , and _ )
A prepending underscore means that the function is library private. That is, you can't use it in an other library. See Libraries and Visibility.
Libraries not only provide APIs, but are a unit of privacy: identifiers that start with an underscore (_) are visible only inside the library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With