dependencies: airtable: ^0.0.2 import 'package:airtable/airtable.dart'; ??
import 'package:dart_airtable/dart_airtable.dart'; ??
void main() async {
final apiKey = 'my-airtable-api-key'
final projectBase = 'my-airtable-project-base';
final recordName = 'Tasks';
var airtable = Airtable(apiKey: apiKey, projectBase: projectBase);
var records = await airtable.getAllRecords(recordName);
print(records);
}
If anyone knows how to solve it, I will be very grateful.
First of all, it seems like you mix two things together. Currently there are two
packagesthat provide a library for the communication with airtable: airtable 0.0.2 and dart_airtable 0.1.1.In your example code you use the import statement for the first
packagebut the code from the second one. As the first one doesn't provide a valid link to arepositoryI'll have a look at the second one.To retrieve
recordsfor a project from the API you can use this code:Unfortunately the
packagehas some bugs. As I wanted to create a record I used the methodcreateRecordlike this:But the only
responseI got wasnull. So I cloned the project and debugged the method. The result was this:After a little bit of searching I found out that the
packagesends wrong data to the airtable API. In atoJsonmethod of theAirtableRecordmodel, the author added the unnecessary fieldsidandcreatedTime. After deleting them, the method works.Response:
I didn't look for the remaining methods, but my advice is to write your own connection to the airtime API or use the existing
packageand change the things that aren't working. Hopefully this helps you.Edit:
I'll checked the
repositoryagain, and it seems that the author is inactive. As it only contains a few methods and models to work with the airtable API, I'll guess it's not a bad idea to just wrote your own implementation.Here an simple example of how to do this (with Dio for the network connection):
Response:
You could now extend this, maybe as a
servicewith theGetItpackage and add your required funtions. I definetly recommend to also usemodelsfor yourresponse(have a look at this).I used one of their example workspaces. The projectBase was an ID. You can just look at their API documentation to see how to build the
requests.Edit 2:
Read could be simple done by this:
Update:
And delete:
These are only examples, I advice you to also read the API documentation to get a overview of what is possible. And your own implementation with proper error handling.
Edit 3:
You can use the
filterByFormulaparameter to retrieve all the data that matches your condition (Reference).E.g.: