text stringlengths 1 474 |
|---|
@override |
Widget build(BuildContext context) { |
const title = 'Fade in images'; |
return MaterialApp( |
title: title, |
home: Scaffold( |
appBar: AppBar( |
title: const Text(title), |
), |
body: Stack( |
children: <Widget>[ |
const Center(child: CircularProgressIndicator()), |
Center( |
child: FadeInImage.memoryNetwork( |
placeholder: kTransparentImage, |
image: 'https://picsum.photos/250?image=9', |
), |
), |
], |
), |
), |
); |
} |
}<code_end> |
<topic_end> |
<topic_start> |
From asset bundle |
You can also consider using local assets for placeholders. |
First, add the asset to the project’s pubspec.yaml file |
(for more details, see Adding assets and images):Then, use the FadeInImage.assetNetwork() constructor: |
<code_start>FadeInImage.assetNetwork( |
placeholder: 'assets/loading.gif', |
image: 'https://picsum.photos/250?image=9', |
),<code_end> |
<topic_end> |
<topic_start> |
Complete 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) { |
const title = 'Fade in images'; |
return MaterialApp( |
title: title, |
home: Scaffold( |
appBar: AppBar( |
title: const Text(title), |
), |
body: Center( |
child: FadeInImage.assetNetwork( |
placeholder: 'assets/loading.gif', |
image: 'https://picsum.photos/250?image=9', |
), |
), |
), |
); |
} |
}<code_end> |
<topic_end> |
<topic_start>Play and pause a video |
Playing videos is a common task in app development, |
and Flutter apps are no exception. To play videos, |
the Flutter team provides the video_player plugin. |
You can use the video_player plugin to play videos |
stored on the file system, as an asset, or from the internet.warning Warning |
At this time, |
the video_player plugin doesn’t work with any desktop platform. |
To learn more, check out the video_player package.On iOS, the video_player plugin makes use of |
AVPlayer to handle playback. On Android, |
it uses ExoPlayer.This recipe demonstrates how to use the video_player package to stream a |
video from the internet with basic play and pause controls using |
the following steps:<topic_end> |
<topic_start> |
1. Add the video_player dependency |
This recipe depends on one Flutter plugin: video_player. |
First, add this dependency to your project.To add the video_player package as a dependency, run flutter pub add:<topic_end> |
<topic_start> |
2. Add permissions to your app |
Next, update your android and ios configurations to ensure |
that your app has the correct permissions to stream videos |
from the internet.<topic_end> |
<topic_start> |
Android |
Add the following permission to the AndroidManifest.xml file just after the |
<application> definition. The AndroidManifest.xml file is found at |
<project root>/android/app/src/main/AndroidManifest.xml.<topic_end> |
<topic_start> |
iOS |
For iOS, add the following to the Info.plist file found at |
<project root>/ios/Runner/Info.plist.warning Warning |
The video_player plugin can only play asset videos in iOS simulators. |
You must test network-hosted videos on physical iOS devices.<topic_end> |
<topic_start> |
3. Create and initialize a VideoPlayerController |
Now that you have the video_player plugin installed with the correct |
permissions, create a VideoPlayerController. The |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.