Flutter TextField align - dart

I need to create a TextFormField with decorations - counterText and labelText. I do in this way:
new TextFormField(
decoration: new InputDecoration(
counterText: "some text",
labelText: header),
);
Everything is ok except the fact that I need to move counter text to the left but by the default, it is on the right side. How to change it? I know that there is counterStyle parameter but I have no idea how to use it to achieve moving text to the left.

It is the helperText property what you are looking for.

Related

How to present views above the BottomNavigationBar on a button tap

I've been wondering how to implement a really cool little feature I saw in the Algorand app. I've attached a picture to help illustrate what I mean.
The middle button of the navigation bar at the bottom animates the Send and Receive button onto the view, and then changes it's icon to a cross. These buttons persist when you navigate to other views through the other 4 bottom navigation bar items. And when you click the middle cross button, they disappear.
I tried for a bit to implement this in Flutter. My best attempt was creating my own Bottom Navigation Bar widget for my scaffold, containing the bottom icons and a couple buttons on top, but this seemed really janky. I'm not asking for specific code examples of how to get this done, just rather a point in the right direction of how to do this kind of thing.
Speaking of specific code, their code is actually open source, and the code for the bottom nav bar is here
https://github.com/algorand/algorand-wallet/blob/master/ios/Classes/ViewControllers/Core/Container/TabBar/TabBarController.swift
I've been reading it but unfortunately my Swift is not all that great, working through it line by line. I can make a custom bottom nav bar with Container and Row, and then figure out the onTap behaviours, but it's the presenting two buttons above it that's really blocking me.
Scaffold’s floatingActionButton parameter is exactly what you’re looking for.
Need two buttons? No problem, it doesn’t have to be a FloatingActionButton, it can be any widget, including a Row.
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FloatingActionButton.extended(
icon: Icon(Icons.arrow_upward),
label: Text('Send'),
onPressed: (){},
backgroundColor: Colors.redAccent),
Padding(padding: EdgeInsets.symmetric(horizontal: 8)),
FloatingActionButton.extended(
icon: Icon(Icons.arrow_downward),
label: Text('Request'),
onPressed: (){},
backgroundColor: Colors.teal),
]
),
Then to trigger it with a button press, just make it conditional:
bool appear = false;
...
floatingActionButton: appear ? Row(...) : null
Then you can make it appear or disappear by changing the boolean in your button’s onPressed (and don’t forget to call setState).

Flutter - How to add two Text Widgets in a Column with the 2nd one overflowing vertically after filling the spaces horizontally?

I made a Chat app, I made two Text widgets inside a Column widget, now I want to make the Chat message (the 2nd text Widget) Text Widget to go Vertically after filling the spaces horizontally, so what can I do, this is the image of the Chat screen
and What happens is this(image), the images are embedded because I'm a new user
The Code of it is this:-
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
/// USER NAME
Text(userName, style: Theme.of(context).textTheme.subtitle),
/// CHAT MESSAGE
Container(
margin: const EdgeInsets.only(top: 5.0),
child: Text(
theText,
maxLines: null,
style: Theme.of(context).textTheme.body2,
),
),
],
),
I expected the Code to work like the traditional Chat app's messages, the First text widget (USERNAME) worked but the 2nd one (the actual CHAT MESSAGE) didn't work as it Overflows by pixels, So how can I fix this and Make it like the traditional Chat Messages??
I resolved the problem! And here it is:
I just wrapped my whole Column widget with a Flexible widget and it resolved my problem and now I can add Multiline Messages!
I'm keeping the post as to any Newbie facing the same problem 'may' find this useful...

How to disable splashColor only for TextField in flutter?

I am trying to disable ripple effect on a TextField.
splashColor: Colors.transparent removes ripple effect on others widgets as well.
I want to remove ripple effect only on TextField.
Try this way, you only need to add Theme to your TextField
Theme(
data: Theme.of(context).copyWith(splashColor: Colors.transparent),
child: TextField(),
),

Long String in Flutter DropdownMenuItem causing overlapping

I've got a DropdownButton in my Flutter app that contains some fairly long strings and i'm having an issue with some text overlapping in the DropdownMenuItems. There is a link to the image and in there you can see the text from one option is overlapping with the next option. I tried to wrap the text in an expanded but that isn't doing the trick.
Is there a way to create some equal separation between the DropdownMenuItems? I've tried to play around with softwrap and overflow but these are simply cutting the Strings short which is not ideal as the user needs to be able to fully read each item from the DropDown.
Ideally an equal gap between each item and no overlap is the outcome i'm looking for. Surely there is a solution to having long strings in a dropdown
DropdownMenuItem(
value: value,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[Expanded(child: Text(value))],
))
DropdownButton(
isExpanded: true, //just add this property as true
Expanded( // wrap the DropdownButton with Expanded widget
child: DropdownButton(
isExpanded: true, // also set the isExpanded property to true

Flutter floating action button in a CustomScrollView

Is there any way to include a Floating Action Button in a screen consisting of a CustomScrollView with a SliverAppBar and a SliverList?
I want to be able to have the default behaviour of a sliver list with a FAB fixed on the screen.
Is it possible?
You can still use the Scaffold when you're using the SliverAppBar such as:
new Scaffold(
body: new CustomScrollView(
slivers: <Widget>[
new SliverAppBar(...),
...
],
),
floatingActionButton: new FloatingActionButton(...),
);
Otherwise, you can generally use a Stack above the CustomScrollView and the FloatingActionButton (in a Positioned) as well.

Resources