printing 5.0.0-nullsafety.1 copy "printing: ^5.0.0-nullsafety.1" to clipboard
printing: ^5.0.0-nullsafety.1 copied to clipboard

outdated

Plugin that allows Flutter apps to generate and print documents to android or ios compatible printers

example/lib/main.dart

// ignore_for_file: public_member_api_docs

import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pw;
import 'package:printing/printing.dart';

void main() => runApp(const MyApp('Printing Demo'));

class MyApp extends StatelessWidget {
  const MyApp(this.title);

  final String title;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text(title)),
        body: PdfPreview(
          build: (format) => _generatePdf(format, title),
        ),
      ),
    );
  }

  Future<Uint8List> _generatePdf(PdfPageFormat format, String title) async {
    final pdf = pw.Document();

    pdf.addPage(
      pw.Page(
        pageFormat: format,
        build: (context) {
          return pw.Center(
            child: pw.Text(title),
          );
        },
      ),
    );

    return pdf.save();
  }
}
1451
likes
0
pub points
99%
popularity

Publisher

verified publishernfet.net

Plugin that allows Flutter apps to generate and print documents to android or ios compatible printers

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, flutter_web_plugins, image, js, meta, pdf, plugin_platform_interface

More

Packages that depend on printing