Closed briceAlex closed 3 years ago
Hi, you can pass PlainContent instead of TextContent. And in PlainContent pass two TextContent's with different styles. Like this:
Example code:
ListContent("listnested", [
PlainContent("value")
..add(TextContent("normal", "BMW MTech"))
..add(TextContent("bold", "S55")),
PlainContent("value")
..add(TextContent("normal", "BMW"))
..add(TextContent("bold", "N55")),
]
Result:
Hi, Thank you for your answer, I understand, but I have a list of content like this :
`
var listTaches = <Content>[];
var listTachesCom = <Content>[];
listTaches = afficheTache(db);
listTachesCom = afficheTacheCom(db);
c
..add(TextContent("docname", "Simple test"))
..add(ListContent("Taches",[
TextContent("value", "Tâches :")
..add(ListContent("listnested", [
PlainContent("plain")
listTaches,
PlainContent("plain")
listTachesCom
])`
if I understood the problem correctly, in your example, one PlainContent contains only an array of text with a nomal style, and the second PlainContent contains only an array of text with a bold style.
Should be in one PlainContent both bold and normal style. The PlainContent will be the representation of the row in the list. Example:
final listNormal = ['Foo', 'Bar', 'Baz'];
final listBold = ['ooF', 'raB', 'zaB'];
final contentList = <Content>[];
final b = listBold.iterator;
for (var n in listNormal) {
// iterate two arrays syncronously
b.moveNext();
// add both normal text and bold text to PlainContent
final c = PlainContent("value")
..add(TextContent("normal", n))
..add(TextContent("bold", b.current));
// add PlainContent to List
contentList.add(c);
}
// pass list to ListContent
c..add(ListContent("listnested", contentList));
Yes, I have a database (Hive), and yes I would like to display a normal and bold text on the same line in a list.
I follow your idea, but I have an issue, nothing is displayed :
the code : `
var contentList = <Content>[];
// db is the database, var db = tacheBox.values;
for (Tache n in db){
print(n.type+" = taches");
if(n.type=="tâches"){
final c = PlainContent("Plain")
..add(TextContent("titre",n.titre))
..add(TextContent("com",n.commentaire));
contentList.add(c);
}
}
c
..add(TextContent("docname", "Simple test"))
..add(ListContent("Taches",[
TextContent("value", "tâche :")
..add(ListContent("listnested", contentList)
)]));
` display :
Thank you for your help.
Tag names is case sensitive, so:
final c = PlainContent("plain")
Ho, thank you !
Hi, I have this list : Task:
I don't know how to have the bold side and the normal side text .
If you can help me please.
Thank you for your work !