๐Ÿš€ Neonize Dart

WhatsApp Automation Made Simple for Dart & Flutter

Dart Flutter License WhatsApp

A powerful Dart wrapper for Neonize - enabling seamless WhatsApp automation in your Dart and Flutter applications


โš ๏ธ DEVELOPMENT STATUS - NOT READY FOR PRODUCTION

๐Ÿšง WORK IN PROGRESS ๐Ÿšง

This project is currently under active development and is NOT ready for production use.


Getting Started โ€ข Features โ€ข Examples โ€ข Documentation โ€ข Contributing

โœจ What is Neonize Dart?

Neonize Dart is a comprehensive Dart wrapper around the powerful Neonize shared library, bringing WhatsApp automation capabilities directly to your Dart and Flutter projects.

๐ŸŽฏ Why Choose Neonize Dart?

  • ๐Ÿ”ฅ High Performance - Built on top of the battle-tested Neonize library
  • ๐Ÿ“ฑ Cross-Platform - Works seamlessly on Android, iOS, Windows, macOS, and Linux
  • ๐Ÿ›ก๏ธ Type Safe - Full Dart type safety with comprehensive error handling
  • โšก Real-time - Handle messages, media, and events in real-time
  • ๐Ÿ”ง Easy Integration - Simple API design for quick implementation
  • ๐Ÿ“š Well Documented - Comprehensive documentation and examples

๐ŸŒŸ Features

Core Messaging

  • โœ… Send and receive text messages
  • โœ… Handle media files (images, videos, documents, audio)
  • โœ… Group management and operations
  • โœ… Real-time message events
  • โœ… Message receipts and status tracking

Advanced Capabilities

  • ๐Ÿ” End-to-end encryption support
  • ๐ŸŽฏ Contact and user information retrieval
  • ๐Ÿ“ž Call event handling
  • ๐Ÿ”” Presence and typing indicators
  • ๐Ÿ“ฐ Newsletter support
  • ๐Ÿšซ Blocklist management

Developer Experience

  • ๐Ÿ”„ Event-driven architecture
  • ๐Ÿ“Š Built-in logging and debugging
  • ๐Ÿ—„๏ธ SQLite and PostgreSQL database support
  • ๐Ÿงช Comprehensive test coverage

๐Ÿš€ Getting Started

Prerequisites

  • Dart SDK 3.0 or higher
  • Flutter 3.0+ (for Flutter projects)

Installation

โš ๏ธ Since this project is still unstable, please follow these manual installation steps:

  1. Clone this repository

    git clone https://github.com/krypton-byte/neonize-dart.git
    cd neonize-dart
    
  2. Download the Neonize shared library

    • Go to Neonize Releases
    • Download the appropriate shared library for your platform:
      • Linux: .so file
      • macOS: .dylib file
      • Windows: .dll file
  3. Set environment variable

    # Set NEONIZE_PATH to point to your shared library location
    export NEONIZE_PATH=/path/to/your/neonize-library.so
       
    # For Windows (PowerShell)
    $env:NEONIZE_PATH="C:\path\to\your\neonize-library.dll"
       
    # For Windows (Command Prompt)
    set NEONIZE_PATH=C:\path\to\your\neonize-library.dll
    
  4. Install dependencies

    dart pub get
    
  5. Run the example

    # You can run the example directly from the bin folder
    dart run bin/main.dart
    

Alternative Installation (When Stable)

Once the project becomes stable, you'll be able to add it directly to your pubspec.yaml:

dependencies:
  neonize: ^1.0.0  # Replace with actual version

Quick Start

import 'package:neonize/neonize.dart';

void main() {
  // Initialize the client
  final client = NewAClient(
    name: 'my-whatsapp-bot',
    config: Config(
      tempPath: '/tmp',
      databasePath: './whatsapp.db',
    ),
  );

  // Handle incoming messages
  client.on<Message>((message) {
    print('๐Ÿ“จ Received: ${message.message}');
    
    // Auto-reply example
    if (message.message?.conversation?.toLowerCase() == 'hello') {
      client.sendMessage(
        message.info!.messageSource!.chat!,
        text: '๐Ÿ‘‹ Hello there! How can I help you?'
      );
    }
  });

  // Handle QR code for authentication
  client.qr((qrData) {
    print('๐Ÿ“ฑ Scan this QR code with WhatsApp:');
    qrTerminal(qrData, 2, size: 10);
  });

  // Handle connection events
  client.on<Connected>((event) {
    print('๐ŸŽ‰ Connected to WhatsApp!');
  });

  // Start the client
  client.connect();
}

