import 'package:flutter/material.dart';
class Something {
Something({required this.first, required this.second});
final String first;
final String second;
}
class MapGood extends StatefulWidget {
const MapGood({Key? key})
: location = **const** Something( // the constructor being called isnt' a const constructor. Try to remove 'const' from the invocation.
first: "37.422",
second: "-12",
),
super(key: key);
final Something? location;
@override
State<MapGood> createState() => _MapGoodState();
}
class _MapGoodState extends State<MapGood> {
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}
In const constructor about class Something() in StatefulWidget MapGood is in error, if remove ‘const’ go in error for obvious reason.
Need to create a Stateful like that, where that input can be null, for that reason provide a default values.
I cannot understand how write this condition! i tried all passibility that i know but, every time dart pad (or vsCode) give me some errors.
That solution was give me by Codeium (or AI) and there is this error.
2
Answers
There are too many solutions
First one :
Other :
Either add
const
to theSomething
constructor, likeor remove const from both in front of
Something
andMapGood
like