aslam mac

I’ll discuss different methods for upload files from flutter web.

Uploading from Flutter web is no big deal. We can perform it by multiple methods.

Method 1

  • Using dart:html library. This is not recommended.

Steps

  • Import dart:html package to project file.
import 'dart:html';
  • Method for upload image

Here we can change the file types using accept.

Thank you 😊

Other methods will post soon.

Photo by Markus Spiske on Unsplash

Linting is something that you should be using for every single project. It is a one time set up that helps all your projects stay clean and organized.

You have lots of options to either use packages or you can make custom ones and do it yourself which is my preferred way.

Steps:

  • Add lint as dependency to your pubspec.yaml
dev_dependencies:
lint: ^1.0.0
  • Create a analysis_options.yaml file in the root of your project and import the lint rules:
include: package:lint/analysis_options.yaml
  • If you’re writing a package with a public API you should use the package version instead
include: package:lint/analysis_options_package.yaml

Enable/Disable rules

lint is customizable, you can add or remove rules, depending on your needs. To do so adjust your analysis_options.yaml.

Flutter web apps support two ways of configuring URL-based navigation on the web:

  • Hash (default)Paths are read and written to the hash fragment. For example, flutterexample.dev/#/path/to/screen.
  • PathPaths are read and written without a hash. For example, flutterexample.dev/path/to/screen.
Photo by Artur Shamsutdinov on Unsplash

Identifying host platforms in flutter has little confusion in the case of the web. we cover most of the issues of platform detection.

For mobile only.

For web included project.

You can also detect if you are running on the web using kIsWeb, a global constant indicating if the application was compiled to run on the web:

Full code.

Thank you☺

Photo by Arnold Francisca on Unsplash

As we all know that Provider is the best known state management package available for flutter application development.

  • initState method called when this object is inserted into the tree.
  • The framework will call this method exactly once for each State object it creates.

You need to use the context to call Provider.of() so you can add addPostFrameCallback() which is called after the first build, there you can use the context