Skip to content

Instantly share code, notes, and snippets.

@minikin
Created December 5, 2019 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minikin/eb00c0e1c830d34442e697abe13c4fab to your computer and use it in GitHub Desktop.
Save minikin/eb00c0e1c830d34442e697abe13c4fab to your computer and use it in GitHub Desktop.
// Copyright (c) 2019 Sasha Prokhorenko.
// Use of this source code is governed by a MIT license.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
final List<String> _items = List<String>.generate(
100, (id) => 'https://picsum.photos/id/$id/500/500');
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text('Flutter Demo'),
),
body: SafeArea(
child: Container(
margin: const EdgeInsets.all(8),
child: ListView.builder(
itemCount: _items.length,
itemBuilder: (_, index) {
return PhotoItem(
imageUrl: _items[index],
);
},
),
),
),
),
);
}
}
class PhotoItem extends StatelessWidget {
final String imageUrl;
const PhotoItem({
@required this.imageUrl,
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
color: Colors.grey[200],
margin: const EdgeInsets.all(4),
child: Image.network(
imageUrl,
fit: BoxFit.cover,
cacheWidth: 600,
cacheHeight: 600,
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment