title: flutter TextField get text using TextEditingController but got empty
body: <p>I have two simple TextField Widgets, and one custom 'PublishAction' page including submit button.</p>
  <pre><code>child: Column(
    children: [
      TextField(
        decoration: const InputDecoration(labelText: &quot;Topic&quot;),
      ),
      TextField(
        decoration: const InputDecoration(labelText: &quot;Context&quot;),
      ),
      PublishAction(
        topic: &quot;flutter/topic&quot;,
        message: &quot;Hello World&quot;,
      ),
    ],
  ),
  </code></pre>
  <p>and I try to use TextEditingController to handle the text, pass values to custom 'PublishAction', like below</p>
  <pre><code>final _topicController = TextEditingController();
  final _messageController = TextEditingController();
  
  child: Column(
    children: [
      TextField(
        controller: _topicController,
        decoration: const InputDecoration(labelText: &quot;Topic&quot;),
      ),
      TextField(
        controller: _messageController,
        decoration: const InputDecoration(labelText: &quot;Context&quot;),
      ),
      PublishAction(
        topic: _topicController.text,
        message: _messageController.text,
      ),
    ],
  ),
  </code></pre>
  <p>but in my PublishAction page, after I printed it out, I found both values were empty</p>
  <p>I've tried something like this, but it works pretty well</p>
  <pre><code>child: Column(
    children: [
      TextField(
        controller: _topicController,
        decoration: const InputDecoration(labelText: &quot;Topic&quot;),
        onchange: () {
          print(_topicController.text);
        }
      ),
    ],
  ),
  </code></pre>
  <p>how do I not get empty value when passing TextEditingController.text as a function parameter?</p>
  <p>edit:</p>
  <p>here is how PublishAction looks like:</p>
  <pre><code>class PublishAction extends StatelessWidget {
    final String topic;
    final String message;
  
    const PublishAction({
      Key? key,
      required this.topic,
      required this.message,
    }) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return FloatingActionButton(
          child: const Icon(Icons.send),
          onPressed: () {
            print(&quot;topic - $topic, message - $message&quot;);
          });
    }
  }
  </code></pre>
  <p>and the output:</p>
  <pre><code>topic - , message -
  </code></pre>