Q: dart_pdf Image is not generated properly and how to use async function while generating multipage with image Image not loading properly broken image
   PdfImage image = new PdfImage.file(
                doc.document,
                bytes: (File(field.imagename).readAsBytesSync()),
              );

How to use await getContentlist function as async. below function call
doc.addPage(
       pw.MultiPage(
        maxPages: 100,
        pageTheme: _buildTheme(
          pageFormat,
          
        ),
        header: _buildheader2,
        footer: _buildfooter2,
        build:  (pw.Context context)  => getContentlist(context),
      ),
    );

Here is the function
List<pw.Widget> getContentlist(context) {
      List<pw.Widget> contentlist = [];
      contentlist.add(pw.SizedBox(height: 20));

      contentlist.add(_contentheader2(context));                                                    
      return contentlist;
    }


A: I think you need to ask 2 different questions
For the second part if build is not related with Flutter widget build() method you can just modify you snippet to make it async
build:  (pw.Context context) async  => getContentlist(context),

But if it relates to widget build - you need to use FutureBuilder widget which wait for Future state changes and rebuilds widgets
      FutureBuilder<String>(
        future: _yourFuture, 
        builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
          List<Widget> children;
          if (snapshot.hasData) {
            // return widget that shows data
          } else if (snapshot.hasError) {
            // return widget that shows  erro
          } 
          // by default show progress indication
          return Center(
            child: CircularProgressIndicator()
          );
        },
      ),

PS feel free to reach me in comments
