Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 477k

How to fetch data from firebase_database and display it as pdf?

Sep 24 2023 8:08 AM

Hi Team

I need some help i have firebase_database but need now to fetch it on my widget, so when i click the button it can display data as pdf to my screen. Below is my code that i attempted, issue is on viewing and downloading it. 

@override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Dashboard'),
          actions: <Widget>[
            IconButton(
              icon: Icon(Icons.exit_to_app),
              onPressed: () {
                _signOut(context);
              },
            ),
          ],
        ),
        drawer: Drawer(
          child: ListView(
            children: <Widget>[
              UserAccountsDrawerHeader(
                accountEmail:
                    Text(FirebaseAuth.instance.currentUser?.email ?? ''),
                accountName: Text('User'),
              ),

              ListTile(
                title: Text('Logout'),
                onTap: () {
                  _signOut(context);
                },
              ),

              // button to view data from database.
              ElevatedButton(
                onPressed: () async {
                  await _viewPDF();
                },
                child: Text('View PDF'),
              ),

              // button download pdf file
              ElevatedButton(
                onPressed: () async {
                  await _downloadPDF();
                },
                child: Text('Download PDF'),
              ),
            ],
          ),
        ),

 


Answers (1)