I have a line break \n in a string that I'm reading from my sqflite row (the specific column data type is TEXT) through the bloc state, and am trying to display it within a TextSpan-
RichText(
text: TextSpan(
text: _state.feedback, //this is the string
style: TextStyle(
fontSize: 20,
color: Colors.black
)
),
)
When doing this, it just renders onscreen as the literal some text \n some text, but if I hardcode the same string as the text value instead of reading from the bloc state, eg:
RichText(
text: TextSpan(
text: "some text \n some text"
style: TextStyle(
fontSize: 20,
color: Colors.black
)
),
)
I've tried with just a plain Text(_state.feedback) widget as well, and I get the exact same behaviour.. line break works correctly when I hard-code the text value, but won't break when reading the string from the column value.
Has anyone else experienced this or can see something I'm doing wrong?
Have you tried it like this:
text: "${_state.feedback}",
I hope it works for you.
Try this. It should work.
text: _state.feedback.replaceAll(r'\n', '\n'),
Related
I want to change the color from the number of the items of the OrderedList . But I do not find a way to do this.
I can set the list style to example dots or numbers like in the following code example, but I can not find a way to change the color:
Html(
data: "<ol><li>Item 1</li><li>Item2</li></ol>",
style: {
"li": Style(
listStyleType: ListStyleType.fromWidget(Padding(
child: CircleAvatar(radius: 2,´
backgroundColor: Color.fromARGB(255, 230, 50, 50),)))),, },),
If I do not override the default styling the numbers stay black even when I change the color of the text itself.
Is it possible to change the Slider label colour in Flutter?
There is no such field in constructor of Slider class.
According to Flutter api use valueIndicatorColor which is the property of SliderThemeData As mention here SliderClass
and here SliiderThemeData
Simple Demonstration:
set local variables:
double feet = 0;
String heightInFeet = "null";
int height = 180;
and Here comes your Custom Slider Solution
SliderTheme(
data: SliderTheme.of(context).copyWith(
valueIndicatorColor: Colors.blue, // This is what you are asking for
inactiveTrackColor: Color(0xFF8D8E98), // Custom Gray Color
activeTrackColor: Colors.white,
thumbColor: Colors.red,
overlayColor: Color(0x29EB1555), // Custom Thumb overlay Color
thumbShape:
RoundSliderThumbShape(enabledThumbRadius: 12.0),
overlayShape:
RoundSliderOverlayShape(overlayRadius: 20.0),
),
child: Slider(
value: height.toDouble(),
onChanged: (double newValue) {
setState(() {
height = newValue.toInt();
feet = (height / 30.48);
heightInFeet = feet.toStringAsFixed(2) + " feet";
});
},
divisions: 220,
label: heightInFeet,
min: 90.0,
max: 305.0,
),
)
and if you want to change Text color text font etc. use
valueIndicatorTextStyle: TextStyle(
color: Colors.amber, letterSpacing: 2.0)
in SliderThemeData
that´s one way to do it, but that will change all the placer where accentTextTheme it´s use, you can use this:
Theme(
child: yourSlide,
data: Theme.of(context).copyWith(
accentTextTheme: TextTheme(bodyText2: TextStyle(color: Colors.white)),
),
)
This way you will only change the widget you need to change and not the entire accentTextTheme that can be use for other that maybe you don't need to change.
Use SliderThemeData:
sliderTheme: ThemeData.dark().sliderTheme.copyWith(
valueIndicatorColor: _primaryColor,
valueIndicatorTextStyle: TextStyle(
backgroundColor: Colors.transparent
)
)
I have found that it is specified in Slider class above label field.
The label is rendered using the active [ThemeData]'s
[ThemeData.accentTextTheme.bodyText2] text style.
When creating the App widget it is necessary to specify the accentTextTheme and the bodyText2 field.
return MaterialApp(
theme: ThemeData(
accentTextTheme: TextTheme(bodyText2: TextStyle(color: Colors.white)),
),
home: MyHomePage(),
);
ISSUE
Hello Guys please help me to solve this. I've started building a REACT application working with some JSON data, and now I got stuck on this problem when trying to tap some letters or word snippets to search on options from the select that could contain that letter or those snippet(s).
Check the example and my code below please, I have only one list stored in a react-select component, I'm using react v15.6.2, react-dom v15.6.2 and react-select 2.1.0. Thanks in advance.
Example: If I tap letter 'a', the search works fine and it gives me the options that contain that letter but when I add something else that is NOT exactly before/after the letter 'a', example: I add a letter 'b' that can be at the last of the option value, the select stops giving results!
const selectObjects = (<Select
isMulti
options={this.state.list.map(obj => {
return {
value: obj.id,
label: obj.id + ' ' + obj.name
};
})}
onChange={this.handleChangeObj}
value={this.state.list}
/>);
PRESS HERE TO CHECK THE DEMO
I have verified that, if you map your option label and value correctly, your search issue should be resolved.
const options = [{
id: 2,
artist: 'Hendrix, Jimi',
title: 'Red House'
}, {
id: 3,
artist: 'Clapton, Eric',
title: `I'm Tore Down`
}];
<Select options={options}
getOptionValue={(opt) => opt.id}
getOptionLabel={(opt) => `${opt.artist}: ${opt.title}`} />
I have a larger example in this codesandbox.
I'm trying to display data with TCPDF from my DB which were specifically indented.
I use a writeHTMLCell to do so.
e.g. :
"This should be indented as so :
- First bullet
- Second one
Then the end of the example."
But of course, it render the text on a single line.
Does anyone know how i can render the text properly ?
Thank you very much !
With HTML preformatted text requires that you use <pre>. Here is an example:
This should be indented as so:
- First bullet
- Second one
Then the end of the example.
<pre>
This should be indented as so:
- First bullet
- Second one
Then the end of the example.
</pre>
Using <pre> tags with the preformatted text block should achieve the result you are looking for. Preformatted text defaults to a monospaced font and can be changed with $pdf->SetDefaultMonospacedFont(). Here is an example with and without <pre>:
<?php
require_once('tcpdf_include.php');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->AddPage();
$text_sample = 'This should be indented as so:
- First bullet
- Second one
Then the end of the example.';
$y = $pdf->getY();
$pdf->SetDefaultMonospacedFont('helvetica');
$pdf->SetFont('helvetica', '', 14, '', true);
$pdf->SetFillColor(255, 255, 255);
$pdf->SetTextColor(255, 92, 92);
$pdf->writeHTMLCell(190, '', '', $y, $text_sample, 1, 0, 1, true, 'J', true);
$pdf->SetTextColor(53,183,41);
$pdf->writeHTMLCell(190, '', '', $y+20, '<pre>'.$text_sample.'</pre>', 1, 1, 1, true, 'J', true);
$pdf->Output('example.pdf', 'I');
The PDF will contain the following cells:
How to visualize ascii chars to "human readable" in kineticJS?
var figure = new Kinetic.Text({
x: 75/2,
y: 75/2,
text: "♘",
fontSize: 30,
fontFamily: "Calibri",
textFill: "green",
align: "center",
verticalAlign: "middle"
});
This has nothing to do with KineticJS. You are asking how to take a string containing HTML character entities and decode the entities. See Convert HTML Character Entities back to regular text using javascript for answers to that question.