How To Create Multi Line Textfield Using Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 30-10-2020

In Flutter this is the TextField object that takes maxLines as null to make it a multi line entry, a decoration parameter as a InputDecoration which sets things like hint text and finally a controller parameter that takes an object that will be updated when the user inserts new input.Below this TextField we will have a RaisedButton which at the moment will do nothing. Those two objects will be within a Column object which will take a crossAxisAlignment parameter to make both the TextField and RaisedButton to start from the left (or right if you're running the app in a right to left language). Finally this will all be within a stateless widget:

How To Create Multi Line Textfield Using Flutter Android App

Multi Line TextField 
Complete Code For Multi-Line TextField In Flutter
main.dart

import 'package:flutter/material.dart';

void main(){
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  MyHomePageState createState() {
    return new MyHomePageState();
  }
}

class MyHomePageState extends State<MyHomePage> {
  TextEditingController _textFieldController = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.pink[700],
        title: Text("Multi Line TextField"),
      ),
      body:  Center(
        child: Padding(
          padding: EdgeInsets.symmetric(horizontal: 25.0),
          child: TextField(
            controller: _textFieldController,
            keyboardType: TextInputType.multiline,
            maxLines: 3,
          ),
        ),
      ),
    );
  }
}

 

Related Post