How do you load an image from the internet?
Image.network() loads images from URLs.
Display images and icons in your app
Passing the Quiz & Exercises is mandatory to earn FX and proceed. If you fail, try again to gain the required FX, then the Proceed button will become available.
You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.
Having trouble? AI is here to help
Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.
Use the AI button at the bottom of the screen
The Image widget displays images from various sources, including the internet, local assets, and memory. It is one of the most frequently used widgets in any Flutter app.
1// From internet2Image.network(3'https://example.com/image.jpg',4width: 200,5height: 200,6fit: BoxFit.cover,7loadingBuilder: (context, child, progress) {8if (progress == null) return child;9return CircularProgressIndicator();10},11errorBuilder: (context, error, stackTrace) {12return Icon(Icons.error);13},14)1516// From assets (local files)17Image.asset(18'assets/images/logo.png',19width: 100,20)2122// From memory23Image.memory(bytes)
The BoxFit property controls how an image is resized to fit inside its container. Choosing the right fit prevents images from looking stretched or leaving unwanted gaps.
1Image.network(2url,3fit: BoxFit.cover, // Fills container, may crop4// Other options:5// BoxFit.contain - Show entire image, may have gaps6// BoxFit.fill - Stretch to fill, distorts7// BoxFit.fitWidth - Match width, may crop height8// BoxFit.fitHeight - Match height, may crop width9// BoxFit.none - No resizing10)
assets/images/ folderflutter:
assets:
- assets/images/
Image.asset('assets/images/photo.png')Flutter comes with a comprehensive set of Material Icons built right in. You can use them without installing any additional packages.
1// Basic icon2Icon(Icons.home)34// Styled icon5Icon(6Icons.favorite,7color: Colors.red,8size: 32,9)1011// With background12Container(13padding: EdgeInsets.all(12),14decoration: BoxDecoration(15color: Colors.blue.withValues(alpha: 0.1),16borderRadius: BorderRadius.circular(12),17),18child: Icon(Icons.settings, color: Colors.blue),19)
Browse all Material Icons at fonts.google.com/icons. You can also use autocomplete in your editor by typing `Icons.` to see all available icon suggestions.
For production apps, image handling should balance quality and speed:
Good media handling improves both perceived quality and app responsiveness.
Display images and icons in your app. This lesson adds one more building block for creating stable and user-friendly Flutter apps.
Build confidence with basics first; speed comes later.
After reading, rewrite the concept in your own words and apply it in a tiny runnable sample.
Each lesson becomes useful when you connect concept, implementation, and real-user outcome together.
Image.network() loads images from URLs.
cover fills the container completely, cropping the image if needed.
Assets are declared in the flutter section of pubspec.yaml.
errorBuilder provides a widget to display when the network image fails to load.
Something seems incorrect, unclear, or missing? Let us know.
FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.
Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.
Sign in to continue with exercises and quiz for this lesson.
Sign In to Continue