I'm still pretty new to Dart and the syntax of => (fat arrow) still confuses me (I come from C# background).
So in C# fat arrow ( => ) says: goes to so for example:
Action<string> action1 = (str) => { System.Diagnostic.Debug.WriteLine("Parameter received: " + str.ToString()); }
action1("Some parameter");
means: whatever send as parameter to action1
(if it could be casted to string
) goes to inner scope (in our case it just printed in Debug.WriteLine()
but in Dart it's something different.... (?)
for example in Future.then
ClassWithFutures myClass = new ClassWithFutures();
myClass.loadedFuture.then(
(str) => { print("Class was loaded with info: $str"),
onError: (exp) => { print("Error occurred in class loading. Error is: $exp"); }
);
Dart editor warn me that the first and second print
is: Expected string literal for map entry key
. I think in C# way that str
it just name for parameter that will be filled by internal callback that Future.then
uses to call onValue
or onError
What I'm doing wrong ?