wx_dart 0.9.12 copy "wx_dart: ^0.9.12" to clipboard
wx_dart: ^0.9.12 copied to clipboard

Flutter backend of wxDart

wxDart #

A cross-platform GUI library to build native desktop apps, web apps and mobile apps from a single source using the Dart programming language.

Table of contents #

wxDart Flutter and wxDart Native #

wxDart consists of two separate libraries which offer the same API and can be used independently.

  • 'wxDart Flutter' uses the Flutter libary as its backend and is written in pure Dart.
  • 'wxDart Native' uses the wxWidgets C++ GUI library as its backend using FFI calls.

Since version 0.9.11, both wxDart Flutter and wxDart Native support

Only wxDart Flutter supports mobile devices (iOS and Android) and the web.

Note that both wxDart Native and wxDart Flutter support the main desktop architectures (Windows, macOS and Linux). When using wxDart Flutter (this package), your applications will have an identical look and feel across all desktop platforms (and on the web). With wxDart Native, your applications will have the native look and feel.

wxDart aims to provide Dart bindings to the wxWidgets library very similar to the hugely popular wxPython for Python, with additional support for mobile devices and web apps.

If you are coming from the Flutter world, consider wxDart a new toolkit based on the Flutter core (next to Material UI, Cupertino UI, MacOS UI or Fluent UI), but with a fully native twin brother library and a single code base for all of them.

Screenshot #

A screenshot showing the demo running side-by-side in a web browser (wxDart Flutter, in light mode) and running natively on macOS Tahoe (wxDart Native, in dark mode). There are more screenshots below and you can run the entire demo in the browser by clicking here.

Web vs macOS

Installation of wxDart Flutter #

wxDart Flutter has been published as wx_dart on pub.dev, the central repository for most Dart and Flutter packages and pub.dev also hosts the documentation. Click here to go there.

To use wxDart Flutter, add wx_dart as a dependency in your pubspec.yaml file.

flutter pub add wx_dart

Import the package into your Dart file:

import 'package:wx_dart/wx_dart.dart';

Tutorial with samples #

The demo app includes a number of samples that can be used as a tutorial. You can also have a look at the samples directly in the tutorial folder on GitHub.

You can see some of these tutorials live embedded into HTML here.

Installation of wxDart Native #

wxDart Native can be downloaded from here. It consists of the wxDart Native library and the three bridge libraries (the Windows .dll, macOS .dylib and Linux .so) as the interface to the respective platforms.

Licence #

'wxDart Flutter' is free software under the wxWindows licence. The wxWindows licence allows you to use 'wxDart Flutter' to create free and commercial software with no restrictions, but not to create a closed source competitor of the library itself. See the Licence in full.

'wxDart Native' is not open source.

Classes by Category #

wxDart uses the API from the wxWidgets library with only minimal adaptions to the Dart langauge.

Below you find a table of the main classes by category with links to both the documentation of the Dart classes as well as the C++ classes which wxDart Native uses internally.

Core data classes #

Dart C++
WxClass Any C++ class
WxObject wxObject
String wxString
List wxList
dynamic wxVariant
WxApp wxApp

Window classes #

Dart C++
WxWindow wxWindow
WxPanel wxPanel
WxScrolledWindow wxScrolledWindow
WxSplitterWindow wxSplitterWindow
WxTopLevelWindow wxTopLevelWindow
WxDialog wxDialog
WxFrame wxFrame

Book controls #

Dart C++
WxNotebook wxNotebook
WxTreebook wxTreebook
WxDataViewBook Only available in wxDart

Windows for mobile interfaces #

Dart C++
WxAdaptiveFrame Only available in wxDart
WxAppBar Only available in wxDart
WxNavigationCtrl Only available in wxDart

Common dialogs #

Dart C++
WxMessageDialog wxMessageDialog
WxFileDialog wxFileDialog
WxDirDialog wxDirDialog
Dart C++
WxMenuBar wxMenuBar
WxMenu wxMenu
WxMenuItem wxMenuItem
WxToolBar wxToolBar
WxStatusBar wxStatusBar

Misc classes #

Dart C++
WxUIAnimation Only available in wxDart
WxTimer wxTimer
WxStopWatch wxStopWatch
WxStandardPaths wxStandardPaths
WxSystemSettings wxSystemSettings

Graphics classes #

wxDC overview

