Package selection guidance compiled from public package information, community data, and project usage.
A Dart package that provides a wrapper for the public beta Notion API, enabling developers to interact with Notion databases, pages, and content as if using a native SDK. It simplifies authentication, data retrieval, and manipulation through intuitive methods tailored for Flutter applications across multiple platforms. The package abstracts low-level HTTP requests, offering a clean, type-safe interface for working with Notion's structured data. Ideal for apps needing real-time synchronization with Notion workspaces or dynamic content management.
Use cases
Integrating Notion databases into Flutter apps
Synchronizing app data with Notion pages
Building content management tools with Notion backend
Automating Notion page updates from Flutter apps
Creating task trackers using Notion as a data source
Key features
Type-safe API calls
Cross-platform support (Android, iOS, Web, macOS, Windows, Linux)
Authentication handling via Notion API token
Support for database queries and page operations
Simple, readable method syntax
Suitable for
Flutter developers building productivity apps
Teams using Notion as a primary workspace
Apps requiring bidirectional sync with Notion
Developers seeking a lightweight Notion integration
Considerations
Requires valid Notion API token
Limited to public beta API features
Not suitable for private or enterprise-only Notion endpoints
May require updates as Notion API evolves
No built-in caching or offline support
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Important: The methods return a NotionResponse. You can find how to use it in its documentation.
NotionClient class
You only have to create a new instance of the NotionClient class and all the API requests will be available as class methods.
NotionClient notion = NotionClient(token: 'YOUR SECRET TOKEN FROM INTEGRATIONS PAGE');
Individual classes
You can also use individual request group class like NotionPagesClient or NotionDatabasesClient. They are used like the main client but the methods are class methods instead of class properties methods.
Example
// With main classNotionClient notion = NotionClient(token: 'YOUR_TOKEN');
notion.databases.fetchAll();
// With individual classNotionDatabasesClient databases = NotionDatabasesClient(token: 'YOUR_TOKEN');
databases.fetchAll();
A few examples
A page created and filled using only this package:
https://jonathangomz.notion.site/notion_api-example-0893dd2cb38a413d90165cb810b3c019
To see code to create the page above or see more examples go here.
Append blocks children
// Create children instance:Children children = Children.withBlocks([
Heading(text: Text('Test')),
Paragraph(texts: [
Text('Lorem ipsum (A)'),
Text('Lorem ipsum (B)',
annotations: TextAnnotations(
bold: true,
underline: true,
color: ColorsTypes.Orange,
))
])
]);
// Send the instance to Notion
notion.blocks.append(
to: 'YOUR_BLOCK_ID',
children: children,
);
Create a page
// Create a page instancePage page = Page(
parent: Parent.database(id: 'YOUR_DATABASE_ID'),
title: Text('NotionClient (v1): Page test'),
);
// Send the instance to Notion.
notion.pages.create(page);
Errors
Some errors that I have encounter and still don't know how to solve because are errors that also occur on Postman are:
Create page with chidren
When the parent is a page the error is:
"body failed validation: body.properties.title.type should be an array, instead was `\"array\"`."
But when the parent is a database then the error is:
"body failed validation: body.parent.page_id should be defined, instead was `undefined`."
You can create the page first and then add the children as shown in the examples.
Contributions
Please help, I don't even know if what I'm doing is right.
Add constructors with only single text content with default style for:
Paragraph.text('some text here...')
ToDo.text('some text here...', checked: true)
Heading.text('some text here...', type: 2)
BulletedListItem.text('some text here...')
NumberedListItem.text('some text here...')
Toggle.text('some text here...', children: [])
Add more constructors for Heading class:
one: Heading with type 1 by default.
two: Heading with type 2 by default.
three: Heading with type 3 by default.
Add more constructors for Text class:
code: Text with code style by default.
italic: Text with italic style by default.
bold: Text with bold style by default.
[Opt] list: List of words separated by comma (by default).
Example: Text.list() will receive a list of Text and will be concatenated separated with comma by default. It may be unnecessary. Can help to make the code more readable.
[Opt] sep: Text separator.
Example: Text.sep(), by default, will insert " " in a list of Text instances, but it will be able to do more things that I don't know yet, hehe. It may be unnecessary. Can help to make the code more readable.