How to get Text from TextField on button click?
This Article is posted by seven.srikanth at 1/3/2020 4:38:08 AM
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter
Tags:
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter
1 Comments
Recent Comments
pc_systemx1 at 3/26/2024
Hello friend, I have corrected the code today 2024: import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter TextField Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(title: 'Flutter TextField Demo'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { String _inputtext=''; TextEditingController inputtextField = TextEditingController(); void _processText() { setState(() { _inputtext = inputtextField.text; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Padding( padding: const EdgeInsets.all(16.0), child: TextField( controller: inputtextField, decoration: InputDecoration( border: OutlineInputBorder(), labelText: 'Enter some text' ), ), ), Padding( padding: const EdgeInsets.all(16.0), child: Text( '$_inputtext', style: Theme.of(context).textTheme.headline5, ), ), ElevatedButton( onPressed: _processText, child: Text('Process Text'), ) ], ), ), ); } }