Skip to main content
Language:

From App Bundle

PhotoEditor SDK supports loading stickers from the app bundle. In this example, we load both a custom sticker and an existing sticker from the img.ly bundle.

Adding Sticker categories#

Stickers are added to the PhotoEditor SDK via the configuration.sticker.categories array within a StickerCategory.

Adding custom categories#

Each StickerCategory takes a name, an identifier, a thumbnailUri as well as an array of Stickers via them items property. A category can be populated both with custom as well as existing stickers that are shipped with the SDK.

Adding existing categories#

Existing StickerCategories can be added by specifying the unique identifier. You can find all available identifiers of the predefined categories here.

Adding stickers#

A Sticker is always added to the SDK via a hosting StickerCategory as shown in the previous section.

Adding custom stickers#

Each Sticker takes an identifier, a name as well as a stickerUri pointing to the actual sticker file. The sticker identifier needs to be unique since it is used during the (de)serialization process.

Adding existing stickers#

Existing stickers can be added by specifying the corresponding identifier. You can find all available identifiers of the predefined categories here.

File:
import 'package:catalog/models/code_example.dart';
import 'package:imgly_sdk/imgly_sdk.dart';
import 'package:photo_editor_sdk/photo_editor_sdk.dart';
class PhotoStickerLocalExample extends CodeExample {
void invoke() async {
// Create [StickerOptions] to customize the sticker tool.
final stickerOptions = StickerOptions(categories: [
// A custom sticker category.
StickerCategory("custom", "Custom", "assets/custom_sticker_igor.png",
items: [
// A custom sticker.
Sticker("custom_sticker_igor", "Igor",
"assets/custom_sticker_igor.png"),
// An existing sticker.
Sticker.existing("imgly_sticker_shapes_badge_01")
]),
// An existing sticker category.
StickerCategory.existing("imgly_sticker_category_emoticons")
]);
// Create a [Configuration] instance.
final configuration = Configuration(sticker: stickerOptions);
try {
// Open the photo editor and handle the export as well as any occurring errors.
final result = await PESDK.openEditor(
image: "assets/LA.jpg", configuration: configuration);
if (result != null) {
// The user exported a new photo successfully and the newly generated photo is located at `result.image`.
print(result.image);
} else {
// The user exported a new photo successfully and the newly generated photo is located at `result.image`.
return;
}
} catch (error) {
// The user exported a new photo successfully and the newly generated photo is located at `result.image`.
print(error);
}
}
}