How to add List of Images into a Flutter Project?

This Article is posted by seven.srikanth at 27-08-2018 13:38:06

Follow the below steps to add multiple images to the Flutter project and make it scrollable.
You need to follow this article to add images to your project,
and then, copy the below code into your main.dart file. Note: Make sure you have updated the image file names as appropriate.
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Flutter Image Examples'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new Center(
child: new ListView(
children: [
Image.asset('images/carimg.jpeg',
width: 600.0,
height: 240.0,
fit: BoxFit.cover,),
Image.asset('images/carimg.jpeg',
width: 600.0,
height: 240.0,
fit: BoxFit.cover,),
Image.asset('images/carimg.jpeg',
width: 600.0,
height: 240.0,
fit: BoxFit.cover,),
Image.asset('images/carimg.jpeg',
width: 600.0,
height: 240.0,
fit: BoxFit.cover,)
],
),
),
);
}
}
In this example, you can observe that I have used ListView to display multiple Images. It is required because, it will make images scrollable. 
Thanks,
Srikanth

Tags: Multiple images; Scrollable images; Unable to Scroll images in Flutter; Unable to Scroll page in Flutter;



0 Comments
Login to comment.
Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.



Recent Articles


How to add Assets Images and Network images in flutter?

Posted by bloggeraatit on 20 Sep 2019 Article


How to use inkwell class for responding images in flutter?

Posted by bloggeraatit on 20 Sep 2019 Article


Flutter Web Live on Server

Posted by nikhilchaudhary12155 on 18 Sep 2019 Article


How to specify stops in a gradient?

Posted by seven.srikanth on 20 Sep 2019 Article



© 2018 - Fluttercentral | Email to me - Seven.srikanth@gmail.com