Dart C++
WxPoint wxPoint
WxRealPoint wxRealPoint
WxSize wxSize
WxRect wxRect
WxGraphicsContext wxGraphicsContext
WxGraphicsPath wxGraphicsPath
WxGraphicsBitmap wxGraphicsBitmap
WxReadOnlyDC wxReadOnlyDC
WxDC wxDC
WxPaintDC wxPaintDC
WxMemoryDC wxMemoryDC
WxInfoDC wxInfoDC
WxPaintEvent wxPaintEvent
WxColour wxColour
WxCursor wxCursor
WxFont wxFont
WxPen wxPen
WxBrush wxBrush
WxBitmap wxBitmap
WxBitmapBundle wxBitmapBundle
WxImage wxImage
WxRendererNative wxRendererNative

Control classes #

Dart C++
WxControl wxControl
WxStaticLine wxStaticLine
WxStaticBox wxStaticBox
WxStaticText wxStaticText
WxStaticBitmap wxStaticBitmap
WxButton wxButton
WxBitmapButton wxBitmapButton
WxToggleButton wxToggleButton
WxAnimationCtrl wxAnimationCtrl
WxCheckBox wxCheckBox
WxTextCtrl wxTextCtrl
WxChoice wxChoice
WxRadioButton wxRadioButton
WxRadioBox wxRadioBox
WxComboBox wxComboBox
WxBitmapComboBox wxBitmapComboBox
WxListBox wxListBox
WxSlider wxSlider
WxGauge wxGauge
WxSpinCtrl wxSpinCtrl
WxSpinCtrlDouble wxSpinCtrlDouble
WxHyperlinkCtrl wxHyperlinkCtrl

OpenGL and WebGL classes #

Dart C++
WxGLCanvas wxGLCanvas
WxGLContext wxGLContext

Complex control classes #

Dart C++
WxTreeCtrl wxTreeCtrl
WxHeaderCtrl wxHeaderCtrl
WxHtmlWindow wxHtmlWindow
Dart C++
WxDataViewCtrl wxDataViewCtrl
WxDataViewModel wxDataViewModel
WxDataViewModelNotifier wxDataViewModelNotifier
WxDataViewIndexListModel wxDataViewIndexListModel
WxDataViewVirtualListModel wxDataViewVirtualListModel
WxDataViewColumn wxDataViewColumn

wxDataViewCtrl Renderers

Dart C++
WxDataViewRenderer wxDataViewRenderer
WxDataViewTextRenderer wxDataViewTextRenderer
WxDataViewChoiceRenderer wxDataViewChoiceRenderer
WxDataViewBitmapRenderer wxDataViewBitmapRenderer
WxDataViewProgressRenderer wxDataViewProgressRenderer
WxDataViewToggleRenderer wxDataViewToggleRenderer
WxDataViewTileRenderer Only available in wxDart

Predefined model and controls for tabular data

Dart C++
WxDataViewListStore wxDataViewListStore
WxDataViewListCtrl wxDataViewListCtrl
WxDataViewTileListCtrl Only available in wxDart

Predefined models and controls for tree data

Dart C++
WxDataViewTreeStore wxDataViewTreeStore
WxDataViewTreeCtrl wxDataViewTreeCtrl
WxDataViewBookStore Only available in wxDart
WxDataViewChapterRenderer Only available in wxDart
WxDataViewChapterCtrl Only available in wxDart

Layout classes #

WxSizer overview

Dart C++
WxSizer wxSizer
WxSizerItem wxSizerItem
WxBoxSizer wxBoxSizer
WxStaticBoxSizer wxStaticBoxSizer
WxFlexGridSizer wxFlexGridSizer
WxWrapSizer wxWrapSizer
WxTileSizer Only available in wxDart

Event classes #

Event handling overview

Dart C++
WxEvtHandler wxEvtHandler
WxEvent wxEvent
WxEventTableEntry Internal implementation detail.
WxCommandEventTableEntry Internal implementation detail.

System events (deriving from WxEvent directly)

Dart C++
WxEvtHandler wxEvtHandler
WxPaintEvent wxPaintEvent
WxMouseEvent wxMouseEvent
WxKeyEvent wxKeyEvent
WxSizeEvent wxSizeEvent
WxShowEvent wxShowEvent
WxIdleEvent wxIdleEvent
WxTimerEvent wxTimerEvent
WxCloseEvent wxCloseEvent
WxFocusEvent wxFocusEvent
WxScrollWinEvent wxScrollWinEvent
wxActivateEvent wxActivateEvent
WxDPIChangedEvent wxDPIChangedEvent
WxSysColourChangedEvent wxSysColourChangedEvent
WxInitDialogEvent wxInitDialogEvent
WxDialogValidateEvent Only available in wxDart
WxMenuEvent wxMenuEvent

Command events (deriving from WxCommandEvent)

