How to create images in A4 or PDF in Flutter from widgets? How to create images in A4 or PDF in Flutter from widgets? dart dart

How to create images in A4 or PDF in Flutter from widgets?


Method 1: Generate for one page, then (automatically) scroll to next page, then generate for the second page, etc.

Method 2: For each page, wrap by one RepaintBoundary and one Key. Say you have 10 pages, then you have 10 keys, and use those keys to generate all pages.

If only visible thing is generated, try the following:

List<Widget> yourPages = ...;List<Key> yourKeys = yourPages.map((_) => GlobalKey()).toList(); // or other kinds of keys? what do you useStack(children:[for(var i=0;i< yourPages.length;i++) RepaintBoundary(key: yourKeys[i], child: yourPages[i]),])

In this way, everything may be generate-able.