Advertisement
jevixlugya
Oct 12th, 2024
5
0
Never
This is comment for paste pdf reader
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. solved
  2. class Example extends StatefulWidget {
  3. const Example({super.key});
  4.  
  5. @override
  6. State<Example> createState() => _ExampleState();
  7. }
  8. class _ExampleState extends State<Example> {
  9.  
  10. Future<String> getPdfURL() async {
  11. await Future.delayed(const Duration(seconds: 5));
  12.  
  13. return "http://example.com/pdf.pdf";
  14. }
  15.  
  16. @override
  17. Widget build(BuildContext context) {
  18. return Scaffold(
  19. body: FutureBuilder(
  20. future: getPdfURL(), // add your future method here
  21. builder: (context, snapshot) {
  22. if (snapshot.connectionState == ConnectionState.waiting) {
  23. return const CircularProgressIndicator();
  24. } else if (snapshot.hasError) {
  25. return Text('Error: ${snapshot.error}');
  26. } else {
  27. String url = snapshot.data!;
  28. return YourPDFViewerWidget(url: url);
  29. }
  30. },
  31. ),
  32. );
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement