Challenge - 5 Problems
Image Widget Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What will this Flutter code display?
Consider this Flutter code snippet that uses the Image widget to load an image from assets. What will the app show on the screen?
Flutter
Image.asset('assets/images/picture.png')Attempts:
2 left
💡 Hint
Think about where Image.asset loads images from and if it needs internet.
✗ Incorrect
Image.asset loads images bundled inside the app package, so it shows the local image immediately if the path is correct.
❓ ui_behavior
intermediate2:00remaining
What happens if the network image URL is invalid?
This Flutter code tries to load an image from the internet. What will the user see if the URL is wrong or the server is down?
Flutter
Image.network('https://example.com/invalid-image.jpg')Attempts:
2 left
💡 Hint
Think about what Flutter does when it cannot load a network image.
✗ Incorrect
If the network image fails to load, Flutter shows an empty box or broken image icon by default unless a placeholder is provided.
❓ lifecycle
advanced2:00remaining
How does Flutter cache network images by default?
When you use Image.network in Flutter, how does the framework handle caching of the downloaded images?
Attempts:
2 left
💡 Hint
Think about how apps avoid re-downloading images repeatedly.
✗ Incorrect
Flutter's Image.network uses the underlying image provider which caches images only in memory but not on disk.
📝 Syntax
advanced2:00remaining
Which code correctly loads a local asset image with a fixed size?
Choose the Flutter code snippet that loads an asset image and sets its width to 100 pixels and height to 50 pixels.
Attempts:
2 left
💡 Hint
Check the correct parameter names and syntax for Image.asset sizing.
✗ Incorrect
Image.asset accepts width and height named parameters to set image size. Other options use invalid syntax or methods.
🔧 Debug
expert2:00remaining
Why does this Image.network code cause a runtime error?
Analyze this Flutter code snippet and find why it throws an error at runtime.
Flutter
Image.network(null)Attempts:
2 left
💡 Hint
Think about what happens if you pass null where a string URL is expected.
✗ Incorrect
Image.network requires a non-null string URL. Passing null causes a runtime error.