How to import api calls in custom code?

Custom Code

Hi Everyone,

I've been trying to use an API call I already created on FF's API call manager.
And I can't use that API call on a custom Action !!

I've read this discussion already but it's not working for me, so not sure if things changed since that post or I still need to learn a bit more...

What have you tried so far?

1- The API call isn't recognized whether I use :
"
" KonnectCall(); " or " KonnectCall.call(); "


2- FF code editor underlines it with red and suggests me to import the api_calls.dart package but it doesn't work whether it's with:
"
import '/backend/api_requests/api_calls.dart';
"
or :
import 'package:nameofmypackage/backend/api_requests/api_calls.dart'
or:

import '../../backend/api_requests/api_calls.dart';

--> It always gives me the same error :
"Target of URI doesn't exist: '/backend/api_requests/api_calls.dart'. Try creating the file referenced by the URI, or try using a URI for a file that does exist."


The only thing that "worked" was to copy the API call class definitions from the api_calls.dart file and add them as part of the custom function...
And even though it's a work-around that "does the trick"... it defies the 1st rule of coding : No redundancies ๐Ÿ˜›
So like the title says : Does anyone know how to import api calls into custom code? (if it's even possible) :)

Thank you in advance

Did you check FlutterFlow's Documentation for this topic?
Yes
4
4 replies