black friday sale

Flat 10% off on the purchase of any two apps or more. Use coupon code - FESTIVAL10

Grab It Now
Check Mobile App
Read now
Start a Project

Read and write from disk in the Flutter


We need to read and write files to disk in an app while handling cases.

Reading and writing files to disk is a way to persist data locally in the app. Data stored in the disk is safe in all stages of the application.

When the user uninstalls the app then the disk data will be cleared otherwise it will keep safe in the disk.

In Flutter, To save files to disk, combine the path_provider plugin with the dart:io library.

This task uses the following steps to read and write from disk.

Let’s start with the implementation

Add dependency

1. Find the correct local path

This example stores information in the documents directory. You can find the path to the documents directory as follows:

2. Create a reference to the file location

Once you know where to store the file, create a reference to the file’s full location. You can use the File class from the dart:io library to achieve this.

3. Write data to the file

First, write some data to the file. The counter is an integer, but is written to the file as a string using the '$counter' syntax.

4. Read data from the file

We have some data on disk, we can read it. Once again, use the File class.

A complete example of read and write from disk

Images of the output


In this blog, we have discussed Read and write from disk in the Flutter

I hope it will help you out in understanding and getting a brief idea about it.

You can also go through the FlutterDev for more understanding

Thank you for reading!!

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.


When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.

Michael Urresta

Michael Urresta

Talk to Sales


Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home