ListView with Images

This Article is posted by seven.srikanth at 8/27/2018 2:10:17 AM



<p>font-size: 1rem;](This Flutter example will help you to create a ListView with images. In order to try this example, all you need to do is to copy paste the below code into main.dart file of your freshly created flutter project. font-size: 1rem;](</p> <p>font-size: 1rem;](</p> <p>The final output of this example is as below, ![](https://www.fluttercentral.com/Uploads/6b7e1b11-1fcf-4534-b34f-40b01054097d.jpgwidth="50%height="auto](</p> <p>Before moving into this, here is the latest article which I have written inlines to this.ListView with Images from the Internet and below is the screenshot of the app we created. Check it out. <a href="https://fluttercentral.com/Articles/Post/1145">https://fluttercentral.com/Articles/Post/1145background-color: white; font-size: 1rem;</a>font-size: 1rem;]( ![](https://fluttercentral.com/Uploads/f819b314-540c-46e3-97c6-22b0fd9b877f.pngwidth="50%height="auto](</p> <p>Full code from main.dart</p> <p>color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Consolas, "Courier New", monospace; line-height: 19px; white-space: pre-wrap;](color: rgb(86, 156, 214);](import color: rgb(206, 145, 120);]('package:flutter/material.dart';color: rgb(86, 156, 214);](import color: rgb(206, 145, 120);]('package:flutter/foundation.dart'; color: rgb(86, 156, 214);](void color: rgb(220, 220, 170);](main() { color: rgb(220, 220, 170);](runApp(color: rgb(78, 201, 176);](MyApp());} color: rgb(86, 156, 214);](class color: rgb(78, 201, 176);](MyApp color: rgb(86, 156, 214);](extends color: rgb(78, 201, 176);](StatelessWidget { color: rgb(86, 156, 214);](@override color: rgb(78, 201, 176);](Widget color: rgb(220, 220, 170);](build(color: rgb(78, 201, 176);](BuildContext context) { color: rgb(86, 156, 214);](final title = color: rgb(206, 145, 120);]("ListView List"; color: rgb(197, 134, 192);](return color: rgb(78, 201, 176);](MaterialApp( title: title, home: color: rgb(78, 201, 176);](Scaffold(appBar: color: rgb(78, 201, 176);](AppBar( title: color: rgb(78, 201, 176);](Text(title), ), body: color: rgb(197, 134, 192);](new color: rgb(78, 201, 176);](ListView( shrinkWrap: color: rgb(86, 156, 214);](true, padding: color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](EdgeInsets.color: rgb(220, 220, 170);](all(color: rgb(181, 206, 168);](20.0), children: color: rgb(78, 201, 176);](List.color: rgb(220, 220, 170);](generate(choices.length, (index) { color: rgb(197, 134, 192);](return color: rgb(78, 201, 176);](Center( child: color: rgb(78, 201, 176);](ChoiceCard(choice: choices[index], item: choices[index]), ); } ) ) ) ); }} color: rgb(86, 156, 214);](class color: rgb(78, 201, 176);](Choice { color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice({color: rgb(86, 156, 214);](this.title, color: rgb(86, 156, 214);](this.icon}); color: rgb(86, 156, 214);](final color: rgb(78, 201, 176);](String title; color: rgb(86, 156, 214);](final color: rgb(78, 201, 176);](IconData icon;} color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](List choices = color: rgb(86, 156, 214);](const [ color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car.', icon: color: rgb(78, 201, 176);](Icons.directions_car), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Bicycle, because its a Bicycle. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Bicycle. This is a Bicycle, because its a Bicycle. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Bicycle. This is a Bicycle, because its a Bicycle. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Bicycle.', icon: color: rgb(78, 201, 176);](Icons.directions_bike), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Boat, because its a Boat. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Boat', icon: color: rgb(78, 201, 176);](Icons.directions_boat), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Bus, because its a Bus. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Bus', icon: color: rgb(78, 201, 176);](Icons.directions_bus), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Train, because its a Train. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Train', icon: color: rgb(78, 201, 176);](Icons.directions_railway), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Walk, because its a Walk. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Walk', icon: color: rgb(78, 201, 176);](Icons.directions_walk), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car.', icon: color: rgb(78, 201, 176);](Icons.directions_car), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car', icon: color: rgb(78, 201, 176);](Icons.directions_car), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Bicycle, because its a Bicycle. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Bicycle', icon: color: rgb(78, 201, 176);](Icons.directions_bike), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Boat, because its a Boat. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Boat', icon: color: rgb(78, 201, 176);](Icons.directions_boat), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Bus, because its a Bus. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Bus', icon: color: rgb(78, 201, 176);](Icons.directions_bus), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Train, because its a Train. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Train', icon: color: rgb(78, 201, 176);](Icons.directions_railway), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Walk, because its a Walk. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Walk', icon: color: rgb(78, 201, 176);](Icons.directions_walk), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car.', icon: color: rgb(78, 201, 176);](Icons.directions_car), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car', icon: color: rgb(78, 201, 176);](Icons.directions_car), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Bicycle, because its a Bicycle. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Bicycle', icon: color: rgb(78, 201, 176);](Icons.directions_bike), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Boat, because its a Boat. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Boat', icon: color: rgb(78, 201, 176);](Icons.directions_boat), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Bus, because its a Bus. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Bus', icon: color: rgb(78, 201, 176);](Icons.directions_bus), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car. This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car.', icon: color: rgb(78, 201, 176);](Icons.directions_car), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Train, because its a Train. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Train', icon: color: rgb(78, 201, 176);](Icons.directions_railway), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Walk, because its a Walk. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Walk', icon: color: rgb(78, 201, 176);](Icons.directions_walk), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Car, because its a car. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a car', icon: color: rgb(78, 201, 176);](Icons.directions_car), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Bicycle, because its a Bicycle. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Bicycle', icon: color: rgb(78, 201, 176);](Icons.directions_bike), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Boat, because its a Boat. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Boat', icon: color: rgb(78, 201, 176);](Icons.directions_boat), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Bus, because its a Bus. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Bus', icon: color: rgb(78, 201, 176);](Icons.directions_bus), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Train, because its a Train. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Train', icon: color: rgb(78, 201, 176);](Icons.directions_railway), color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](Choice(title: color: rgb(206, 145, 120);]('This is a Walk, because its a Walk. So, itcolor: rgb(215, 186, 125);]('color: rgb(206, 145, 120);](s a Walk', icon: color: rgb(78, 201, 176);](Icons.directions_walk),]; color: rgb(86, 156, 214);](class color: rgb(78, 201, 176);](ChoiceCard color: rgb(86, 156, 214);](extends color: rgb(78, 201, 176);](StatelessWidget { color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](ChoiceCard( {color: rgb(78, 201, 176);](Key key, color: rgb(86, 156, 214);](this.choice, color: rgb(86, 156, 214);](this.onTap, color: rgb(86, 156, 214);](@required color: rgb(86, 156, 214);](this.item, color: rgb(86, 156, 214);](this.selected: color: rgb(86, 156, 214);](false} ) : color: rgb(86, 156, 214);](super(key: key); color: rgb(86, 156, 214);](final color: rgb(78, 201, 176);](Choice choice; color: rgb(86, 156, 214);](final color: rgb(78, 201, 176);](VoidCallback onTap; color: rgb(86, 156, 214);](final color: rgb(78, 201, 176);](Choice item; color: rgb(86, 156, 214);](final color: rgb(86, 156, 214);](bool selected;</p> <p>color: rgb(86, 156, 214);](@override color: rgb(78, 201, 176);](Widget color: rgb(220, 220, 170);](build(color: rgb(78, 201, 176);](BuildContext context) { color: rgb(78, 201, 176);](TextStyle textStyle = color: rgb(78, 201, 176);](Theme.color: rgb(220, 220, 170);](of(context).textTheme.display1; color: rgb(197, 134, 192);](if (selected) textStyle = textStyle.color: rgb(220, 220, 170);](copyWith(color: color: rgb(78, 201, 176);](Colors.lightGreenAccent<a href="400%5D">color: rgb(181, 206, 168);</a>; color: rgb(197, 134, 192);](return color: rgb(78, 201, 176);](Card( color: color: rgb(78, 201, 176);](Colors.white, child: color: rgb(78, 201, 176);](Row( children: [ color: rgb(197, 134, 192);](new color: rgb(78, 201, 176);](Container( padding: color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](EdgeInsets.color: rgb(220, 220, 170);](all(color: rgb(181, 206, 168);](8.0), alignment: color: rgb(78, 201, 176);](Alignment.topLeft, child: color: rgb(78, 201, 176);](Icon(choice.icon, size:color: rgb(181, 206, 168);](80.0, color: textStyle.color,)), color: rgb(197, 134, 192);](new color: rgb(78, 201, 176);](Expanded( child: color: rgb(197, 134, 192);](new color: rgb(78, 201, 176);](Container( padding: color: rgb(86, 156, 214);](const color: rgb(78, 201, 176);](EdgeInsets.color: rgb(220, 220, 170);](all(color: rgb(181, 206, 168);](10.0), alignment: color: rgb(78, 201, 176);](Alignment.topLeft, child: color: rgb(78, 201, 176);](Text(choice.title, style: color: rgb(86, 156, 214);](null, textAlign: color: rgb(78, 201, 176);](TextAlign.left, maxLines: color: rgb(181, 206, 168);](5,), ) ), ], crossAxisAlignment: color: rgb(78, 201, 176);](CrossAxisAlignment.start, ) ); }}</p> <p>Note: Instead of images, I used Icons. But it will be easy to replace them with Images. Thanks,Srikanth</p>


Tags: Flutter example will help you to create a ListView with images; Mobile App with ListView and Images; ListView with Images on Mobile App;








0 Comments
Login to comment.
Recent Comments