Axel
Axel

Reputation: 5141

How to align text inside textfield to bottom in flutter?

So I want the text inside TextField to the very bottom.

import 'package:flutter/material.dart';

void main() => runApp(const Home());

class Home extends StatelessWidget {
  const Home({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: TextField(
            textAlignVertical: TextAlignVertical(y: -0.0),
            decoration: InputDecoration(filled: true)
          ),
        ),
      ),
    );
  }
}

I tried using textAlignVertical but it doesn't work.

Upvotes: 1

Views: 569

Answers (1)

Lucas Josino
Lucas Josino

Reputation: 835

Try adding a contentPadding:

import 'package:flutter/material.dart';

void main() => runApp(const Home());

class Home extends StatelessWidget {
  const Home({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: TextField(
            textAlignVertical: TextAlignVertical(y: -0.0),
            decoration: InputDecoration(
              filled: true,
              contentPadding: EdgeInsets.only(bottom: 0.0), //here
            ),
          ),
        ),
      ),
    );
  }
}

Upvotes: 2

Related Questions