typedef Future<ClientGrid> GetAjaxData(){int page});var g = await _getDataFunc(page: _currentPage);
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
Ok, should this work in a setter?
_currentPage = newPage;_setLoading(true);var g = await _getDataFunc(page: _currentPage);grid.data = g;_setLoading(false);pagination.totalPages = grid.data.totalPages;}
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
If you really, really want to do async stuff inside a setter, you can still wrap the body in a function expression:
If you have a setter that does asynchronous computations, maybe consider making it a function instead with a name that corresponds to the computation.

import 'dart:async' show Future, Stream;
class SomeClass {
int _someValue;
void set someValue(int val) =>
new Future.delayed(new Duration(milliseconds: 500), () => _someValue = val);
Future set someValue2(int val) =>
new Future.delayed(new Duration(milliseconds: 500), () => _someValue = val);
int get someValue => _someValue;
}Here is an example https://dartpad.dartlang.org/28321d64aa5ed5ec3768import 'dart:async' show Future, Stream;
class SomeClass {
int _someValue;
void set someValue(int val) =>
new Future.delayed(new Duration(milliseconds: 500), () => _someValue = val);
Future set someValue2(int val) =>
new Future.delayed(new Duration(milliseconds: 500), () => _someValue = val);
int get someValue => _someValue;
}With return type- voidThe return type 'Future' is not a 'void', as defined by the method 'someValue'- FutureThe return type of the setter must be 'void'Somehow this doesn't make sense.
I think this should be changed but I'm not sure how.
Either the setter accepts 'void' even when short-hand syntax is usedor the analyzer always suggests to not have a return type for setters.
Either the setter accepts 'void' even when short-hand syntax is usedor the analyzer always suggests to not have a return type for setters.The solution is to stop returning something from a setter. The short-hand isn't just a short way to write a function. It's a short way to write a function *that returns a value*. Setters, being void, should not be returning values.Returning a future from a setter makes it seem like someone might see that future, and that's likely to just be fooling yourself (or somebody else reading the code).Just write:void set someValue(int val) {new Future.delayed(new Duration(milliseconds: 500), () { _someValue = val; });}or even:void set someValue(int val) {new Timer(new Duration(milliseconds: 500), () { _someValue = val; });}Both makes it clear that nobody will be seeing the delayed computation - nobody will be able to handle errors on the future.