To read and Write File in Flutter Web

The accepted answer is not completely right. Yes, dart:io is not available on the web, but it is still possible to read files. You can select a file through the system's file picker and read it afterward. An easy option to "write" a file is to send the user an auto-download.

Read:
Use this library to select a file: pub.dev/packages/file_picker (Web migration guide)

import 'dart:html' as webFile;
import 'package:file_picker_web/file_picker_web.dart' as webPicker;

if (kIsWeb) {
   final webFile.File file = await webPicker.FilePicker.getFile(
      allowedExtensions: ['pd'],
      type: FileType.custom,
   );
  
   final reader = webFile.FileReader();
   reader.readAsText(file);

   await reader.onLoad.first;

   String data = reader.result;
}

Write (a.k.a download):

import 'dart:html' as webFile;

if (kIsWeb) {
   var blob = webFile.Blob(["data"], 'text/plain', 'native');

   var anchorElement = webFile.AnchorElement(
      href: webFile.Url.createObjectUrlFromBlob(blob).toString(),
   )..setAttribute("download", "data.txt")..click();
}

in the dart docs it has been explained ... dart:io is not available to web build ... it means that you can not directly access to system files in flutter web . the build will fail .. you need to remove the code in order to run it

this is a security thing .. js doesn't allow it too .. imagine a website that can read all your system files if you visit it .. that's why things like path reading or file reading is not allowed .. it goes same for flutter

hope you have your answer