### Example pubspec.yaml Dependency Source: https://pub.dev/packages/flutter_quill_test/install This is an example of how the flutter_quill_test dependency will appear in your pubspec.yaml file after running the add command. ```yaml dependencies: flutter_quill_test: ^11.1.0 ``` -------------------------------- ### Flutter Quill to PDF Example Main App Source: https://pub.dev/packages/flutter_quill_to_pdf/example This is the main entry point for the flutter_quill_to_pdf example application. It initializes the Flutter binding, loads custom fonts, and sets up the main application widget with theme and localizations. ```dart import 'dart:io'; import 'package:animated_text_kit/animated_text_kit.dart'; import 'package:example/example_editor/editor/custom_quill_editor.dart'; import 'package:example/example_editor/utils/constants.dart'; import 'package:example/fonts_loader/fonts_loader.dart'; import 'package:file_selector/file_selector.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_quill/flutter_quill.dart'; import 'package:flutter_quill/quill_delta.dart'; import 'package:flutter_quill_extensions/flutter_quill_extensions.dart'; // ignore: implementation_imports import 'package:flutter_quill_to_pdf/src/constants.dart'; import 'package:flutter_quill_to_pdf/flutter_quill_to_pdf.dart'; import 'package:http/http.dart' as http; import 'package:path/path.dart'; /// This is the default loader for the fonts created to the example /// see this class [here](https://github.com/CatHood0/flutter_quill_to_pdf/blob/master/example/lib/fonts_loader/fonts_loader.dart) final FontsLoader loader = FontsLoader(); void main() async { WidgetsFlutterBinding.ensureInitialized(); await loader.loadFonts(); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter quill to pdf Demo', debugShowCheckedModeBanner: false, theme: ThemeData( colorScheme: ColorScheme.fromSeed( seedColor: const Color.fromARGB(255, 108, 189, 255)), useMaterial3: true, fontFamily: 'Noto Sans'), localizationsDelegates: [ FlutterQuillLocalizations.delegate, ], home: const MyHomePage(), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key}); @override State createState() => _MyHomePageState(); } class _MyHomePageState extends State { bool firstEntry = false; final PDFPageFormat params = PDFPageFormat.a4; final QuillController _quillController = QuillController( document: Document(), selection: const TextSelection.collapsed(offset: 0)); final FocusNode _editorNode = FocusNode(); final ScrollController _scrollController = ScrollController(); final ValueNotifier _shouldShowToolbar = ValueNotifier(false); Delta? oldDelta; @override void dispose() { _quillController.dispose(); _editorNode.dispose(); _scrollController.dispose(); _shouldShowToolbar.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: const Color.fromARGB(255, 107, 188, 255), actions: [ IconButton( onPressed: () async { final bool isAndroid = Platform.isAndroid; // on android devices is not available getSaveLocation final Object? result = isAndroid ? await getDirectoryPath( confirmButtonText: 'Select directory') : await getSaveLocation( suggestedName: 'document_pdf', acceptedTypeGroups: [ XTypeGroup( label: 'Pdf', extensions: ['pdf'], mimeTypes: ['application/pdf'], uniformTypeIdentifiers: ['com.adobe.pdf'], ), ], ); if (result == null) { return; } final File file = isAndroid ? File(result as String) : File((result as FileSaveLocation).path); PDFConverter pdfConverter = PDFConverter( backMatterDelta: null, frontMatterDelta: null, isWeb: kIsWeb, onDetectImageUrl: kIsWeb ? _fetchBlobAsBytes : null, paintStrikethoughStyleOnCheckedElements: true, checkboxDecorator: CheckboxDecorator.base( strikethroughColor: "#AAAAAA", italicOnStrikethrough: true, ), document: _quillController.document.toDelta(), fallbacks: [...loader.allFonts()], onRequestFontFamily: (FontFamilyRequest familyRequest) { final normalFont = loader.getFontByName(fontFamily: familyRequest.family); ``` -------------------------------- ### Pubspec.yaml Dependency Example Source: https://pub.dev/packages/flutter_quill/install This is an example of how the flutter_quill dependency will appear in your pubspec.yaml file after running the add command. ```yaml dependencies: flutter_quill: ^11.5.1 ``` -------------------------------- ### Full Example of QuillEditor Testing Source: https://pub.dev/packages/flutter_quill_test A complete widget test demonstrating the usage of flutter_quill_test utilities for interacting with QuillEditor. ```dart import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_quill/flutter_quill.dart'; import 'package:flutter_quill_test/flutter_quill_test.dart'; void main() { testWidgets('Example QuillEditor test', (WidgetTester tester) async { final QuillController controller = QuillController.basic(); await tester.pumpWidget( MaterialApp( home: QuillEditor.basic( controller: controller, config: const QuillEditorConfig(), ), ), ); await tester.tap(find.byType(QuillEditor)); await tester.quillEnterText(find.byType(QuillEditor), 'Hello, World!\n'); expect(controller.document.toPlainText(), 'Hello, World!\n'); await tester.quillMoveCursorTo(find.byType(QuillEditor), 12); await tester.quillExpandSelectionTo(find.byType(QuillEditor), 13); await tester.quillReplaceText(find.byType(QuillEditor), ' and hi, World!'); expect(controller.document.toPlainText(), 'Hello, World and hi, World!\n'); await tester.quillMoveCursorTo(find.byType(QuillEditor), 0); await tester.quillExpandSelectionTo(find.byType(QuillEditor), 7); await tester.quillRemoveTextInSelection(find.byType(QuillEditor)); expect(controller.document.toPlainText(), 'World and hi, World!\n'); }); } ``` -------------------------------- ### Pubspec.yaml Configuration Source: https://pub.dev/packages/flutter_quill_to_pdf/score Example of how to include the flutter_quill_to_pdf package in your pubspec.yaml file. ```yaml flutter_quill_to_pdf: ^2.3.9 ``` -------------------------------- ### Creating a Bullet List Paragraph Source: https://pub.dev/packages/flutter_quill_delta_easy_parser Demonstrates creating a Paragraph with block-level formatting, specifically for a bullet list. This example includes underlined text within the bullet point. ```dart final Paragraph bulletListParagraph = Paragraph.auto( lines: [Line(fragments: [ TextFragment(data: "I am also a bullet point, but I have "), TextFragment(data: "underlined text", attributes: {"underline": true}), TextFragment(data: " included in my paragraph."), ]), ], blockAttributes: {"list": "bullet"}, ); debugPrint(bulletListParagraph.type.name); // output: block ``` -------------------------------- ### Basic HTML to Delta Conversion Source: https://pub.dev/packages/flutter_quill_delta_from_html Import the package and use the HtmlToDelta converter to transform HTML strings into Delta objects. This example shows a simple paragraph with bold text and line height transformation. ```dart import 'package:flutter_quill_delta_from_html/flutter_quill_delta_from_html.dart'; void main() { String htmlContent = '

