Do I understand correctly that in Flutter state fields are analogous to state in React (that is, is controlled by an element itself) and widget fields are analogous to props in React (that is, are received from the parent)?
Example:
// Called as `PlacesAdd(db: db, coord: coord)`.
class PlacesAdd extends StatefulWidget {
Database? db;
LatLng? coord;
PlacesAdd({super.key, required this.db, required this.coord});
@override
State<PlacesAdd> createState() => _PlacesAddState();
}
class _PlacesAddState extends State<PlacesAdd> {
void Function() onChoosePlace(_PlaceData place) {
return () => {
widget.db.insert(/*...*/)
.then((c) => {});
};
}
@override
Widget build(BuildContext context) {
/*...*/
}
}
Or should it be duplicated in the state?:
Database db?;
@override
Widget build(BuildContext context) {
setState(() => {
db = widget.db;
});
If it is the case, then should I then use in the PlacesAddState the field db of the state or directly widget.db?