I'm trying to understand the List
example in flutter_gallery.
My approach is to simplify the `` code by refactoring into (my project).
I'm seeing a breaking change in this commit
I/flutter (14712): 'file:///Users/hong/Flutter/github/flutter_gallery_material_list/lib/main.dart': error: line 54:
I/flutter (14712): expression is not a valid compile-time constant
I/flutter (14712): const Text t = const Text(text);
The source code starting line 53 is:
MergeSemantics _mergeSemanticsOf(String text, _MaterialListType listType) {
const Text t = const Text(text);
//const Text t = const Text('we want a variable here');
return new MergeSemantics(
child: new ListTile(
dense: true,
title: t,
trailing: new Radio<_MaterialListType>(
value: listType,
groupValue: _itemType,
onChanged: changeItemType,
)),
);
}
I can only make it compile with something like:
const Text t = const Text('we want a variable here');
.
I understand what the exception says, but wonder if there is a way to pass a variable to Text().
This is the exception popup (in a red box) in VSCode:
And this is the exception on an Android phone (Samsung S7)
A search on Stackoverflow shows this, which looks not related to my question.