Issue
What makes it possible for client side code to share some server side code in dart? I know there are some packages where this is possible but what makes it happen? I haven’t found much on this subject overall and wanted to minimize my code for future projects. I would greatly appreciate it if someone could explain it to me. Thank you in advance:)
Solution
Currently if you don’t import dart:html
or dart:io
nor any library that imports one of these transitive, the code is platforms-independent.
Importing dart:html
ties the code to the browser, importing dart:io
to the standalone VM (there are also the evolving Fletch and Flutter platforms).
There is ongoing work to make imports configurable so that imports import a different library, depending on where the code is executed. This should make it much easier to share libraries between such patforms.
Answered By – Günter Zöchbauer
Answer Checked By – Clifford M. (FlutterFixes Volunteer)