How to add List of Images into a Flutter Project?

This Article is posted by seven.srikanth at 8/27/2018 1:38:06 PM



<p>Follow the below steps to add multiple images to the Flutter project and make it scrollable.</p> <p>You need to follow this article to add images to your project, runApp(new MyApp());</p> <p>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'), ); } }</p> <p>class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key);</p> <p>final String title;</p> <p>@override _MyHomePageState createState() => new _MyHomePageState(); }</p> <p>class _MyHomePageState extends State { @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',<br /> width: 600.0, height: 240.0, fit: BoxFit.cover,), Image.asset('images/carimg.jpeg',<br /> width: 600.0, height: 240.0, fit: BoxFit.cover,), Image.asset('images/carimg.jpeg',<br /> width: 600.0, height: 240.0, fit: BoxFit.cover,), Image.asset('images/carimg.jpeg',<br /> width: 600.0, height: 240.0, fit: BoxFit.cover,) ],</p> <pre> ), ), ); </pre> <p>} }</p> <p>In this example, you can observe that I have used ListView to display multiple Images. It is required because, it will make images scrollable.</p> <p>Thanks, Srikanth</p>


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








0 Comments
Login to comment.
Recent Comments