๐Ÿ’ก Examples

๐Ÿ“ฑ Basic Client Setup

import 'package:neonize/neonize.dart';
import 'dart:io';

void main() {
  // Initialize the WhatsApp client
  final client = NewAClient(
    name: 'my-whatsapp-bot',
    config: Config(
      tempPath: '/tmp',
      databasePath: './neonize.db',
    ),
  );

  // Setup QR code authentication
  client.qr((qrData) {
    print('๐Ÿ“ฑ Scan this QR code with WhatsApp:');
    qrTerminal(qrData, 2, size: 10);
  });

  // Handle successful connection
  client.on<Connected>((event) {
    print('๐ŸŽ‰ Successfully connected to WhatsApp!');
  });

  // Start the client
  client.connect();
}

๐Ÿ’ฌ Sending Messages

// Send simple text message
client.sendMessage(
  buildJID('1234567890'), 
  text: 'Hello from Neonize Dart! ๐Ÿš€'
);

// Send image with caption
final imageFile = File('/path/to/your/image.jpg');
final imageBytes = imageFile.readAsBytesSync();

final imageMessage = client.buildImageMessage(
  imageBytes,
  'Check out this amazing image! ๐Ÿ“ธ',
  'image/jpeg',
  Uint8List(0), // thumbnail (optional)
);

client.sendMessage(
  buildJID('1234567890'),
  message: imageMessage,
);

// Send document file
final document = File('/path/to/document.pdf');
final documentBytes = document.readAsBytesSync();

final documentMessage = client.buildDocumentMessage(
  documentBytes,
  'document.pdf',
  'Here is the document you requested',
  'application/pdf',
);

client.sendMessage(
  buildJID('1234567890'),
  message: documentMessage,
);

๐ŸŽญ Message Event Handling

// Handle incoming text messages
client.on<Message>((message) {
  final messageText = message.message?.conversation;
  final senderJID = message.info?.messageSource?.sender;
  final chatJID = message.info?.messageSource?.chat;
  
  print('๐Ÿ“จ Received from $senderJID: $messageText');
  
  // Auto-reply functionality
  if (messageText?.toLowerCase() == 'hello') {
    client.sendMessage(chatJID, text: 'Hello there! ๐Ÿ‘‹');
  } else if (messageText?.toLowerCase() == 'help') {
    const helpText = '''
๐Ÿค– *Bot Commands:*
โ€ข hello - Get a greeting
โ€ข help - Show this help message
โ€ข time - Get current time
โ€ข joke - Get a random joke
''';
    client.sendMessage(chatJID, text: helpText);
  }
});

// Handle message receipts (delivery status)
client.on<Receipt>((receipt) {
  print('๐Ÿ“ง Message ${receipt.type}: ${receipt.messageIds}');
});

// Handle typing indicators
client.on<ChatPresence>((chatPresence) {
  final chat = chatPresence.messageSource?.chat;
  final participant = chatPresence.messageSource?.sender;
  print('๐Ÿ’ฌ $participant is typing in $chat');
});

๐Ÿ‘ฅ Group Management

// Create a new group
final participants = [
  buildJID('1234567890'),
  buildJID('0987654321'),
];

final groupInfo = client.createGroup(
  'My Awesome Group ๐Ÿš€',
  participants,
);
print('๐ŸŽ‰ Group created: ${groupInfo.jid}');

// Get group information
final groupInfo = client.getGroupInfo(...);
print('๐Ÿ“‹ Group Name: ${groupInfo.groupName}');
print('๐Ÿ“ Description: ${groupInfo.groupDesc}');
print('๐Ÿ‘ฅ Participants: ${groupInfo.participants?.length ?? 0}');

// Add participants to group
client.updateGroupParticipants(
  jidGroup,
  [userJid],
  ParticipantAction.add,
);

// Remove participants from group
client.updateGroupParticipants(
  jidGroup,
  [userJid],
  ParticipantAction.remove,
);

// Update group name
client.updateGroupName(
  jidGroup,
  'New Group Name ๐ŸŽฏ',
);

