buildElement method
Implementation
List<Widget> buildElement(BuildContext context) {
if (element.tagName == "heading") {
return [
Stack(
children: [
SizedBox(
width: double.infinity,
child: Padding(
padding: EdgeInsets.only(top: element.parent!.getChildren().indexOf(element) > 0 ? 50 : 0, left: 30, right: 30),
child: Text(element.getAttribute("text")!, style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
),
),
],
),
];
} else if (element.tagName == "content" || element.tagName == "body" || element.tagName == "speech") {
return [
Stack(
children: [
SizedBox(
width: double.infinity,
child: Padding(
padding: EdgeInsets.only(left: 30, right: 30),
child: MarkdownWidget(
config: buildChatBubbleMarkdownConfig(context),
data: element.getAttribute("text")!,
shrinkWrap: true,
),
),
),
],
),
];
} else if (element.tagName == "step") {
return [Text(element.getAttribute("description"))];
} else if (element.tagName == "file") {
return [FilePreview(room: client, path: element.getAttribute("name"))];
} else if (element.tagName == "plan") {
return [
Container(
decoration: BoxDecoration(color: Color.from(alpha: 1.0, red: .9, green: .9, blue: .9), borderRadius: BorderRadius.circular(10)),
margin: EdgeInsets.only(bottom: 20),
padding: EdgeInsets.all(20),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text("Plan", style: TextStyle(fontWeight: FontWeight.bold)),
...buildChildren(context),
],
),
),
];
} else {
return buildChildren(context);
}
}