In the following code, I'm getting inspection warning with 'prefer const literals as parameters of constructors on @immutable classes' and it's annoying. What should I do to make it go away?
screenshot from ide
Container(
margin: const EdgeInsets.all(20),
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Enter a search term'),
),
Text("these are the search results", textAlign: TextAlign.left),
],
),
)
I have tried to make every constructor call 'const' with no avail.
Container(
margin: const EdgeInsets.all(20),
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const TextField(
decoration: const InputDecoration(
border: const OutlineInputBorder(),
hintText: 'Enter a search term'),
),
const Text("these are the search results", textAlign: TextAlign.left),
],
),
),
Just mark the list as const:
Container(
margin: const EdgeInsets.all(20),
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Enter a search term'),
),
Text("these are the search results", textAlign: TextAlign.left),
],
),
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With