title: Passing data to widgets in Flutter
body: <p>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)?</p>
  <p>Example:</p>
  <pre class="lang-dart prettyprint-override"><code>// 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&lt;PlacesAdd&gt; createState() =&gt; _PlacesAddState();
  }
  
  class _PlacesAddState extends State&lt;PlacesAdd&gt; {
    void Function() onChoosePlace(_PlaceData place) {
      return () =&gt; {
        widget.db.insert(/*...*/)
            .then((c) =&gt; {});
      };
    }
  
    @override
    Widget build(BuildContext context) {
      /*...*/
    }
  }
  </code></pre>
  <p>Or should it be duplicated in the state?:</p>
  <pre class="lang-dart prettyprint-override"><code>  Database db?;
  
    @override
    Widget build(BuildContext context) {
      setState(() =&gt; {
        db = widget.db;
      });
  </code></pre>
  <p>If it is the case, then should I then use in the <code>PlacesAddState</code> the field <code>db</code> of the state or directly <code>widget.db</code>?</p>