Este es el pdf que esta retornado dicha funcion. Si print en la consola, mostrará el código del pdf. Si desea ver el pdf como pdf, debe mostrarlo en un view en su app. La forma más sencilla es utilizar una webview.
Primero agregue esta dependencia a su pubspec.yaml:
webview_flutter: ^2.3.1
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:webview_flutter/webview_flutter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
var googleDocs = "https://docs.google.com/viewer?url=";
var pdf = 'https://unec.edu.az/application/uploads/2014/12/pdf-sample.pdf';
return Scaffold(
body: WebView(
initialUrl: googleDocs + pdf,
),
);
}
}
Si desea guardar o editar el pdf, debe usar un paquete desde https://pub.dev. Si busca 'pdf', encontrará varios paquetes disponibles.