Flutter Error: Text() vs const Text()
I was watching this video tutorial on flutter to learn Container() or Container class.
As per the instructor in video tutorial
the code shown is
but when I write the same code I get the error..
[{ "resource": "/C:/flutter_app/lib/main.dart", "owner": "_generated_diagnostic_collectionname#1", "code": { "value": "prefer_const_constructors", "target": { "$mid": 1, "external": "dart-lang.github.io/linter/lints/prefer_con..", "path": "/linter/lints/prefer_const_constructors.html", "scheme": "https", "authority": "dart-lang.github.io" } }, "severity": 2, "message": "Prefer const with constant constructors.",
"source": "dart",
"startLineNumber": 7,
"startColumn": 14,
"endLineNumber": 7,
"endColumn": 28
}]
One solution is:
Add the word Const before the class
child: const Text('Nimish'),
and it should resolve the issue.