Skip to content

Instantly share code, notes, and snippets.

@aliyazdi75
Last active December 20, 2021 13:57
Show Gist options
  • Save aliyazdi75/f70f86b7877e3f5cf7f66c081e18e6ba to your computer and use it in GitHub Desktop.
Save aliyazdi75/f70f86b7877e3f5cf7f66c081e18e6ba to your computer and use it in GitHub Desktop.
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(
title: 'Test CachedNetworkImage',
),
);
}
}
class MyHomePage extends StatefulWidget {
final String title;
const MyHomePage({
Key? key,
required this.title,
}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: CachedNetworkImage(
errorWidget: (context, url, error) => const Icon(Icons.error),
imageUrl:
'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone-err.png',
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment