harimayco / whatsapp_stickers

A Flutter plugin for adding stickers to WhatsApp.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

whatsapp_stickers

A Flutter plugin for adding stickers to WhatsApp.

Notes

  • trayImageFileName uses PNG data whereas stickers use WebP data.

Usage

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

Android

Add the following option to your app\build.gradle file. This will prevent all WebP files from being compressed.

android {
    aaptOptions {
        noCompress "webp"
    }
}

iOS

Do not forget to add following entry to Info.plist with Runner target.

<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>whatsapp</string>
	</array>

Examples

Local assets

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);
  }
}

Remote assets

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);
  }
}

About

A Flutter plugin for adding stickers to WhatsApp.

License:MIT License


Languages

Language:Java 51.1%Language:Swift 30.0%Language:Dart 8.0%Language:Kotlin 6.7%Language:Ruby 3.4%Language:Objective-C 0.8%