text stringlengths 1 474 |
|---|
Flutter also uses native platform mechanisms to draw |
transitional launch screens to your Flutter app while the |
Flutter framework loads. This launch screen persists until |
Flutter renders the first frame of your application.info Note |
This implies that if you don’t call runApp() in the |
main() function of your app (or more specifically, |
if you don’t call FlutterView.render() in response to |
PlatformDispatcher.onDrawFrame), |
the launch screen persists forever.<topic_end> |
<topic_start>Android |
To add a launch screen (also known as “splash screen”) to your |
Flutter application, navigate to .../android/app/src/main. |
In res/drawable/launch_background.xml, |
use this layer list drawable XML to customize |
the look of your launch screen. The existing template provides |
an example of adding an image to the middle of a white splash |
screen in commented code. You can uncomment it or use other |
drawables to achieve the intended effect.For more details, see |
Adding a splash screen to your Android app.<topic_end> |
<topic_start>iOS |
To add an image to the center of your “splash screen”, |
navigate to .../ios/Runner. |
In Assets.xcassets/LaunchImage.imageset, |
drop in images named LaunchImage.png, |
LaunchImage@2x.png, LaunchImage@3x.png. |
If you use different filenames, |
update the Contents.json file in the same directory.You can also fully customize your launch screen storyboard |
in Xcode by opening .../ios/Runner.xcworkspace. |
Navigate to Runner/Runner in the Project Navigator and |
drop in images by opening Assets.xcassets or do any |
customization using the Interface Builder in |
LaunchScreen.storyboard.For more details, see |
Adding a splash screen to your iOS app. |
<topic_end> |
<topic_start>Display images from the internet |
Displaying images is fundamental for most mobile apps. |
Flutter provides the Image widget to |
display different types of images.To work with images from a URL, use the |
Image.network() constructor. |
<code_start>Image.network('https://picsum.photos/250?image=9'),<code_end> |
<topic_end> |
<topic_start> |
Bonus: animated gifs |
One useful thing about the Image widget: |
It supports animated gifs. |
<code_start>Image.network( |
'https://docs.flutter.dev/assets/images/dash/dash-fainting.gif');<code_end> |
<topic_end> |
<topic_start> |
Image fade in with placeholders |
The default Image.network constructor doesn’t handle more advanced |
functionality, such as fading images in after loading. |
To accomplish this task, |
check out Fade in images with a placeholder.<topic_end> |
<topic_start> |
Interactive example |
<code_start>import 'package:flutter/material.dart'; |
void main() => runApp(const MyApp()); |
class MyApp extends StatelessWidget { |
const MyApp({super.key}); |
@override |
Widget build(BuildContext context) { |
var title = 'Web Images'; |
return MaterialApp( |
title: title, |
home: Scaffold( |
appBar: AppBar( |
title: Text(title), |
), |
body: Image.network('https://picsum.photos/250?image=9'), |
), |
); |
} |
}<code_end> |
<topic_end> |
<topic_start>Fade in images with a placeholder |
When displaying images using the default Image widget, |
you might notice they simply pop onto the screen as they’re loaded. |
This might feel visually jarring to your users.Instead, wouldn’t it be nice to display a placeholder at first, |
and images would fade in as they’re loaded? Use the |
FadeInImage widget for exactly this purpose.FadeInImage works with images of any type: in-memory, local assets, |
or images from the internet.<topic_end> |
<topic_start> |
In-Memory |
In this example, use the transparent_image |
package for a simple transparent placeholder. |
<code_start>FadeInImage.memoryNetwork( |
placeholder: kTransparentImage, |
image: 'https://picsum.photos/250?image=9', |
),<code_end> |
<topic_end> |
<topic_start> |
Complete example |
<code_start>import 'package:flutter/material.dart'; |
import 'package:transparent_image/transparent_image.dart'; |
void main() { |
runApp(const MyApp()); |
} |
class MyApp extends StatelessWidget { |
const MyApp({super.key}); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.