Hello, world!

'; var delta = HtmlToDelta().convert(htmlContent, transformTableAsEmbed: false); /* { "insert": "hello, " }, { "insert": "world", "attributes": {"bold": true} }, { "insert": "!" }, { "insert": "\n", { 'line-height': 2.0 } } */ } ``` -------------------------------- ### Dart Analyzer Warning Example Source: https://pub.dev/packages/flutter_quill_to_pdf/score An example of a Dart analyzer warning related to type parameter naming conventions. ```dart sealed class Converter { } ``` -------------------------------- ### Import flutter_quill_delta_easy_parser in Dart code Source: https://pub.dev/packages/flutter_quill_delta_easy_parser/install Import the package into your Dart files to start using its functionalities. ```dart import 'package:flutter_quill_delta_easy_parser/flutter_quill_delta_easy_parser.dart'; ``` -------------------------------- ### Constructing a Paragraph for a List Source: https://pub.dev/packages/flutter_quill_delta_easy_parser Example of creating a Paragraph that represents an ordered list item. This structure is used when block attributes like 'list' are applied, and multiple lines share these attributes. ```dart Paragraph( lines: [ Line(fragments: [ TextFragment(data: 'This is a ordered list item') ]), Line(fragments: [ TextFragment(data: 'This is another ordered list item'), ]), Line(fragments: [ TextFragment(data: 'Just a different ordered list item'), ]), ], blockAttributes: {'list': 'ordered'}, type: ParagraphType.block, ); ``` -------------------------------- ### Fetch Blob Data as Bytes Source: https://pub.dev/packages/flutter_quill_to_pdf/example This function fetches data from a blob URL and returns it as bytes. It handles HTTP GET requests and checks for a successful response. ```dart Future _fetchBlobAsBytes(String blobUrl) async { final http.Response response = await http.get(Uri.parse(blobUrl)); if (response.statusCode == 200) return response.bodyBytes; return null; } ``` -------------------------------- ### Import flutter_quill_to_pdf in Dart Code Source: https://pub.dev/packages/flutter_quill_to_pdf/install Import the package into your Dart files to start using its functionalities. ```dart import 'package:flutter_quill_to_pdf/flutter_quill_to_pdf.dart'; ``` -------------------------------- ### Initialize Flutter Quill Editor Source: https://pub.dev/packages/flutter_quill/example Sets up the QuillController with basic configuration, including custom image pasting logic for non-web platforms. The document is loaded from a predefined JSON sample. ```dart import 'dart:convert'; import 'dart:io' as io show Directory, File; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_quill/flutter_quill.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_quill_example/quill_delta_sample.dart'; import 'package:flutter_quill_extensions/flutter_quill_extensions.dart'; import 'package:path/path.dart' as path; void main() => runApp(const MainApp()); class MainApp extends StatelessWidget { const MainApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData.light(useMaterial3: true), darkTheme: ThemeData.dark(useMaterial3: true), themeMode: ThemeMode.system, home: HomePage(), localizationsDelegates: [ GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, GlobalWidgetsLocalizations.delegate, FlutterQuillLocalizations.delegate, ], ); } } class HomePage extends StatefulWidget { const HomePage({super.key}); @override State createState() => _HomePageState(); } class _HomePageState extends State { final QuillController _controller = () { return QuillController.basic( config: QuillControllerConfig( clipboardConfig: QuillClipboardConfig( enableExternalRichPaste: true, onImagePaste: (imageBytes) async { if (kIsWeb) { // Dart IO is unsupported on the web. return null; } // Save the image somewhere and return the image URL that will be // stored in the Quill Delta JSON (the document). final newFileName = 'image-file-${DateTime.now().toIso8601String()}.png'; final newPath = path.join( io.Directory.systemTemp.path, newFileName, ); final file = await io.File( newPath, ).writeAsBytes(imageBytes, flush: true); return file.path; }, ), )); }(); final FocusNode _editorFocusNode = FocusNode(); final ScrollController _editorScrollController = ScrollController(); @override void initState() { super.initState(); // Load document _controller.document = Document.fromJson(kQuillDefaultSample); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Flutter Quill Example'), actions: [ IconButton( icon: const Icon(Icons.output), tooltip: 'Print Delta JSON to log', onPressed: () { ScaffoldMessenger.of(context).showSnackBar(const SnackBar( content: Text('The JSON Delta has been printed to the console.'))); debugPrint(jsonEncode(_controller.document.toDelta().toJson())); }, ), ], ), body: SafeArea( child: Column( children: [ QuillSimpleToolbar( controller: _controller, config: QuillSimpleToolbarConfig( embedButtons: FlutterQuillEmbeds.toolbarButtons(), showClipboardPaste: true, customButtons: [ QuillToolbarCustomButtonOptions( icon: const Icon(Icons.add_alarm_rounded), onPressed: () { _controller.document.insert( _controller.selection.extentOffset, TimeStampEmbed( DateTime.now().toString(), ), ); ``` -------------------------------- ### Instantiate QuillController Source: https://pub.dev/packages/flutter_quill Create a basic instance of QuillController to manage the document content and editor state. ```dart QuillController _controller = QuillController.basic(); ``` -------------------------------- ### Request Editor Focus on Desktop Source: https://pub.dev/packages/flutter_quill/example Sets up a callback for when a toolbar button is pressed. If the platform is desktop (Linux, Windows, macOS), it requests focus for the editor. ```dart afterButtonPressed: () { final isDesktop = { TargetPlatform.linux, TargetPlatform.windows, TargetPlatform.macOS }.contains(defaultTargetPlatform); if (isDesktop) { _editorFocusNode.requestFocus(); } }, ``` -------------------------------- ### Custom Video Builder for YouTube Source: https://pub.dev/packages/flutter_quill/example Provides a placeholder for custom video builders, specifically mentioning the ability to load YouTube videos as per a release note. Currently returns null, indicating no custom implementation. ```dart videoEmbedConfig: QuillEditorVideoEmbedConfig( customVideoBuilder: (videoUrl, readOnly) { // To load YouTube videos https://github.com/singerdmx/flutter-quill/releases/tag/v10.8.0 return null; }, ), ``` -------------------------------- ### Import flutter_quill in Dart Source: https://pub.dev/packages/flutter_quill/install Import the flutter_quill library into your Dart files to start using its rich text editing components. ```dart import 'package:flutter_quill/flutter_quill.dart'; ``` -------------------------------- ### Custom Image Provider for Assets Source: https://pub.dev/packages/flutter_quill/example Configures the image embed to use AssetImage for URLs starting with 'assets/'. This allows embedding local images within the editor. ```dart imageEmbedConfig: QuillEditorImageEmbedConfig( imageProviderBuilder: (context, imageUrl) { // https://pub.dev/packages/flutter_quill_extensions#-image-assets if (imageUrl.startsWith('assets/')) { return AssetImage(imageUrl); } return null; }, ), ``` -------------------------------- ### Instantiate DocumentParser with a custom MergerBuilder Source: https://pub.dev/packages/flutter_quill_delta_easy_parser Use this to create a DocumentParser instance with your own logic for joining paragraphs. Replace `` with your custom merger builder implementation. ```dart final parser = DocumentParser(mergerBuilder: ); ``` -------------------------------- ### Add flutter_quill from Git repository Source: https://pub.dev/packages/flutter_quill Alternatively, you can add flutter_quill directly from its Git repository. Replace '' with the desired version. ```yaml dependencies: flutter_quill: git: url: https://github.com/singerdmx/flutter-quill.git ref: v ``` -------------------------------- ### Configure Image Asset Loading Source: https://pub.dev/packages/flutter_quill_extensions Configure the editor to load image assets by providing a custom imageProviderBuilder. ```dart FlutterQuillEmbeds.editorBuilders( imageEmbedConfig: QuillEditorImageEmbedConfig( imageProviderBuilder: (context, imageUrl) { if (imageUrl.startsWith('assets/')) { return AssetImage(imageUrl); } return null; }, ), ) ``` -------------------------------- ### Enter Text into QuillEditor Source: https://pub.dev/packages/flutter_quill_test Use quillEnterText to simulate text input into the QuillEditor. ```dart await tester.quillEnterText(find.byType(QuillEditor), 'test\n'); ``` -------------------------------- ### Import Flutter Quill Test Utilities Source: https://pub.dev/packages/flutter_quill_test Import the necessary test utilities into your test file. ```dart import 'package:flutter_quill_test/flutter_quill_test.dart'; ``` -------------------------------- ### Custom Animated Loading Widget Source: https://pub.dev/packages/flutter_quill_to_pdf/example A custom StatelessWidget for displaying an animated loading indicator with customizable text, colors, and animation duration. Useful for indicating background processes. ```dart class LoadingWithAnimtedWidget extends StatelessWidget { final String text; final double verticalTextPadding; final double? heightWidget; final double? spaceBetween; final double strokeWidth; final TextStyle? style; final Duration duration; final Color? loadingColor; final bool infinite; const LoadingWithAnimtedWidget({ super.key, required this.text, this.loadingColor, this.strokeWidth = 7, this.spaceBetween, this.duration = const Duration(milliseconds: 260), this.infinite = false, this.style, this.heightWidget, this.verticalTextPadding = 30, }); @override Widget build(BuildContext context) { // Widget implementation would go here throw UnimplementedError(); } } ``` -------------------------------- ### Use QuillEditor and QuillSimpleToolbar Source: https://pub.dev/packages/flutter_quill Integrate QuillSimpleToolbar for basic editing controls and QuillEditor for displaying and editing rich text content, both managed by a QuillController. ```dart QuillSimpleToolbar( controller: _controller, config: const QuillSimpleToolbarConfig(), ), Expanded( child: QuillEditor.basic( controller: _controller, config: const QuillEditorConfig(), ), ) ``` -------------------------------- ### Creating Paragraphs from Raw Embeds and Operations Source: https://pub.dev/packages/flutter_quill_delta_easy_parser Shows how to create Paragraphs from raw embed data (like images) and from QuillJS operations. Use these for inserting non-textual content or complex embed structures. ```dart final Paragraph embedPr = Paragraph.fromRawEmbed(data: {'image': 'https://example.com/image.png'}, attributes: null, blockAttributes: null); final Paragraph embedPrWithOp = Paragraph.fromEmbed(data: Operation.insert({'image': 'https://example.com/image.png'})); ``` -------------------------------- ### Add Dependencies for Testing Source: https://pub.dev/packages/flutter_quill_test Add the flutter_test and flutter_quill_test dev dependencies to your project. ```bash flutter pub add 'dev:flutter_test:{"sdk":"flutter"}' flutter pub add dev:flutter_quill_test ``` -------------------------------- ### Create PDFConverter Instance Source: https://pub.dev/packages/flutter_quill_to_pdf Initialize the PDFConverter with your Quill document delta, page format, and various optional parameters to customize the PDF output, including document metadata, text direction, themes, and custom builders. ```dart import 'package:flutter_quill_to_pdf/flutter_quill_to_pdf.dart': final pdfConverter = PDFConverter( document: _quillController.document.toDelta(), pageFormat: pageFormat, // pass your page format here // optional params backMatterDelta: null, frontMatterDelta: null, // set a default Direction to your pdf widgets textDirection: Directionality.of(context), // if you support web platform, you will need to pass this param, // since fetching images in web works differently isWeb: kIsWeb, themeData: null, // your custom theme for the document listTypeWidget: ListTypeWidget.stable, // or ListTypeWidget.modern documentOptions: DocumentOptions( title: 'My fantastic document', author: 'Me', creator: 'Me', subject: 'Another fantastic document', keywords: 'my, key, words', producer: 'Me', version: PdfVersion.pdf_1_5, orientation: pw.PageOrientation.portrait, mode: PdfPageMode.thumbs, ), // create a custom leading for your lists listLeadingBuilder: (String type, int level, Object? args) => null, customHeadingSizes: [50, 45, 40, 35, 30], // override default heading sizes // code-block enableCodeBlockHighlighting: true, isLightCodeBlockTheme: false, // your custom theme for code-block (see code-block customization resource) customCodeHighlightTheme: {}, codeBlockBackgroundColor: null, // override default implementation codeBlockNumLinesTextStyle: null, // override default implementation codeBlockFont: null, // override default implementation inlineCodeStyle: null, // override default implementation // blockquote blockquoteTextStyle: null, // override default implementation blockquotePadding: null, // override default implementation blockquoteBoxDecoration: null, // override default implementation // custom widgets onDetectBlockquote: (Paragraph paragraph, Map? blockAttributes, [Object? args]) { return YourPdfWidget(); }, onDetectCodeBlock: null, onDetectVideoBlock: null, fallbacks: [], // here you can put all your pdf font fallbacks onRequestFontFamily: (FontFamilyRequest familyRequest) { return FontFamilyResponse( fontNormalV: , boldFontV: familyRequest.isBold ? : null, italicFontV: familyRequest.isItalic ? : null, boldItalicFontV: familyRequest.isItalic && familyRequest.isBold ? : null, fallbacks: const [], ); }, ); ``` -------------------------------- ### Creating a Basic Paragraph with Text Fragments Source: https://pub.dev/packages/flutter_quill_delta_easy_parser Demonstrates how to create a Paragraph with multiple TextFragments, including bold and italic attributes. This is useful for rich text formatting within a paragraph. ```dart final Paragraph basicParagraph = Paragraph( lines: [ Line(fragments: [ TextFragment(data: 'I am building a new package in Dart. '), TextFragment(data: 'This package will be ', attributes: {'bold': true}), TextFragment(data: 'open source', attributes: {'italic': true}), TextFragment(data: ' and it will help developers process the text entered into a QuillJS editor.'), ]), ], type: ParagraphType.inline, ); ``` -------------------------------- ### Generate PDF Document or Widget Source: https://pub.dev/packages/flutter_quill_to_pdf Create a complete PDF document that can be saved to a file, or generate a PDF widget for previewing. This involves calling methods on the configured PDFConverter instance. ```dart import 'dart:io'; import 'package:flutter_quill_to_pdf/flutter_quill_to_pdf.dart'; import 'package:pdf/pdf.dart'; // return a pdf Document final doc = await pdfConverter.createDocument(); // Generate the widgets without adding them to a pdf document final pw.Widget? pwWidget = await pdfConverter.generateWidget( maxWidth: pwWidgetWidth, maxHeight: pwWidgetHeight, ); // with this, we can use doc.save() to write the bytes into a File in a Storage Path ``` -------------------------------- ### MIT License for flutter_quill_to_pdf Source: https://pub.dev/packages/flutter_quill_to_pdf/license This is the standard MIT License text. It grants broad permissions for using, copying, modifying, merging, publishing, distributing, and selling the software, provided the original copyright and license notice are included. It also includes a disclaimer of warranty. ```text MIT License Copyright (c) 2024 CatHood0 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` -------------------------------- ### MIT License Source: https://pub.dev/packages/flutter_quill_delta_from_html/license This is the standard MIT License text. It grants broad permissions for use, modification, and distribution of the software, with the condition that the copyright notice and permission notice are included in all copies or substantial portions of the Software. The software is provided "as is" without warranty. ```plaintext MIT License Copyright (c) 2024 Cat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` -------------------------------- ### Build Loading Dialog with Animated Text Source: https://pub.dev/packages/flutter_quill_to_pdf/example This widget builds a dialog that displays a loading indicator and animated text. It uses `CircularProgressIndicator` and `AnimatedWavyText` for visual feedback during loading operations. ```dart class LoadingDialog extends StatelessWidget { final double? heightWidget; final double? strokeWidth; final Color? loadingColor; final double? spaceBetween; final String text; final bool infinite; final int totalRepeatCount; final Duration duration; final TextStyle? style; final double verticalTextPadding; const LoadingDialog({ super.key, this.heightWidget, this.strokeWidth, this.loadingColor, this.spaceBetween, required this.text, this.infinite = false, this.totalRepeatCount = 4, this.duration = const Duration(milliseconds: 260), this.style, this.verticalTextPadding = 50, }); @override Widget build(BuildContext context) { final Size size = MediaQuery.sizeOf(context); return PopScope( canPop: false, child: Dialog( surfaceTintColor: Colors.transparent, backgroundColor: Colors.transparent, child: SizedBox( height: heightWidget ?? size.height * 0.45, child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ CircularProgressIndicator( strokeWidth: strokeWidth, color: loadingColor, ), SizedBox(height: spaceBetween ?? 10), AnimatedWavyText( infinite: infinite, duration: duration, text: text, style: style ?? const TextStyle( color: Color.fromARGB(255, 255, 255, 255)), verticalPadding: verticalTextPadding, ), ], ), ), ), ), ); } } class AnimatedWavyText extends StatelessWidget { final double verticalPadding; final Key? animatedKey; final String text; final bool infinite; final int totalRepeatCount; final Duration duration; final TextStyle? style; const AnimatedWavyText({ super.key, this.animatedKey, this.verticalPadding = 50, required this.text, this.infinite = false, this.totalRepeatCount = 4, this.duration = const Duration(milliseconds: 260), this.style, }); @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.symmetric(vertical: verticalPadding), child: AnimatedTextKit( key: animatedKey, repeatForever: infinite, animatedTexts: [ WavyAnimatedText( text, speed: duration, textStyle: style ?? const TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold, ), ), ], displayFullTextOnTap: true, totalRepeatCount: totalRepeatCount < 1 ? 1 : totalRepeatCount, ), ); } } ``` -------------------------------- ### Android Manifest Configuration for FileProvider Source: https://pub.dev/packages/flutter_quill Configure your AndroidManifest.xml to include a FileProvider for handling clipboard image copying. This is an optional feature. ```xml ... ... ``` -------------------------------- ### Add flutter_quill_delta_easy_parser with Flutter Source: https://pub.dev/packages/flutter_quill_delta_easy_parser/install Use this command to add the package as a dependency in your Flutter project. ```bash $ flutter pub add flutter_quill_delta_easy_parser ``` -------------------------------- ### Creating a New Line Paragraph Source: https://pub.dev/packages/flutter_quill_delta_easy_parser Illustrates how to create a Paragraph that represents a new line. This is typically used for simple line breaks within the editor. ```dart final Paragraph newLinePr = Paragraph.newLine(blockAttributes: null); ``` -------------------------------- ### Add dependency to pubspec.yaml Source: https://pub.dev/packages/flutter_quill_delta_from_html/install This line will be added to your pubspec.yaml file after running the add command. ```yaml dependencies: flutter_quill_delta_from_html: ^1.5.3 ``` -------------------------------- ### Add flutter_quill_delta_easy_parser with Dart Source: https://pub.dev/packages/flutter_quill_delta_easy_parser/install Use this command to add the package as a dependency in your Dart project. ```bash $ dart pub add flutter_quill_delta_easy_parser ``` -------------------------------- ### Add flutter_quill_delta_from_html with Flutter Source: https://pub.dev/packages/flutter_quill_delta_from_html/install Use this command to add the package as a dependency in your Flutter project. ```bash $ flutter pub add flutter_quill_delta_from_html ``` -------------------------------- ### Flutter Analyze Warning: Experimental Internal Import Source: https://pub.dev/packages/flutter_quill_extensions/score This warning indicates that the package is using an experimental internal import which may be removed or changed in future versions. It is recommended to run `flutter analyze` on the specific file to reproduce and address the issue. ```dart import 'package:flutter_quill/internal.dart'; ``` -------------------------------- ### Add flutter_quill_delta_from_html with Dart Source: https://pub.dev/packages/flutter_quill_delta_from_html/install Use this command to add the package as a dependency in your Dart project. ```bash $ dart pub add flutter_quill_delta_from_html ``` -------------------------------- ### Flutter Quill Simple Toolbar Configuration Source: https://pub.dev/packages/flutter_quill_to_pdf/example This snippet shows the configuration for a simple toolbar in Flutter Quill, enabling various formatting options for the editor. ```dart QuillSimpleToolbar( controller: _quillController, config: QuillSimpleToolbarConfig( toolbarSize: 55, linkStyleType: LinkStyleType.original, headerStyleType: HeaderStyleType.buttons, showAlignmentButtons: true, multiRowsDisplay: true, showLineHeightButton: true, ``` -------------------------------- ### Convert Delta to HTML with Custom Render Callback Source: https://pub.dev/packages/flutter_quill_to_pdf/changelog This function demonstrates how to convert a Delta object to HTML, allowing for custom rendering of specific operations using a callback function. ```dart String convertDeltaToHtml(Delta delta, [ConverterOptions? options,String Function(DeltaInsertOp customOp, DeltaInsertOp? contextOp)? customRenderCallback]) { final QuillDeltaToHtmlConverter converterDeltaToHTML = QuillDeltaToHtmlConverter( delta.toJson(), options ?? HTMLConverterOptions.options(), ); converterDeltaToHTML.renderCustomWith = customRenderCallback; return converterDeltaToHTML.convert(); } ``` -------------------------------- ### Define a Custom HTML Block Handler Source: https://pub.dev/packages/flutter_quill_delta_from_html Create a custom class that extends `CustomHtmlPart` to handle specific HTML elements. The `matches` method determines if the element should be handled, and the `convert` method defines how to transform it into Delta operations. ```dart import 'package:flutter_quill_delta_from_html/flutter_quill_delta_from_html.dart'; import 'package:html/dom.dart' as dom; /// Custom block handler for elements. class PullquoteBlock extends CustomHtmlPart { @override bool matches(dom.Element element) { //you can put here the validation that you want // // To detect a

, you just need to do something like: // element.localName == 'p' return element.localName == 'pullquote'; } @override List convert(dom.Element element, {Map? currentAttributes}) { final Delta delta = Delta(); final Map attributes = currentAttributes != null ? Map.from(currentAttributes) : {}; // Extract custom attributes from the element // The attributes represents the data into a html tag // at this point, should have these attributes // // // These attributes can be optional, so do you need to ensure to not use "!" // to avoid any null conflict final author = element.attributes['data-author']; final style = element.attributes['data-style']; // Apply custom attributes to the Delta operations if (author != null) { delta.insert('Pullquote: "${element.text}" by $author', attributes); } else { delta.insert('Pullquote: "${element.text}"', attributes); } if (style != null && style.toLowerCase() == 'italic') { attributes['italic'] = true; } delta.insert('\n', attributes); return delta.toList(); } } ``` -------------------------------- ### Configure PDF Page Format Source: https://pub.dev/packages/flutter_quill_to_pdf Define the dimensions and margins for your PDF pages. You can set individual margins or use a shorthand for all margins. ```dart final PDFPageFormat pageFormat = PDFPageFormat( width: ..., //max width of the page height: ..., //max height of the page, marginTop: ..., marginBottom: ..., marginLeft: ..., marginRight: ..., ); // or use final PDFPageFormat pageFormat = PDFPageFormat.all( width: ..., //max width of the page height: ..., //max height of the page, margin: ..., //will set the property to the others margins ); ``` -------------------------------- ### Android file_paths.xml Configuration Source: https://pub.dev/packages/flutter_quill Create the file_paths.xml resource file in your Android project to define cache paths for the FileProvider. This is required for clipboard image functionality. ```xml ``` -------------------------------- ### Parsing a Quill Delta into a Document Source: https://pub.dev/packages/flutter_quill_delta_easy_parser Demonstrates how to use the DocumentParser to convert a complex Quill Delta object into a structured Document. This includes handling text formatting, headers, lists, and links. The output can be printed to the console for inspection. ```dart import 'package:flutter_quill_delta_easy_parser/flutter_quill_delta_easy_parser.dart'; void main() { final delta = Delta() ..insert('This is ') ..insert('bold', {'bold': true}) ..insert(' and ') ..insert('italic', {'italic': true}) ..insert(' text with ') ..insert('custom color', {'color': '#FF0000'}) ..insert(' ', {'header': 1}) ..insert('This is a list item') ..insert(' ', {'list': 'ordered'}) ..insert('Another list item') ..insert(' ', {'list': 'ordered'}) ..insert('Third list item') ..insert(' ') ..insert('This is a ') ..insert('link', {'link': 'https://example.com'}) ..insert(' to a website') ..insert(' '); final Document? document = DocumentParser() .parseDelta( delta: delta, returnNoSealedCopies: false, ignoreAllNewLines: false, ); debugPrint(document.toPrettyString()); } ``` -------------------------------- ### Add Dependency to pubspec.yaml Source: https://pub.dev/packages/flutter_quill_delta_from_html Add the flutter_quill_delta_from_html dependency to your project's pubspec.yaml file. ```yaml dependencies: flutter_quill_delta_from_html: ``` -------------------------------- ### Register and Use Custom HTML Block Source: https://pub.dev/packages/flutter_quill_delta_from_html Register your custom block handler with the `HtmlToDelta` converter using the `customBlocks` parameter. This allows the converter to process your custom HTML elements. ```dart import 'package:flutter_quill_delta_from_html/flutter_quill_delta_from_html.dart'; void main() { // Example HTML snippet final htmlText = '''

Regular paragraph before the custom block

This is a custom pullquote

Regular paragraph after the custom block

'''; // Registering the custom block final customBlocks = [PullquoteBlock()]; // Initialize HtmlToDelta with the HTML text and custom blocks final converter = HtmlToDelta(customBlocks: customBlocks); // Convert HTML to Delta operations final delta = converter.convert(htmlText); /* This should be resulting delta {"insert": "Regular paragraph before the custom block"}, {"insert": "Pullquote: \"This is a custom pullquote\" by John Doe", "attributes": {"italic": true}}, {"insert": "\n"}, {"insert": "Regular paragraph after the custom block\n"} */ } ``` -------------------------------- ### Add flutter_quill_to_pdf Dependency with Dart Source: https://pub.dev/packages/flutter_quill_to_pdf/install Use this command to add the package as a dependency in your Dart project. ```bash $ dart pub add flutter_quill_to_pdf ``` -------------------------------- ### Image Embed with Custom Style Properties Source: https://pub.dev/packages/flutter_quill_extensions Define image embed properties including width, height, and margin using a JSON object. ```json { "insert": { "image": "https://user-images.githubusercontent.com/122956/72955931-ccc07900-3d52-11ea-89b1-d468a6e2aa2b.png" }, "attributes": { "style": "width: 50px; height: 50px; margin: 10px;" } } ``` -------------------------------- ### Add flutter_quill_to_pdf Dependency with Flutter Source: https://pub.dev/packages/flutter_quill_to_pdf/install Use this command to add the package as a dependency in your Flutter project. ```bash $ flutter pub add flutter_quill_to_pdf ``` -------------------------------- ### Add flutter_quill Dependency Source: https://pub.dev/packages/flutter_quill/install Use this command to add the flutter_quill package to your project's dependencies. This command automatically updates your pubspec.yaml file. ```bash $ flutter pub add flutter_quill ``` -------------------------------- ### Add flutter_quill_extensions Dependency via Git Source: https://pub.dev/packages/flutter_quill_extensions Alternatively, add the flutter_quill_extensions dependency by specifying a Git URL, including a specific version or branch. ```yaml dependencies: flutter_quill_extensions: git: url: https://github.com/singerdmx/flutter-quill.git ref: v path: flutter_quill_extensions ``` -------------------------------- ### Add flutter_quill_test Dependency Source: https://pub.dev/packages/flutter_quill_test/install Use this command to add the flutter_quill_test package to your Flutter project's dependencies. ```bash $ flutter pub add flutter_quill_test ``` -------------------------------- ### Configure Quill Toolbar Embed Buttons Source: https://pub.dev/packages/flutter_quill_extensions Configure the QuillSimpleToolbar to include embed buttons provided by FlutterQuillEmbeds. ```dart QuillSimpleToolbar( config: QuillSimpleToolbarConfig( embedButtons: FlutterQuillEmbeds.toolbarButtons(), ), ), ``` -------------------------------- ### Parse Quill Delta to Document Source: https://pub.dev/packages/flutter_quill_delta_easy_parser Demonstrates how to parse a Quill Delta object into a structured Document format using DocumentParser. This is useful for further processing or generating other document types. ```dart import 'package:flutter_quill_delta_easy_parser/flutter_quill_delta_easy_parser.dart'; final Delta delta = Delta() ..insert('Hello, how are you? ') ..insert('The first Major Section') ..insert(' ', {'header': 1}) ..insert('We are writing some ') ..insert('bolded text',{'bold': true}) ..insert(' '); final Document? parsedDocument = DocumentParser(mergerBuilder: const CommonMergerBuilder()).parseDelta(delta: delta); /* it's equal, to build a document manually like this: final Document document = Document(paragraphs: [ Paragraph( lines: [ Line(fragments: [ TextFragment(data: "Hello, how are you? The first Major Section"), ]), ], blockAttributes: {"header": 1}, type: ParagraphType.block, ), Paragraph( lines: [ Line(fragments: [ TextFragment(data: "We are writing some "), TextFragment(data: "bolded text", attributes: {"bold": true}) ]), ], type: ParagraphType.inline, ), Paragraph.newLine(), ]); */ ```