Line data Source code
1 : // Copyright 2014 The Flutter Authors. 2 : // Copyright 2021 Suragch. 3 : // All rights reserved. 4 : // Use of this source code is governed by a BSD-style license that can be 5 : // found in the LICENSE file. 6 : 7 : import 'package:flutter/foundation.dart'; 8 : 9 : /// The horizontal alignment of verical Mongolian text within an input box. 10 : /// 11 : /// A single [x] value that can range from -1.0 to 1.0. -1.0 aligns to the left side 12 : /// of an input box so that the left side of the first line of text fits within the 13 : /// box and its padding. 0.0 aligns to the center of the box. 1.0 aligns so that 14 : /// the right side of the last line of text aligns with the right interior edge of 15 : /// the input box. 16 : /// 17 : /// See also: 18 : /// 19 : /// * [TextAlignVertical], which is the [TextField] version for horizontal text 20 : /// * [MongolTextField.textAlignHorizontal], which is passed on to the [MongolInputDecorator]. 21 : /// * [MongolInputDecorator.textAlignHorizontal], which defines the alignment of 22 : /// prefix, input, and suffix within an [MongolInputDecorator]. 23 : class TextAlignHorizontal { 24 : /// Creates a TextAlignHorizontal from any x value between -1.0 and 1.0. 25 8 : const TextAlignHorizontal({ 26 : required this.x, 27 : }) : 28 0 : assert(x >= -1.0 && x <= 1.0); 29 : 30 : /// A value ranging from -1.0 to 1.0 that defines the leftmost and rightmost 31 : /// locations of the left and right sides of the input box. 32 : final double x; 33 : 34 : /// Aligns a MongolTextField's input text with the leftmost location within a 35 : /// MongolTextField's input box. 36 : static const TextAlignHorizontal left = TextAlignHorizontal(x: -1.0); 37 : /// Aligns a MongolTextField's input text to the center of the MongolTextField. 38 : static const TextAlignHorizontal center = TextAlignHorizontal(x: 0.0); 39 : /// Aligns a MongolTextField's input text with the rightmost location within a 40 : /// MongolTextField. 41 : static const TextAlignHorizontal right = TextAlignHorizontal(x: 1.0); 42 : 43 0 : @override 44 : String toString() { 45 0 : return '${objectRuntimeType(this, 'TextAlignHorizontal')}(x: $x)'; 46 : } 47 : }