Dart C++
WxCommandEvent wxCommandEvent
WxWindowCreateEvent wxWindowCreateEvent
WxUpdateUIEvent wxUpdateUIEvent
WxNotifyEvent wxNotifyEvent
WxNotebookEvent wxNotebookEvent
WxTreeEvent wxTreeEvent
WxSplitterEvent wxSplitterEvent
WxDataViewEvent wxDataViewEvent
WxHtmlEvent wxHtmlEvent

Demo #

Here is a link to the demo app (written in wxDart) running in your browser.

Screenshots #

Several pages from the demo running on the iPhone emulator: iPhone

The demo running on Windows 11 in light mode Windows 11 light mode

The demo running on Windows 11 in dark mode Windows 11 dark mode

The demo running on Linux Ubuntu in light and dark mode Linux Ubuntu

For completeness: the demo running in the Android emulator Android

wxDart Native and wxDart Flutter showing a WxDataViewListCtrl on the desktop Native vs Flutter

Web app tutorials #

Here are samples from the tutorials that you can run in the window.

Screencasts from the demo #

Here are screencasts from the demo running on different platforms.

Hello world #

import 'package:wx_dart/wx_dart.dart';

// wxDart uses IDs to identify menu items, toolbar items, and sometimes controls.
const idAbout = 100;

// Every app needs a WxFrame as a main window.
class MyFrame extends WxFrame {
  MyFrame( WxFrame? parent) : super( parent, -1, "Hello World", size: WxSize(900, 700) ) 
  {
    // Create a menu bar
    final menubar = WxMenuBar();

    // Create a menu 
    final filemenu = WxMenu();
    // Create a menu item with short cuts and help text
    filemenu.appendItem( idAbout, "About\tAlt-A", help: "About Hello World" );
    filemenu.appendSeparator();
    filemenu.appendItem( wxID_EXIT, "Quit app\tCtrl-Q", help: "Run, baby, run!" );
    // Attach menu to menu bar
    menubar.append(filemenu, "File");

    // Attach menu bar to this frame
    setMenuBar(menubar);

    // Create status bar at the bottom
    createStatusBar();
    setStatusText( "Welcome to wxDart" );

    // Bind this function to idAbout ID menu item
    bindMenuEvent((_) {
      // Show a message dialog
      final dialog = WxMessageDialog( this, "Welcome to Hello World", caption: "wxDart" );
      dialog.showModal(null);
    }, idAbout );

    // Bind this function to wxID_EXIT 
    bindMenuEvent( (_) => close(false), wxID_EXIT );

    // Someone requested to close. 
    bindCloseWindowEvent( (event) { 
      // You didn't save your data? Veto!
      // event.veto( true ); 
      // return

      // otherwise, go ahead and quit
      destroy();
    } );
  }
}

// Every app needs an instance of WxApp
class MyApp extends WxApp {
  MyApp();

  @override
  bool onInit() {
    // create and show main window
    WxFrame myFrame = MyFrame( null );
    myFrame.show();

    return true;
  }
}

void main()
{
  final myApp = MyApp();
  myApp.run();
  myApp.dispose();
}

License of wxDart Flutter #

wxWindows Library Licence, Version 3.1
                ======================================

  Copyright (c) 1998-2026 Julian Smart, Robert Roebling et al

  Everyone is permitted to copy and distribute verbatim copies
  of this licence document, but changing it is not allowed.

                       WXWINDOWS LIBRARY LICENCE
     TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  This library is free software; you can redistribute it and/or modify it
  under the terms of the GNU Library General Public Licence as published by
  the Free Software Foundation; either version 2 of the Licence, or (at
  your option) any later version.

  This library is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
  General Public Licence for more details.

  You should have received a copy of the GNU Library General Public Licence
  along with this software, usually in a file named COPYING.LIB.  If not,
  write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  Boston, MA 02110-1301 USA.

  EXCEPTION NOTICE

  1. As a special exception, the copyright holders of this library give
  permission for additional uses of the text contained in this release of
  the library as licenced under the wxWindows Library Licence, applying
  either version 3.1 of the Licence, or (at your option) any later version of
  the Licence as published by the copyright holders of version
  3.1 of the Licence document.

  2. The exception is that you may use, copy, link, modify and distribute
  under your own terms, binary object code versions of works based
  on the Library.

  3. If you copy code from files distributed under the terms of the GNU
  General Public Licence or the GNU Library General Public Licence into a
  copy of this library, as this licence permits, the exception does not
  apply to the code that you add in this way.  To avoid misleading anyone as
  to the status of such modified files, you must delete this exception
  notice from such code and/or adjust the licensing conditions notice
  accordingly.

  4. If you write modifications of your own for this library, it is your
  choice whether to permit this exception to apply to your modifications.
  If you do not wish that, you must delete the exception notice from such
  code and/or adjust the licensing conditions notice accordingly.