boxed_text_field 0.0.1 copy "boxed_text_field: ^0.0.1" to clipboard
boxed_text_field: ^0.0.1 copied to clipboard

A text field in a sized box which can simulate TextAlign.center or TextAlign.Right

Boxed Text Field #

A temporary workaround for the issue encountered when using textAlign Center or Right with Flutter Text Field. The idea is to put the TextField inside a sized Box and tune the content Padding according to the Text actual width. It can thus simulates a center/right effect inside the box.

Usage #

This demo showcases how this package can be used:

import 'package:flutter/material.dart';
import 'package:boxed_text_field/boxed_text_field.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Boxed Text Field',
      home: new HomeScreen(),
    );
  }
}

class HomeScreen extends StatefulWidget {
  @override
  HomeScreenState createState() => new HomeScreenState();
}

class HomeScreenState extends State<HomeScreen> {

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
        body: new Container(
        padding: EdgeInsets.all(28.0),
        child: BoxedTextField (
            hintText: "Name",
            textStyle: TextStyle(fontSize:16.0), //mandatory
            alignRight: true, // default false => center instead
        ),
    ));
  }
}
0
likes
20
pub points
42%
popularity

Publisher

unverified uploader

A text field in a sized box which can simulate TextAlign.center or TextAlign.Right

Repository (GitHub)
View/report issues

License

Apache-2.0 (LICENSE)

Dependencies

after_layout, flutter

More

Packages that depend on boxed_text_field