zigzag_reader 0.0.1 copy "zigzag_reader: ^0.0.1" to clipboard
zigzag_reader: ^0.0.1 copied to clipboard

A new flutter plugin project.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:zigzag_reader/zigzag_reader.dart';
import 'package:file_picker/file_picker.dart';
import 'dart:io';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  File? file;
  String _pdfText = "";
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: const Text('Zigzag plugin'),
          ),
          body: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: () {
                  FilePicker.platform.pickFiles(
                      type: FileType.custom,
                      allowedExtensions: ["pdf"]).then((result) {
                    if (result != null &&
                        result.files.single.path != null &&
                        result.paths.isNotEmpty) {
                      File file = File(result.files.single.path!);

                      getPDFText(file.path).then((pdfText) {
                        if (pdfText != null) {
                          pdfText.replaceAll("\n", " ");
                          setState(() {
                            _pdfText = pdfText;
                          });
                        }
                      });
                    }
                  });
                },
                child: const Text('Get Text from PDF'),
              ),
              Expanded(
                child: SingleChildScrollView(
                  child: Text(_pdfText),
                ),
              ),
            ],
          )),
    );
  }

  Future<String?> getPDFText(String path) async {
    String? textMessage = "";

    try {
      textMessage = await ZigzagReader.getPDFText(path);
    } on PlatformException {
      textMessage = "Something went wrong";
    }
    return textMessage;
  }
}
0
likes
130
points
2
downloads

Publisher

unverified uploader

Weekly Downloads

A new flutter plugin project.

Homepage

Documentation

API reference

License

unknown (license)

Dependencies

flutter

More

Packages that depend on zigzag_reader

Packages that implement zigzag_reader