notion_api icon indicating copy to clipboard operation
notion_api copied to clipboard

How to work with typed blocks by design?

Open broderix opened this issue 3 years ago • 2 comments

Hi, please explain how you design work with typed Block (e.g. Paragraph) after retrieve Page?

  NotionResponse resBlocks =
      await notion.blocks.list(block_id: 'YYYYYYYYY');
  Pagination paging = resBlocks.content;
  for (Block block in paging.blocks) {
    if (block.isParagraph) {
      //<-- HOW TO GET Paragraph Object ?
    }
  }
`

broderix avatar Feb 11 '22 22:02 broderix

Right now only can be obtained from jsonContent attribute :(

NotionResponse resBlocks =
      await notion.blocks.list(block_id: 'YYYYYYYYY');
Pagination paging = resBlocks.content;
for (Block block in paging.blocks) {
  if (block.isParagraph) {
    print(block.jsonContent);
  }
}

I don't like a lot of things in this package, so I'm doing it again almost from scratch breaking my mind in the process. I will think about a way to solve this problem for this new version.

Thanks for letting me know and sorry for all my mess here hehe

jonathangomz avatar Feb 24 '22 08:02 jonathangomz

Thanks, it's clear now. Dude, the code is great, don't worry. It would be worse if it didn't exist at all. Let's try to fix the current one and support those who already use it. May the force be with you)

broderix avatar Feb 25 '22 11:02 broderix