0
0
Fluttermobile~20 mins

Image widget (asset, network) in Flutter - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Image Widget Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2: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')
AA loading spinner until the image downloads from the internet.
BA blank screen because Image.asset requires a network URL.
CThe image located at assets/images/picture.png will be displayed.
DAn error because the image path is incorrect without a full URL.
Attempts:
2 left
💡 Hint
Think about where Image.asset loads images from and if it needs internet.
ui_behavior
intermediate
2: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')
AThe app shows the last cached image from that URL.
BThe app crashes with a network error.
CThe app shows a default placeholder image automatically.
DA broken image icon or empty space where the image should be.
Attempts:
2 left
💡 Hint
Think about what Flutter does when it cannot load a network image.
lifecycle
advanced
2: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?
AFlutter caches images only in memory but not on disk.
BFlutter does not cache network images; it downloads every time.
CFlutter caches images in memory and disk automatically for faster reloads.
DFlutter caches images only if you use a special caching package.
Attempts:
2 left
💡 Hint
Think about how apps avoid re-downloading images repeatedly.
📝 Syntax
advanced
2: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.
AImage.asset('assets/pic.png').size(100, 50)
BImage.asset('assets/pic.png', width: 100, height: 50)
CImage.asset('assets/pic.png', size: Size(100, 50))
DImage.asset('assets/pic.png', width=100, height=50)
Attempts:
2 left
💡 Hint
Check the correct parameter names and syntax for Image.asset sizing.
🔧 Debug
expert
2: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)
AIt throws a runtime error because the URL cannot be null.
BIt shows a blank image because null is treated as empty string.
CIt loads a default placeholder image automatically.
DIt compiles but crashes later due to missing internet permission.
Attempts:
2 left
💡 Hint
Think about what happens if you pass null where a string URL is expected.