Layout bug: Not code related but design related - flutter

This time the bug i'm facing is not code related but design related. In the login page I have;
text view just saying Log In, then I have two input fields for email and password, the third widget is where the bug is. It is Forgot Password and it is constrained to the right side of the phone screen.
Now on my device, it is like "Forgot Password". But when I installed the application on another device, it went like
"Fo
rgo
t
Pa
ss
wor
d?"
Words scattered vertically.
Here are the code screenshots,
The forgot password widget, I mentioned.
then finally the button login.
I dont know whats up? Any suggestion guys?

Remove the padding and add below code
Align(
alignment: Alignment(1.2, 0),
child: FlatButton( // You can use your own widget here
child: Text(
"Forgot Password?",
style: your text style;
),
onPressed: () {},
),
),

Add maxLines: 1, to your Text Widget:
Text(
"Forgot Password?",
maxLines: 1,
),

Related

How to show overflow on textfield's value (ellipsis)

How can I achieve something like this?
That the textfields value is showing (...) when text is bigger than the remaining space
When the text input
I know we can use overflow: TextOverflow.ellipsis, in a Text widget. How can we do something similar in textfield value?
i think for now ,there is no parameter to set overflow on TextField
since the issue still open on official repository here.
maybe you can use another plugin like auto_size_text_field
AutoSizeTextField(
controller: _controller,
overflowReplacement: Text(
_controller.text,
style: const TextStyle(overflow: TextOverflow.ellipsis),
),

Flutter | auto_size_text inside of Expanded FittedBox

Disclaimer:
I am very new to flutter, this is my first solo project that I am creating. All other projects have only been very short tutorials. The problem I am having (described below) may seem like a very easy fix, but as I am new please do explain it in detail as best you can, being able to visualize what you are saying also helps (through code, diagrams etc). Thank you.
Problem:
Unable to get auto_size_text maxLines to work correctly. On top of this, unable to get MaxFontSize working.
Further Explanation
I am using the auto_size_text package, setup with the pubspec.yaml dependency: auto_size_text: ^2.1.0 and import: 'package:auto_size_text/auto_size_text.dart'. I also changed my pubspec.yaml environment from sdk: ">=2.12.0 <3.0.0" to sdk: ">=2.11.0 <3.0.0" to allow non null safe packages to work - as per direction of this tutorial.
I am creating a container inside of my app, inside of this container is a Column widget, inside the Column widget are several rows. One of these rows is intended as a title. The code for it is below:
Row( // Row is inside of a Column which is inside of a Container
children: [
const SizedBox(width: 55), // Used to create padding either side of text
Expanded(
child: FittedBox(
child: AutoSizeText(
'70 | Brighton - Abbotsford and Green Island', // Header Example
maxLines: 2, // Cannot get this to work, always remains one line
maxFontSize: 20, // Does not work, always resizes to max font in order to fill whole FittedBox
style: TextStyle(
fontSize: 20, // Unsure if I need this, adding or removing seems to have to effect.
color: color.AppColor.textMain.withOpacity(0.8),
fontWeight: FontWeight.bold,
),
),
),
),
const SizedBox(width: 55), // Used to create padding either side of text
],
),
With this code I get this result - Note that the blue line is another row above the title but still inside of the same Column widget.
Desired Result:
The font is far too small, so I want it to be split among two lines. I am designing this container to be reused and I will later change it so the text is imported from a CSV file so name lengths will be varied. They all need to be readable, and while it's fine for smaller titles (example), larger ones need to have a bigger font while still fitting inside the same boundaries, so two lines is required. As also mentioned, I am unable to get the maxFontSize working, resulting in shorter titles having too large of a font.
Attempted Solutions:
I have tired using a null safe version of auto_size_text but was unable to get it working (as it's a prerelease I assume it isn't functioning properly).
I have another solution without using auto_size_text package
SizedBox(
child: TextField(
controller: _yourController,
decoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.all(8),
),
textInputAction: TextInputAction.done,
keyboardType: TextInputType.multiline,
maxLines: null,
),
),
keyboardType: TextInputType.multiline makes TextField can be resized automatically and move to new line if it reach max width, and
maxLines: null makes your text can be written with many lines, and then
decoration here i use to remove TextField box border
Solved
I solved my own problem almost accidently while playing around with the code I posted in the original question.
Solution:
Although not the most convenient, the solution is to replace the Expanded widget and FittedBox to a SizedBox. Below is the adjusted code including comments about changes made.
Row( // Row is inside of a Column which is inside of a Container
children: [
const SizedBox(width: 55), // Used to create padding either side of text
SizedBox( // Changed the Expanded and FittedBox to a sized box with a width of 280, source container has a width of 390, so text is allowed a width of 280 once you subtract the width 55 SizedBox's either side
width: 280,
child: AutoSizeText(
'70 | Brighton - Abbotsford and Green Island', // Header Example
maxLines: 2, // Cannot get this to work, always remains one line
maxFontSize: 20, // Does not work, always resizes to max font in order to fill whole FittedBox
style: TextStyle(
fontSize: 20, // Unsure if I need this, adding or removing seems to have to effect.
color: color.AppColor.textMain.withOpacity(0.8),
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(width: 55), // Used to create padding either side of text
],
),
Thanks

Flutter, widget next to the last letter of TextFormField

I want to move the box that is full of red background over there to the position of the empty box.
In other words, I want to insert a container right next to the point where TextFormField ends.
Is this something that can be implemented in Flutter? Or is there no way?
-- UPDATE
I actually want to add a "send" Icon to the end of the text. All the examples I looked up were always going to the end of the Containers due to Rows, as shown in the photos I posted. Since the position of the send icon will always change, depending on the length of the text, in real time, this problem feels very difficult to me. and also for your information, this is not Text, but TextField or TextFormField widget.
Unfortunately, there is no way of doing this since TextFormField accepts string only and not a widget. Also, according to material guidelines, any such widget should be at the end of the text field as a suffix such as:
TextField(
controller: _controller,
decoration: InputDecoration(
hintText: "Enter a message",
suffixIcon: IconButton(
onPressed: () => _controller.clear(),
icon: Icon(Icons.clear),
),
),
)
May I ask what is the purpose?! maybe we can help find better solution then?
but if we have to then I can think of 2 ways.
1- Include the box as a Text - For example ▀ (Alt + 223)
var box = ▀
Text("efwewewefwewefe$box"),
2- Option 2: Wrap in a Stack widget
Stack(
children: [
Text("efwewewefwewefe"),
Container(height:5, width:5, color: Colors.red]),

Flutter - text and icons not displaying sometimes

Sometimes after turning on my app, user see not rendered screen.
Buttons are available, but no labels and icons are printed.
I didn't notice it with debug version, only release.
In some cases restarting app helps, and sometimes user has to install the app again.
What may be causing this issue?
Broken screen:
And this is how it should look like
Code seems to be rather standard, e.g. logo, 'Slift' string is created this way:
#override
Widget build(BuildContext context) {
return BorderedText(
strokeWidth: strokeWidth,
strokeColor: ThemeColors.getColor3(),
child: Text(
'SLift',
style: GoogleFonts.baloo(
textStyle:
TextStyle(decoration: TextDecoration.none, fontSize: fontSize),
),
));
}
are you using MediaQuery in your code? Because sometimes it works differently on release and debug mode.

Flutter text not rendering correctly in some cases

I am developing a flutter app to display speed itself. But sometime, the speed isn't rendered correctly in the UI. This doesn't happen always but happens say 5-10% of the time.
I tried to add another text field, with lesser size below it(just to debug), and the same text renders there correctly.
2 screenshots - One correct and one with the bug
I am using a column widget to display the text and this is how I am building the children list:
List<Widget> children = [];
children.add(Container(
child: Text(listenerSpeedText,
style: TextStyle(color: Colors.lightGreen, fontSize: 100.00)),
padding: EdgeInsets.only(bottom: 5.00)));
children.add(Text(
'digitalSpeed: ' + listenerSpeedText,
style: TextStyle(
color: Colors.red,
fontSize: 25.00,
),
));
return children;
Any help would be appreciated. I am not sure what is going on. Do I need to give extra width or height to container?