i tried to pass a State object to Counter widget as a child, I get the following error:-
Error compiling to JavaScript: /tmp/dartpadWVXESU/lib/main.dart:59:18: Error: Cannot invoke a non-'const' constructor where a const expression is expected. Try using a constructor or factory that is 'const'. child: _CounterState(),
can anyone please explain me what is happening and why.
void main() {
runApp(
const MaterialApp(
home: Scaffold(
body: Center(
child: _CounterState(),
),
),
),
);
}
_CounterState is a class extending State class