How to add Assets Images and Network images in flutter?

This Article is posted by bloggeraatit at 9/20/2019 5:54:47 AM



<p>There are a lots of ways to add the asset and network images in flutter. This is one of the simplest way to add images in flutter. First of all,to show the asset image you have to put the image in a folder,in my case i have put the image in image folder.and then you can give the asset path in pubsec.yaml file like this</p> <p>![](../../Uploads/9b28b5d8-1a96-4c9b-9889-d5721ad45bf4.pngwidth="50%height="auto]( Then font-size: 1rem;](You can simply use Image.asset and <a href=>http://Image.network</a><a href="Image.network">http://Image.network</a> to add asset and network image. font-size: 1rem;]( font-size: 1rem;](The output of app will be like this</p> <p>![](../../Uploads/c85606d8-d945-4f5f-983c-7668d911b26f.gifwidth="50%height="auto]( The complete main.dart code is like this: color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre-wrap;](color: #569cd6;](import color: #ce9178;]('package:flutter/material.dart'; color: #569cd6;](void color: #dcdcaa;](main() => color: #dcdcaa;](runApp(color: #4ec9b0;](MyApp()); color: #569cd6;](class color: #4ec9b0;](MyApp color: #569cd6;](extends color: #4ec9b0;](StatelessWidget { color: #569cd6;](@override color: #4ec9b0;](Widget color: #dcdcaa;](build(color: #4ec9b0;](BuildContext context) { color: #c586c0;](return color: #4ec9b0;](MaterialApp( debugShowCheckedModeBanner: color: #569cd6;](false, home: color: #4ec9b0;](HomePage(), ); }} color: #569cd6;](class color: #4ec9b0;](HomePage color: #569cd6;](extends color: #4ec9b0;](StatelessWidget { color: #569cd6;](@override color: #4ec9b0;](Widget color: #dcdcaa;](build(color: #4ec9b0;](BuildContext context) { color: #c586c0;](return color: #4ec9b0;](Scaffold( appBar: color: #4ec9b0;](AppBar( title: color: #4ec9b0;](Text(color: #ce9178;]("Image on flutter"), ), backgroundColor: color: #4ec9b0;](Colors.greenAccent, body: color: #4ec9b0;](Center( child: color: #4ec9b0;](Column( children: [ color: #4ec9b0;](Image.color: #dcdcaa;](asset(color: #ce9178;]("image/robo.jpg"), color: #4ec9b0;](Image.color: #dcdcaa;](network( color: #ce9178;]("<a href=>https://picsum.photos/250?image=9</a><a href="https://picsum.photos/250?image=9">https://picsum.photos/250?image=9</a>", ), ], )), ); }}</p>


Tags: flutter








0 Comments
Login to comment.
Recent Comments