Flutter Showcase long description text in one line - flutter

I am making this showcaseview in my app using this library. But I have a long text as the description. But the text will just be in one line like this:
I really want the text to be in multiple lines. A solution would be to do \n to make it a new line, but i would have to do that every time i think it is a long line, and it would be a nightmare.
Is there a better way i could do this?
This is my code:
Showcase(
key: _graph,
title: 'Diagram',
description:
'This is a long description. This is a long description. This is a long description. This is a long description. This is a long description. This is a long description. ',
child: Container(
height: _size.height * 0.3,
child: Diagram()
),
),

Show Case View is supposed to provide a short description of your widget not show multi lines and long descriptions.
For a Text you can try this:
Container(
width: 100,
child: Text(
'This is a long description. This is a long description. This is a long description. This is a long description. This is a long description. This is a long description. ',
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),

If you want to provide a longer or custom description try using Showcase.withWidget() instead of just Showcase() The takes a container: property where you can build a custom description widget that incorporates things like RichText().

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: How to use Material Icons in String?

I have a string and I would like to have an icon from the material icons displayed in that string. Currently, the only workaround is to use the standard emoji codes (e.g. '\u26A0').
I'm not quite sure how to do this. The reason I can't use a widget here is because I'm using a validator, and if the amount of characters are not met, the validator returns a string that reads out what the issue is. I'm trying to add a warning icon to it.
Would appreciate some help, thanks in advance!
The solution to your use case is WidgetSpan here is simple example of how to use it
Text.rich(
TextSpan(
children: <InlineSpan>[
TextSpan(text: 'call me'),
WidgetSpan(
child:Icon(Icons.phone)
),
],
)
),

How to show emoji in flutter

I have an api from which I am fetching messages. These messages might contain emoji.
When it does contain emoji Text Widget is not displaying it correctly.
I just want to display them on the screen. Help if possible.
Thank you :)
class Message{
String text;
Message(){
this.text = get_data_from_api()['text'];
}
}
message = Message();
return Container(
child: Text(message.text),
);
No Displaying text with Emojis on Flutter
won't do it. I can do that but it only works if you have emoji in a string, that is explicitly plasing an emoji in string works fine for me. but when I am using something similar to the code above. I am getting, this
enter image description here
digging more into it I found that if I print my response on console it is
"ð­ð­ð­ð­"
and if I print a emoji it is 😭
So
I am using
Response.fromStream(await request.send())
from http/http.dart
So is that the problem ?
I did figured it out
I was taking data from an API. So while decoding for some reason it was not decoding utf-8 so what I needed to do was add
utf8.decode(response.bodyBytes);
in place of response.body and it was solved
Reference: Emoji and accent encoding in dart/flutter
If you have an emoji image explicitly present in the response from your API and you want to display it in your text, your should try adding WidgetSpan inside your RichText below is an example of how to do it :
RichText(
text: TextSpan(
children: [
TextSpan(
text: "Click ",
),
WidgetSpan(
child: Icon(Icons.add, size: 14),
),
TextSpan(
text: " to add",
),
],
),
),
In the above example they have used the material icon( Icon(Icons.add)). If you want to replace that from the image your get from the API, you can use ImageIcon instead of Icon widget. Follow this link to know how to use ImageIcon : https://www.woolha.com/tutorials/flutter-using-imageicon-widget-examples
Reference : Add image to RichText element

Add Showcase / Highlight Flutter

I have the flutter code to display the showcase or highlights using https://pub.dev/packages/showcaseview/example
I want to show a long description which is 3 lines, is this possible?
now when my description is long it will show 1 line
Showcase(
key: _one,
description: 'I WANT ADD LONG DESCRIPTION HERE,I WANT ADD LONG DESCRIPTION HERE, I WANT ADD LONG DESCRIPTION HERE, ',
child: Icon(
Icons.menu,
color: Colors.black45,
),
),
Simply add \n in your text. Something like:
'I WANT ADD LONG DESCRIPTION HERE,\nI WANT ADD LONG DESCRIPTION HERE,\nI WANT ADD LONG DESCRIPTION HERE, ',
Result:

Layout bug: Not code related but design related

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,
),