flutter_pptx

Creator: coderz1093

Last updated:

Add to Cart

Description:

flutter pptx

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
copied to clipboard
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();
copied to clipboard
Saving a Presentation #
To save the presentation, call the save method.
final bytes = await pres.save();
copied to clipboard
You then can save the bytes to a file.
import 'dart:io';

final file = File('my_presentation.pptx');
await file.writeAsBytes(bytes);
copied to clipboard
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(),
);
copied to clipboard
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',
),
);
copied to clipboard
Title and Photo Slide (Alternative)
pres.addTitleAndPhotoAltSlide(
title: 'Title'.toTextValue(),
subtitle: 'Subtitle'.toTextValue(),
image: ImageReference(
path: './samples/images/sample_jpg.jpg',
name: 'Sample Jpg',
),
);
copied to clipboard
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(),
);
copied to clipboard
Bullets Slide
pres.addBulletsSlide(
bullets: [
'Bullet 1',
'Bullet 2',
'Bullet 3',
'Bullet 4',
].map((e) => e.toTextValue()).toList(),
);
copied to clipboard
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',
),
);
copied to clipboard
Section Slide
pres.addSectionSlide(
section: 'Section'.toTextValue(),
);
copied to clipboard
Title Only Slide
pres.addTitleOnlySlide(
title: 'Title'.toTextValue(),
subtitle: 'Subtitle'.toTextValue(),
);
copied to clipboard
Agenda Slide #
pres.addAgendaSlide(
title: 'Title'.toTextValue(),
subtitle: 'Subtitle'.toTextValue(),
topics: 'Topics'.toTextValue(),
);
copied to clipboard
Statement Slide #
pres.addStatementSlide(
statement: 'Statement'.toTextValue(),
);
copied to clipboard
Big Fact Slide #
pres.addBigFactSlide(
information: 'Information'.toTextValue(),
fact: 'Fact'.toTextLine(),
);
copied to clipboard
Quote Slide #
pres.addQuoteSlide(
quote: 'Quote'.toTextLine(),
attribution: 'Attribution'.toTextValue(),
);
copied to clipboard
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',
),
);
copied to clipboard
Photo Slide #
pres.addPhotoSlide(
image: ImageReference(
path: './samples/images/sample_jpg.jpg',
name: 'Sample Jpg',
),
);
copied to clipboard
Blank Slide #
pres.addBlankSlide();
copied to clipboard
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")),
));
copied to clipboard
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');
copied to clipboard
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';
copied to clipboard
To convert from a Flutter color to HEX, use the toHex method.
slide.background.color = Colors.red.toHex();
copied to clipboard
Image #
slide.background.image = ImageReference(
path: './samples/images/sample_jpg.jpg',
name: 'Sample Jpg',
);
copied to clipboard
Speaker Notes #
slide.speakerNotes = 'Notes'.toTextValue();
copied to clipboard
Show Slide Numbers #
slide.showSlideNumber = true;
copied to clipboard
Or for an entire presentation.
pres.showSlideNumbers = true;
copied to clipboard
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();
copied to clipboard
16x9 #
pres.layout = Layout.screen16x9();
copied to clipboard
16x10 #
pres.layout = Layout.screen16x10();
copied to clipboard
Wide #
pres.layout = Layout.screenWide();
copied to clipboard
Custom #
pres.layout = Layout(
type: 'custom',
width: 24384000,
height: 13716000,
);
copied to clipboard
Metadata #
Title #
pres.title = 'Title';
copied to clipboard
Subject #
pres.subject = 'Subject';
copied to clipboard
Author #
pres.author = 'Author';
copied to clipboard
Company #
pres.company = 'Company';
copied to clipboard
Revision #
pres.revision = 'Revision';
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.