Search code examples
flutterdartflutter-web

How can I read content form a local file with flutter for web?


I want to make a Flutter Web App like Blog System,but when I use the library 'dart:io', I found it doesn't supported in Flutter for Web. So,how can I read content from a local markdown file with Flutter for web? Thx! And apology for My poor English.


Solution

  • I see an example here on the flutter web samples repo.

    https://github.com/flutter/samples/blob/master/web/github_dataviz/lib/main.dart Check the Future loadGitHubData() async function.

    They have used HttpRequest.getString() method. This is ideally a client side request as per the docs here.

    https://api.dartlang.org/stable/2.4.0/dart-html/HttpRequest-class.html

    I am not sure if this is what you want. If you want to just access the contents of the MD file this should help. But if you want to process it into an html or something you probably have to do it in your server.