Dart package to support Wake-on-LAN functionality

Overview

wake_on_lan

Pubdev License

Dart library package to easily send Wake-on-LAN magic packets to devices on your local network.

Getting Started

wake_on_lan has three core classes for functionality, IPv4Address, MACAddress, and WakeOnLAN. All classes are exported in the main file, to import:

import 'package:wake_on_lan/wake_on_lan.dart';

Create an IPv4 Address

IPv4Address is a helper class to ensure that your IPv4 address has been formatted correctly.

The class has a static function, validate(String address) which allows easy validation that an IPv4 address string is correctly formatted.

Create an IPv4Address instance by using the factory IPv4Address.from(address) where address is a string representation of the broadcast address of the network (easily find your broadcast address using this tool). The factory will call the validation function mentioned above, but will throw a FormatException on a poorly constructed string, so it is recommended to validate it first.

String address = '192.168.1.1';
if(IPv4Address.validate(address)) {
    IPv4Address ipv4 = IPv4Address.from(address);
    //Continue execution
} else {
    // Handle invalid address case
}

Create MAC Address

MACAddress is a helper class to ensure that your MAC address has been formatted correctly.

The class has a static function, validate(String address) which allows easy validation that a MAC address string is correctly formatted.

The MAC address must be delimited by colons (:) between each hexidecimal octet.

Create a MACAddress instance by using the factory MACAddress.from(address) where address is a string representation of the address. The factory will call the validation function mentioned above, but will throw a FormatException on a poorly constructed string, so it is recommended to validate it first.

String address = 'AA:BB:CC:DD:EE:FF';
if(MACAddress.validate(address)) {
    MACAddress mac = MACAddress.from(address);
    //Continue execution
} else {
    // Handle invalid address case
}

Sending Wake-on-LAN Packet

WakeOnLAN is the class to handle sending the actual wake-on-LAN magic packet to your network.

Create a WakeOnLAN instance by using the factory WakeOnLAN.from(ipv4, mac, { port }) where ipv4 is an IPv4Address instance, mac is a MACAddress instance, and port is an optional integer parameter for which port the packet should be sent over (defaulted to the specification standard port, 9).

Once created, call the function wake() on the WakeOnLAN object to send the packet.

String mac = 'AA:BB:CC:DD:EE:FF';
String ipv4 = '192.168.1.255';
if(MACAddress.validate(mac) && IPv4Address.validate(ipv4)) {
    MACAddress macAddress = MACAddress.from(mac);
    IPv4Address ipv4Address = IPv4Address.from(ipv4);
    WakeOnLAN wol = WakeOnLAN.from(ipv4Address, macAddress, port: 1234);
    await wol.wake().then(() => print('sent'));
}

Web Support

Wake on LAN functionality utilizes User Datagram Protocol (UDP) which is not available in the browser because of security constraints.

Notes

Because wake-on-LAN packets are sent over UDP, beyond the successful creation of a datagram socket and sending the data over the network, there is no way to confirm that the machine has been awoken beyond pinging the machine after waking it (This functionality is not implemented in this package). This is because of the nature of UDP sockets which do not need to establish the connection for the data to be sent.

You might also like...

Fwitter is an example application that demonstrates the features and functionality of Fauna.

Fwitter is an example application that demonstrates the features and functionality of Fauna.

A full introduction to this project can be found in the docs. This project is an example of how to build a 'real-world' app with highly dynamic data i

Dec 13, 2022

Searchhelperexample - SearchHelper - code wrapper for searching functionality

Searchhelperexample - SearchHelper - code wrapper for searching functionality

Overview SearchHelper is code wrapper for searching functionality developed by D

Dec 19, 2022

Peek & Pop implementation for Flutter based on the iOS functionality of the same name.

peek_and_pop Peek & Pop implementation for Flutter based on the iOS functionality of the same name. Finally, the v1.0.0 release! More fluent, more opt

Dec 17, 2022

Flutter After Layout - Brings functionality to execute code after the first layout of a widget has been performed

Flutter After Layout - Brings functionality to execute code after the first layout of a widget has been performed, i.e. after the first frame has been displayed. Maintainer: @slightfoot

Jan 3, 2023

A Todo app with full fledge functionality and Awesome Look and feel.

to_do A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this is

Aug 5, 2022

(Flutter)Minimal App With Offline Storage(Using HIVE) Functionality.

(Flutter)Minimal App With Offline Storage(Using HIVE) Functionality.

TaskZ (Minimal + Offline TODO List App) Minimal App With Offline Storage(Using HIVE) Functionality. Getting Started 👍 Any suggestion, improvement on

Oct 2, 2022

Dead simple WiFi connect functionality for flutter.

Flutter WiFi Connect Easily connect to a specified WiFi AP programmatically, using this plugin. import 'package:wifi_connect/wifi_connect.dart'; WifiC

Dec 7, 2022

A Stable GeoFence Library - A flutter project to provide Geo Fence functionality in Android and IOS

