-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.triage-automationSee https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.type-questionA question about expected behavior or functionalityA question about expected behavior or functionality
Description
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:
extension SomeExtension on SomeClass {
Future<List<User>> getUsers() {}
}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?
Metadata
Metadata
Assignees
Labels
area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.triage-automationSee https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.type-questionA question about expected behavior or functionalityA question about expected behavior or functionality