Flutter: Network to Local File (Image, Audio, Video)

Recently I was working on a client’s project where I needed to build a chat app. Now in the app, we have text, images, audios and videos. For text and images, I found ways where I can make them available locally and play from local directory (for image I used Network to File Image). When it came to audio and video files, I could not find any package. So now what? Let’s build one.

In this post I would just share the repository of the package, but perhaps in another article, I would explain how it is implemented and make a package of it.

Repository Link

Here is the repository: Network to Local File

Sample Code

Here is an example on how you can use it:

  mainAxisAlignment: MainAxisAlignment.center,
  children: <Widget>[

      mediaURL: 'https://smart-y.fra1.digitaloceanspaces.com/ChatMedia/84050157-ef7c-47a9-84f8-45b13584f747.jpg',
      mediaType: 'image',

      mediaURL: 'https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3',
      mediaType: 'audio'

      child: NetworkToLocal(
        mediaURL: 'https://assets.mixkit.co/videos/preview/mixkit-forest-stream-in-the-sunlight-529-large.mp4',
        mediaType: 'video'

Thank you.

6 thoughts on “Flutter: Network to Local File (Image, Audio, Video)

  1. How to import this package into our flutter project. I mean package name in pubspec and import it in .dart file

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s