Locally when I run the built up function (main.dart), I can import everything just fine.
However the imports do not work if I push the code.tar.gz to deployment.
Here are the logs from build:
Info: Compiling with sound null safety
user_code/lib/main.dart:1:8: Error: Error when reading 'user_code/lib/utils/model/response.dart': No such file or directory
import 'utils/model/response.dart';
^
user_code/lib/main.dart:2:8: Error: Error when reading 'user_code/lib/utils/network.dart': No such file or directory
import 'utils/network.dart';
^
user_code/lib/main.dart:16:28: Error: Undefined name 'NetworkResponse'.
Network.send(response);
^^^^^^^^^^^^^^^
user_code/lib/main.dart:16:5: Error: Undefined name 'Network'.
Network.send(response);
^^^^^^^
Error: AOT compilation failed
Short snipped from the main.dart:
import 'utils/network.dart';
import 'utils/model/response.dart';
Future<void> start(final request, final response) async {
final variables = request.variables;
final apiKey = variables['REMOTE_CONFIG_API_KEY'].toString();
final event = variables['APPWRITE_FUNCTION_EVENT'].toString();
// make network requests and send results back with response.send()
}
How you're deploying the function?
manually uploading the code.tar.gz
Could you please try deploying using cli?
I had some similar errors, and solved it by creating a folder and function with CLI and deploying with it too
I'll try.
Failed with same stacktrace.
Added the whole implementation inside main.dart & it works.
Uh, what do you mean?
I had 3 files in total, main.dart, utils/response.dart, utils/network.dart.
I used all the logic of 3 separate files inside main.dart without any imports to external files which seems to work.
Maybe use relative imports instead?
Otherwise, you can have a pubspec.yaml and give your package a name
hmm, this completely skipped my mind.
Tried the project:*/* format import by moving the logger.dart in lib folder & did import 'package:import_issues/logger.dart'; which worked! 🤩
I'll add this info. on the GitHub issue as well, this probably needs to be documented somewhere also I guess. Maybe I've been completely off dart for quite sometime as well, hence this issue lol.
This can be marked as SOLVED.
[SOLVED] Import issues
Recommended threads
- TablesDB can't be used in Appwrite Funct...
I have written a function (DART) and it won't deploy. Here is what I get : 2026-03-14T17:09:41.459693680Z Compiling ... 2026-03-14T17:09:42.915619217Z ../build...
- Local appwrite run functions --user-id n...
Hi, I'm running into an issue when testing Appwrite functions locally with user impersonation. I'm using a self-hosted Appwrite instance and running functions ...
- Function domain not available
Hello, even tho in docs you clearly describe that every function has its domain, I can not see it anywhere in any of my projects. How do I reveal the url of th...