flutter_pptx 0.1.3 copy "flutter_pptx: ^0.1.3" to clipboard
flutter_pptx: ^0.1.3 copied to clipboard

A package for creating pptx files from markdown, widgets or slide templates.

flutter_pptx #

This is a Flutter plugin that can create powerpoint presentations with dart classes or markdown.

Looking for a pure dart library? Check out dart_pptx.

Getting Started #

To use this plugin, add flutter_pptx as a dependency in your pubspec.yaml file.

flutter pub add flutter_pptx

Usage #

All the existing methods available in the dart_pptx library are available in this plugin.

Creating a Presentation #

First, create a new presentation.

import 'package:dart_pptx/dart_pptx.dart';

final pres = Powerpoint();

Saving a Presentation #

To save the presentation, call the save method.

final bytes = await pres.save();

You then can save the bytes to a file.

import 'dart:io';

final file = File('my_presentation.pptx');
await file.writeAsBytes(bytes);

Adding Slides #

All arguments are optional and if not provided will have the "Double Click to Edit" placeholder text.

Title Slide

pres.addTitleSlide(
    title: 'Title'.toTextValue(),
    author: 'Author'.toTextValue(),
);

Title and Photo Slide

pres.addTitleAndPhotoSlide(
    title: 'Title'.toTextValue(),
    subtitle: 'Subtitle'.toTextValue(),
    author: 'Author'.toTextValue(),
    image: ImageReference(
        path: './samples/images/sample_gif.gif',
        name: 'Sample Gif',
    ),
);

Title and Photo Slide (Alternative)

pres.addTitleAndPhotoAltSlide(
    title: 'Title'.toTextValue(),
    subtitle: 'Subtitle'.toTextValue(),
    image: ImageReference(
        path: './samples/images/sample_jpg.jpg',
        name: 'Sample Jpg',
    ),
);

Title and Bullets Slide

pres.addTitleAndBulletsSlide(
    title: 'Title'.toTextValue(),
    subtitle: 'Subtitle'.toTextValue(),
    bullets: [
        'Bullet 1',
        'Bullet 2',
        'Bullet 3',
        'Bullet 4',
    ].map((e) => e.toTextValue()).toList(),
);

Bullets Slide

pres.addBulletsSlide(
    bullets: [
        'Bullet 1',
        'Bullet 2',
        'Bullet 3',
        'Bullet 4',
    ].map((e) => e.toTextValue()).toList(),
);

Title, Bullets, and Photo Slide

pres.addTitleBulletsAndPhotoSlide(
    title: 'Title'.toTextValue(),
    subtitle: 'Subtitle'.toTextValue(),
    bullets: [
        'Bullet 1',
        'Bullet 2',
        'Bullet 3',
        'Bullet 4',
    ].map((e) => e.toTextValue()).toList(),
    image: ImageReference(
        path: './samples/images/sample_jpg.jpg',
        name: 'Sample Jpg',
    ),
);

Section Slide

pres.addSectionSlide(
    section: 'Section'.toTextValue(),
);

Title Only Slide

pres.addTitleOnlySlide(
    title: 'Title'.toTextValue(),
    subtitle: 'Subtitle'.toTextValue(),
);

Agenda Slide #

pres.addAgendaSlide(
    title: 'Title'.toTextValue(),
    subtitle: 'Subtitle'.toTextValue(),
    topics: 'Topics'.toTextValue(),
);

Statement Slide #

pres.addStatementSlide(
    statement: 'Statement'.toTextValue(),
);

Big Fact Slide #

pres.addBigFactSlide(
    information: 'Information'.toTextValue(),
    fact: 'Fact'.toTextLine(),
);

Quote Slide #

pres.addQuoteSlide(
    quote: 'Quote'.toTextLine(),
    attribution: 'Attribution'.toTextValue(),
);

Photo 3 Up Slide #

pres.addPhoto3UpSlide(
    image1: ImageReference(
        path: './samples/images/sample_jpg.jpg',
        name: 'Sample Jpg',
    ),
    image2: ImageReference(
        path: './samples/images/sample_jpg.jpg',
        name: 'Sample Jpg',
    ),
    image3: ImageReference(
        path: './samples/images/sample_jpg.jpg',
        name: 'Sample Jpg',
    ),
);

Photo Slide #

pres.addPhotoSlide(
    image: ImageReference(
        path: './samples/images/sample_jpg.jpg',
        name: 'Sample Jpg',
    ),
);

Blank Slide #

pres.addBlankSlide();

Widget Slide #

await pres.addWidgetSlide((size) => Center(
child: Container(
    padding: const EdgeInsets.all(30.0),
    decoration: BoxDecoration(
        border: Border.all(color: Colors.blueAccent, width: 5.0),
        color: Colors.redAccent,
    ),
    child: const Text("This is a widget")),
));

This is asynchronous because the widget needs to be rendered to an image thanks to the screenshot package.

Markdown #

It is also possible to create a presentation using markdown.

await pres.addSlidesFromMarkdown('MARKDOWN SOURCE');

The markdown follows the same format for md2googleslides.

Slide Background #

Solid Color #

Colors need to be in HEX format and not include the leading #.

slide.background.color = 'FF0000';

To convert from a Flutter color to HEX, use the toHex method.

slide.background.color = Colors.red.toHex();

Image #

slide.background.image = ImageReference(
    path: './samples/images/sample_jpg.jpg',
    name: 'Sample Jpg',
);

Speaker Notes #

slide.speakerNotes = 'Notes'.toTextValue();

Show Slide Numbers #

slide.showSlideNumber = true;

Or for an entire presentation.

pres.showSlideNumbers = true;

Images #

Images use the ImageReference class. The path can be the base64 encoded string, remote url, asset image or local file path.

The name is used for the alt and can be overridden with a description.

When the presentation is saved all images will be downloaded and saved in the presentation.

Running on Flutter Web will cause a CORS error when using remote urls if the server does not have the correct headers. To get around this, you can use a proxy server.

Layouts #

4x3 #

pres.layout = Layout.screen4x3();

16x9 #

pres.layout = Layout.screen16x9();

16x10 #

pres.layout = Layout.screen16x10();

Wide #

pres.layout = Layout.screenWide();

Custom #

pres.layout = Layout(
    type: 'custom',
    width: 24384000,
    height: 13716000,
);

Metadata #

Title #

pres.title = 'Title';

Subject #

pres.subject = 'Subject';

Author #

pres.author = 'Author';

Company #

pres.company = 'Company';

Revision #

pres.revision = 'Revision';
20
likes
120
pub points
76%
popularity

Publisher

verified publisherrodydavis.com

A package for creating pptx files from markdown, widgets or slide templates.

Repository (GitHub)
View/report issues

Documentation

API reference

Funding

Consider supporting this project:

www.buymeacoffee.com
www.paypal.com

License

Apache-2.0 (LICENSE)

Dependencies

dart_pptx, flutter, screenshot

More

Packages that depend on flutter_pptx