A Stable GeoFence Library - A flutter project to provide Geo Fence functionality in Android and IOS

A flutter project to provide Geo Fence functionality in Android and IOS Getting Started Android In your AndroidManifest.xml

Nov 15, 2022

A collections of packages providing additional functionality for working with bloc

Bloc Extensions A collections of packages providing additional functionality for working with bloc. Index Packages Bloc Hooks Action Blocs Contributin

Apr 19, 2022
Comments
  • My PC doesn't wake on the `wol.wake()`.

    My PC doesn't wake on the `wol.wake()`.

    This is the code I use. I have tried with Broadcast IP and also with my IP and mac address.

    import 'package:flutter/material.dart';
    import 'package:wake_on_lan/wake_on_lan.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: const MyHomePage(title: 'Flutter Demo Home Page'),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      const MyHomePage({Key? key, required this.title}) : super(key: key);
    
      final String title;
    
      @override
      State<MyHomePage> createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      TextEditingController? ipController, macController;
    
      @override
      void initState() {
        ipController = TextEditingController();
        macController = TextEditingController();
        super.initState();
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                SizedBox(
                  height: 50,
                  width: 150,
                  child: TextField(
                    textAlign: TextAlign.center,
                    controller: ipController,
                  ),
                ),
                SizedBox(
                  height: 50,
                  width: 150,
                  child: TextField(
                    textAlign: TextAlign.center,
                    controller: macController,
                  ),
                ),
              ],
            ),
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: () async {
              String mac = macController!.text;
              String ipv4 = ipController!.text;
              if (MACAddress.validate(mac) && IPv4Address.validate(ipv4)) {
                MACAddress macAddress = MACAddress.from(mac);
                IPv4Address ipv4Address = IPv4Address.from(ipv4);
                WakeOnLAN wol = WakeOnLAN.from(ipv4Address, macAddress, port: 1234);
                await wol.wake().then((_) => print('Wake on LAN sent'));
              }
            },
            tooltip: 'START',
            child: const Text('Start'),
          ),
        );
      }
    }
    

    But doesn't wake the PC.

    opened by yahu1031 3
Owner
Jagandeep Brar
Jagandeep Brar
Speed Share is a highly available file sharing terminal on LAN(local area network) developed by flutter framework.

速享 Language: 中文简体 | English 这是一款完全基于局域网的文件互传终端,速享不使用任何服务器,不使用您的移动流量,不收集任何用户数据,完全的点对点传输。 可以快速共享文本消息,图片或其他文件,文件夹。 适用于局域网中的文件互传,解决 QQ,微信等上传文件会经过服务器的问题,或者

null 477 Dec 31, 2022
A flutter plugin to support drag-out functionality on native platforms

flutter_native_drag_n_drop A flutter plugin to support the native drag and drop, especially to drag files (only files) out of the application boundary

Skalio GmbH 5 Oct 28, 2022
A TextField flutter package with tagging functionality.

Flutter Tagging A flutter package with tagging or multi-select functionality. Useful for adding Tag or Label Selection Forms. List<Language> _selected

Sarbagya Dhaubanjar 149 Sep 6, 2022
Contactus - a flutter package. The most common functionality added in any commercial app is the Developer's contact details

Contact Us The most common functionality added in any commercial app is the Developer's contact details!! So this package helps the developers to simp

Abhishek Doshi 19 Aug 4, 2022
⚒️ A monorepo containing a collection of packages that provide useful functionality for building CLI applications in Dart.

⚒️ Dart CLI Utilities A monorepo containing a collection of packages that provide useful functionality for building CLI applications in Dart. Document

Invertase 14 Oct 17, 2022
Flutter plugin, support android/ios.Support crop, flip, rotate, color martix, mix image, add text. merge multi images.

image_editor The version of readme pub and github may be inconsistent, please refer to github. Use native(objc,kotlin) code to handle image data, it i

FlutterCandies 317 Jan 3, 2023
This is an auction application just like eBay. Using firebase as the backend for signup & sign-in functionality. In addition to that, it's a two pages application with user bid in input and count down view.

Nilam This is an auction application just like eBay. Using firebase as the backend for signup & sign-in functionality. In addition to that, it's a two

Md. Siam 5 Nov 9, 2022
Flutter Control is complex library to maintain App and State management. Library merges multiple functionality under one hood. This approach helps to tidily bound separated logic into complex solution.

Flutter Control is complex library to maintain App and State management. Library merges multiple functionality under one hood. This approach helps to

Roman Hornak 23 Feb 23, 2022
Allows send emails from flutter using native platform functionality.

flutter_email_sender Allows send emails from flutter using native platform functionality. In android it opens default mail app via intent. In iOS MFMa

Tautvydas Šidlauskas 107 Jan 3, 2023
Live News App Using Rest API with Searching Functionality

News App Flutter A Simple News App built with Flutter. In this app, there is a Home page, which will display top news from newsapi.org. News categorie

Jay Gajjar 146 Dec 30, 2022