Conditional import for server/console only #59786
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
triage-automation
See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.
type-question
A question about expected behavior or functionality
I want to separate client and server logic into different files using conditional imports.
For clients, such as web and mobile, the implementation should use network calls to fetch data from the API (which serves as the backend).
On the other hand, the server should connect directly to the database without relying on an HTTP call.
The goal is to have the same function signature across all platforms:
On mobile or web (or Flutter in general),
getUsers
should make an HTTP request to the API.When running in a console application (server-side),
getUsers
should interact directly with the database.I've experimented with various
dart.library.something
configurations but haven’t been able to achieve this functionality.Is this approach feasible?
The text was updated successfully, but these errors were encountered: