A Flutter plugin for adding stickers to WhatsApp.
trayImageFileName
uses PNG data whereas stickers use WebP data.
To use this plugin, add whatsapp_stickers
as a dependency in your pubspec.yaml file.
Add the following option to your app\build.gradle
file. This will prevent all WebP files from being compressed.
android {
aaptOptions {
noCompress "webp"
}
}
Do not forget to add following entry to Info.plist
with Runner
target.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>whatsapp</string>
</array>
Put your stickers in any folder, for example, assets
. Do not forget to add this folder to pubspec.yaml.
const stickers = {
'01_Cuppy_smile.webp': ['โ', '๐'],
'02_Cuppy_lol.webp': ['๐', '๐'],
'03_Cuppy_rofl.webp': ['๐', '๐'],
'04_Cuppy_sad.webp': ['๐', '๐'],
'05_Cuppy_cry.webp': ['๐ญ', '๐ง'],
'06_Cuppy_love.webp': ['๐', 'โฅ'],
'07_Cuppy_hate.webp': ['๐', '๐'],
'08_Cuppy_lovewithmug.webp': ['๐', '๐'],
'09_Cuppy_lovewithcookie.webp': ['๐', '๐ช'],
'10_Cuppy_hmm.webp': ['๐ค', '๐'],
'11_Cuppy_upset.webp': ['๐ฑ', '๐ต'],
'12_Cuppy_angry.webp': ['๐ก', '๐ '],
'13_Cuppy_curious.webp': ['โ', '๐ค'],
'14_Cuppy_weird.webp': ['๐', '๐'],
'15_Cuppy_bluescreen.webp': ['๐ป', '๐ฉ'],
'16_Cuppy_angry.webp': ['๐ก', '๐ค'],
'17_Cuppy_tired.webp': ['๐ฉ', '๐จ'],
'18_Cuppy_workhard.webp': ['๐', '๐จ'],
'19_Cuppy_shine.webp': ['๐', 'โจ'],
'20_Cuppy_disgusting.webp': ['๐คฎ', '๐'],
'21_Cuppy_hi.webp': ['๐', '๐'],
'22_Cuppy_bye.webp': ['๐', '๐'],
};
Future installFromAssets() async {
var stickerPack = WhatsappStickers(
identifier: 'cuppyFlutterWhatsAppStickers',
name: 'Cuppy Flutter WhatsApp Stickers',
publisher: 'John Doe',
trayImageFileName: WhatsappStickerImage.fromAsset('assets/tray_Cuppy.png'),
publisherWebsite: '',
privacyPolicyWebsite: '',
licenseAgreementWebsite: '',
);
stickers.forEach((sticker, emojis) {
stickerPack.addSticker(WhatsappStickerImage.fromAsset('assets/$sticker'), emojis);
});
try {
await stickerPack.sendToWhatsApp();
} on WhatsappStickersException catch (e) {
print(e.cause);
}
}
const stickers = {
'01_Cuppy_smile.webp': ['โ', '๐'],
'02_Cuppy_lol.webp': ['๐', '๐'],
'03_Cuppy_rofl.webp': ['๐', '๐'],
'04_Cuppy_sad.webp': ['๐', '๐'],
'05_Cuppy_cry.webp': ['๐ญ', '๐ง'],
'06_Cuppy_love.webp': ['๐', 'โฅ'],
'07_Cuppy_hate.webp': ['๐', '๐'],
'08_Cuppy_lovewithmug.webp': ['๐', '๐'],
'09_Cuppy_lovewithcookie.webp': ['๐', '๐ช'],
'10_Cuppy_hmm.webp': ['๐ค', '๐'],
'11_Cuppy_upset.webp': ['๐ฑ', '๐ต'],
'12_Cuppy_angry.webp': ['๐ก', '๐ '],
'13_Cuppy_curious.webp': ['โ', '๐ค'],
'14_Cuppy_weird.webp': ['๐', '๐'],
'15_Cuppy_bluescreen.webp': ['๐ป', '๐ฉ'],
'16_Cuppy_angry.webp': ['๐ก', '๐ค'],
'17_Cuppy_tired.webp': ['๐ฉ', '๐จ'],
'18_Cuppy_workhard.webp': ['๐', '๐จ'],
'19_Cuppy_shine.webp': ['๐', 'โจ'],
'20_Cuppy_disgusting.webp': ['๐คฎ', '๐'],
'21_Cuppy_hi.webp': ['๐', '๐'],
'22_Cuppy_bye.webp': ['๐', '๐'],
};
Future installFromRemote() async {
var applicationDocumentsDirectory = await getApplicationDocumentsDirectory();
var stickersDirectory = Directory('${applicationDocumentsDirectory.path}/stickers');
await stickersDirectory.create(recursive: true);
final dio = Dio();
final downloads = <Future>[];
stickers.forEach((sticker, emojis) {
downloads.add(
dio.download(
'https://github.com/applicazza/whatsapp_stickers/raw/master/example/assets/$sticker',
'${stickersDirectory.path}/$sticker',
),
);
});
await Future.wait(downloads);
var stickerPack = WhatsappStickers(
identifier: 'cuppyFlutterWhatsAppStickers',
name: 'Cuppy Flutter WhatsApp Stickers',
publisher: 'John Doe',
trayImageFileName: WhatsappStickerImage.fromAsset('assets/tray_Cuppy.png'),
publisherWebsite: '',
privacyPolicyWebsite: '',
licenseAgreementWebsite: '',
);
stickers.forEach((sticker, emojis) {
stickerPack.addSticker(WhatsappStickerImage.fromFile('${stickersDirectory.path}/$sticker'), emojis);
});
try {
await stickerPack.sendToWhatsApp();
} on WhatsappStickersException catch (e) {
print(e.cause);
}
}