The feature spec describes being able to write code like
const list = [2, 3];
const another = [1, ...list, 4]; // [1, 2, 3, 4].
main() => print(another);
However this fails to compile with the error:
$dart example/dart.dart
example/example.dart:4:21: Error: '...' is not supported in constant expressions.
const another = [1, ...list, 4]; // [1, 2, 3, 4].
^^^
Version information:
Dart VM version: 2.4.0 (Wed Jun 19 11:53:45 2019 +0200) on "windows_x64"
IntelliJ IDEA 2019.2 (Ultimate Edition) Build #IU-192.5728.98
This annotation processor is my use case. I’d like to split the queries
parameter into maps defined in different files. For example:
// In queries/todos.dart
const todoQueries = {
'getTodos': 'SELECT * FROM todo'
};
// In database.dart
@UseMoor(
queries: {
'getUsers': 'SELECT * FROM user',
...todoQueries,
},
)
class TodoDb extends _$TodoDb {
Interestingly, pub run build_runner build
runs without issue and the annotation processor spreads the todoQueries
as expected, even though the analyzer has underlined it:
UI-as-code features were only supported in non-const contexts. CHANGELOG has the following note:
In fact 2.5 release will actually fully enable it. This already works on master HEAD: