title: How can i pass data from a child widget to a parent widget
body: <p>I have seen similar answers to my question, example is this <a href="https://stackoverflow.com/questions/49824461/how-to-pass-data-from-child-widget-to-its-parent">How to pass data from child widget to its parent</a> , but the data is passed through an onPressed event. How can i pass data from my child widget to the parent widget, without any onPressed or onTap event.</p>
  <p>Code</p>
  <pre><code>  class ParentWidget extends StatelessWidget {
    String? passedData;
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ChildWidget(),
            Text(passedData != null ? passedData! : 'No data passed'),
          ],
        ),
      );
    }
  }
  
  //How can i pass the title string to the ParentWidget as passedData String
  
  class ChildWidget extends StatelessWidget {
    String title = 'Happy New Year';
    @override
    Widget build(BuildContext context) {
      return Center(
          child: Container(
        child: Text(title),
      ));
    }
  }
  </code></pre>