Reputation: 331
I need to display content containing text and images from an API on my android app, when I save it in a variable of type String, the texts get displayed but the images shows as url. How do I load the get the links to load in between the texts?
Upvotes: 1
Views: 2142
Reputation: 1114
I needed to insert an Image inline with a sentence of texts. So for that I used this:
final String paragraph1 =
'Advanciti App is an app where you can study and make friends with people living near your home. Advanciti is an Edtech Startup based out of Pune, Maharashtra, India.\n';
RichText(
text: TextSpan(
children: [
TextSpan(text: "The "),
WidgetSpan(child: Container(width: 20.0, child: Image.asset('assets/app_icon.png', scale: 1))),
TextSpan(text: paragraph1),
],
),
),
Upvotes: 3
Reputation: 855
if you want to show images you need to convert your data to HTML or Markdown. in MarkDown and HTML, you can show much more then the image. these are packages for HTML and MarkDown:
Upvotes: 2
Reputation: 840
You can use the following to place an image between two texts vertically:
Column(
children: <Widget>[
Text("Hello"),
Image.network(
'REPLACE HERE WITH YOUR IMG URL'),
Text("World")
],
),
or you can use this to place an image between two texts horizontally:
Row(
children: <Widget>[
Text("Hello"),
Image.network(
'REPLACE HERE WITH YOUR IMG URL'),
Text("World")
],
),
Upvotes: 1