This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final htmlContent = ''' | |
<h1>Heading Example</h1> | |
<p>This is a paragraph.</p> | |
<img src="image.jpg" alt="Example Image" /> | |
<blockquote>This is a quote.</blockquote> | |
<table> | |
<tbody> | |
<tr> | |
<td>Okay <br /></td> | |
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Launching lib/main.dart on iPhone 14 Pro in debug mode... | |
Running Xcode build... | |
└─Compiling, linking and signing... 2,892ms | |
Xcode build done. 17.6s | |
[VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(35)] Using the Impeller rendering backend. | |
flutter: \^[[31m [error] Error fetching styles: Exception: type 'Null' is not a subtype of type 'String'<…> | |
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Exception: Error fetching styles: Exception: type 'Null' is not a subtype of type 'String' | |
#0 ThetaClient.initialize.<anonymous closure>.<anonymous closure> (package:theta/src/client.dart:21:13) | |
#1 Left.fold (package:either_dart/src/either.dart:169:15) | |
#2 ThetaClient.initialize.<anonymous closure> (package:theta/src/client.dart:18:13) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:io'; | |
import 'dart:typed_data'; | |
import 'package:flutter/material.dart'; | |
import 'package:http/http.dart' as http; | |
import 'package:share_plus/share_plus.dart'; | |
import 'package:path_provider/path_provider.dart'; | |
import 'package:flutter_pdfview/flutter_pdfview.dart'; | |
class PdfView extends StatefulWidget { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PdfView extends StatefulWidget { | |
const PdfView({Key? key}) : super(key: key); | |
@override | |
State<PdfView> createState() => _PdfViewState(); | |
} | |
class _PdfViewState extends State<PdfView> { | |
String? pdfPath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future storePdfBytesToFile(Uint8List bytes) async { | |
const filename = 'VueJs CheatSheet'; | |
final dir = await getApplicationDocumentsDirectory(); | |
final file = File('${dir.path}/$filename.pdf'); | |
await file.writeAsBytes(bytes); | |
setState(() { | |
pdfPath = file.path; | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<Uint8List> getPdfBytesFromUrl(String pdfUrl) async { | |
final response = await http.get(Uri.parse(pdfUrl)); | |
Uint8List bytes = response.bodyBytes; | |
return bytes; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http: ^0.13.5 | |
share_plus: ^6.3.0 | |
path_provider: ^2.0.11 | |
flutter_pdfview: ^1.2.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This function helps to add a string at the back of each file name IF that | |
// file already exists in the user's file system, so that each file name will | |
// be unique. | |
Future<String> makeFileName(String path, String fileName) async { | |
bool fileExists = await File('$path/$fileName').exists(); | |
if (fileExists) { | |
int counter = 1; | |
List newFileExt = fileName.split('.'); | |
String ext = newFileExt[1]; // refers to the file extension. |
NewerOlder