// Update group description
client.updateGroupDescription(
  jidGroup,
  'This is our updated group description',
);

๐Ÿ” Contact & Profile Management

// Get user profile information
final profile = client.getProfilePicture(
  jidUser,
  true, // get full resolution
);
print('๐Ÿ‘ค Profile picture URL: ${profile.url}');
print('๐Ÿ†” Profile ID: ${profile.id}');

// Update your own status
client.setPresence(Presence.available);
print('โœ… Status updated to available');

// Get contact information
final isRegistered = client.isOnWhatsApp(['1234567890']);
if (isRegistered.isNotEmpty && isRegistered.first.isIn) {
  print('โœ… User is registered on WhatsApp');
  print('๐Ÿ“ฑ JID: ${isRegistered.first.jid}');
} else {
  print('โŒ User is not on WhatsApp');
}

// Check if multiple contacts are on WhatsApp
final contacts = ['1234567890', '0987654321', '1122334455'];
final registeredContacts = client.isOnWhatsApp(contacts);
for (final contact in registeredContacts) {
  if (contact.isIn) {
    print('โœ… ${contact.jid} is on WhatsApp');
  } else {
    print('โŒ ${contact.query} is not on WhatsApp');
  }
}

๐Ÿ—๏ธ Project Structure

neonize-dart/
โ”œโ”€โ”€ bin
โ”‚   โ”œโ”€โ”€ main.dart
โ”‚   โ””โ”€โ”€ qr_test.dart
โ”œโ”€โ”€ CHANGELOG.md
โ”œโ”€โ”€ lib
โ”‚   โ”œโ”€โ”€ neonize.dart
โ”‚   โ””โ”€โ”€ src
โ”‚       โ”œโ”€โ”€ client.dart
โ”‚       โ”œโ”€โ”€ config.dart
โ”‚       โ”œโ”€โ”€ enum.dart
โ”‚       โ”œโ”€โ”€ error.dart
โ”‚       โ”œโ”€โ”€ event
โ”‚       โ”‚   โ”œโ”€โ”€ event.dart
โ”‚       โ”‚   โ””โ”€โ”€ type.dart
โ”‚       โ”œโ”€โ”€ ffi
โ”‚       โ”‚   โ”œโ”€โ”€ bindings.dart
โ”‚       โ”‚   โ”œโ”€โ”€ structs.dart
โ”‚       โ”‚   โ””โ”€โ”€ utils.dart
โ”‚       โ”œโ”€โ”€ helpers
โ”‚       โ”‚   โ”œโ”€โ”€ helpers.dart
โ”‚       โ”‚   โ””โ”€โ”€ image.dart
โ”‚       โ”œโ”€โ”€ logging.dart
โ”‚       โ””โ”€โ”€ qr.dart
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ neonize.db
โ”œโ”€โ”€ neonize-linux-amd64.so
โ”œโ”€โ”€ pubspec.lock
โ”œโ”€โ”€ pubspec.yaml
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ scripts
โ”œโ”€โ”€ test
โ”‚   โ””โ”€โ”€ neonize_test.dart

๐Ÿ“– Documentation

Core Classes

Event System

The event system in Neonize Dart is built around strongly-typed events:

// Type-safe event handling
client.on<Message>((msg) => handleMessage(msg));
client.on<Receipt>((receipt) => handleReceipt(receipt));
client.on<Presence>((presence) => handlePresence(presence));

Database Support

Neonize Dart supports multiple database backends:

// SQLite (default)
Config(databasePath: './app.db')

// PostgreSQL
Config(databasePath: 'postgres://user:pass@localhost/dbname')

๐Ÿค Contributing

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Development Setup

# Clone the repository
git clone https://github.com/krypton-byte/neonize-dart.git
cd neonize-dart

# Get dependencies
dart pub get

# Run tests
dart test

# Run the example
dart run bin/main.dart

๐Ÿ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Neonize - The powerful Python library this project wraps
  • Whatsmeow - The Go library that powers Neonize
  • Dart & Flutter Community - For the amazing ecosystem

๐Ÿ“ž Support


Made with โค๏ธ for the Dart & Flutter community

If this project helped you, please consider giving it a โญ on GitHub!

Libraries

neonize
๐Ÿš€ Neonize Dart - WhatsApp Multi-Device API