stagexl_main_menu 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 41

StageXL Main Menu #

Main Menu is a package for StageXL which allows developers to easily add a main menu to their project

alt text

Example #

MainMenu mainMenu = MainMenu();
stage.addChild(mainMenu);

Adding items #

MenuButton file = mainMenu.addMenuItem("File");

file.addMenuItem("New").onMouseClick.listen((Event e) {
  print("New was clicked");
});

file.addMenuItem("Open");

file.addSeperator();

Adding sub items #

file.addMenuItem("Open Recent")..addMenuItem("File 1")..addMenuItem("File 2");

Adding checkbox items #

CheckboxMenuItem cb = file.addCheckboxMenuItem("cool", true);
cb.onIsCheckedChanged.listen((Event e) {
  print(cb.isChecked);
});

Adding another menu button #

mainMenu.addMenuItem("Edit")..addMenuItem("Cut")..addMenuItem("Copy");

Adding styling #

mainMenu
  ..fileMenuBackColor = 0xff303030
  ..menuButtonBackColor = 0xff303030
  ..menuButtonHighlightColor = 0xff505050
  ..menuButtonTextColor = 0xffCCCCCC
  ..menuButtonTextSize = 15
  ..menuItemBackColor = 0xff262626
  ..menuItemHighlightColor = 0xff505050
  ..menuItemTextColor = 0xffffffff
  ..menuItemTextSize = 15
  ..seperatorColor = 0xffCCCCCC;

sizing and positioning #

stage.onResize.listen(onResize);

void onResize(Event e) {
  mainMenu.x = 0;
  mainMenu.y = 0;
  mainMenu.width = stage.stageWidth;
}

1.0.1 #

  • Formatting and minor performance enhancements

1.0.0 - 06/02/2018. #

  • Initial version

example/main.dart

import 'dart:async';
import 'dart:html' as html;
import 'package:stagexl/stagexl.dart';

import 'package:stagexl_main_menu/stagexl_main_menu.dart';

MainMenu mainMenu;
Stage stage;

Future<Null> main() async {
  StageOptions options = StageOptions()
    ..backgroundColor = Color.White
    ..renderEngine = RenderEngine.WebGL;

  var canvas = html.querySelector('#stage');
  stage = Stage(canvas, width: 1280, height: 800, options: options);

  var renderLoop = RenderLoop();
  renderLoop.addStage(stage);

  MainMenu mainMenu = MainMenu();
  stage.addChild(mainMenu);

  //add a menu item
  MenuItem file = mainMenu.addMenuItem("File");
  
  file.addMenuItem("New").onMouseClick.listen((Event e) {
    print("New was clicked");
  });

  file.addMenuItem("Open");

  //add a seperator
  file.addSeperator();

  //add sub menu items
  file.addMenuItem("Open Recent")..addMenuItem("File 1")..addMenuItem("File 2");

  //add a checkbox and listen for clicks
  CheckboxMenuItem cb = file.addCheckboxMenuItem("cool", true);
  cb.onIsCheckedChanged.listen((Event e) {
    print(cb.isChecked);
  });

  //add another menu item
  mainMenu.addMenuItem("Edit")..addMenuItem("Cut")..addMenuItem("Copy");

  //set some styles
  mainMenu
    ..fileMenuBackColor = 0xff303030
    ..menuButtonBackColor = 0xff303030
    ..menuButtonHighlightColor = 0xff505050
    ..menuButtonTextColor = 0xffCCCCCC
    ..menuButtonTextSize = 15
    ..menuItemBackColor = 0xff262626
    ..menuItemHighlightColor = 0xff505050
    ..menuItemTextColor = 0xffffffff
    ..menuItemTextSize = 15
    ..seperatorColor = 0xffCCCCCC;

  stage.onResize.listen(onResize);
  onResize(null);
}

void onResize(Event e) {
  mainMenu.x = 0;
  mainMenu.y = 0;
  mainMenu.width = stage.stageWidth;
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  stagexl_main_menu: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:stagexl_main_menu/stagexl_main_menu.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
41
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.9+1

Analysis suggestions

Package not compatible with runtime flutter-native of android

Because of the import of dart:html via the import chain package:stagexl_main_menu/stagexl_main_menu.dart->package:stagexl_main_menu/src/CheckboxMenuItem.dart->package:stagexl/stagexl.dart->package:stagexl/src/text.dart->package:stagexl/src/engine.dart->dart:html

Package not compatible with runtime flutter-native of ios

Because of the import of dart:html via the import chain package:stagexl_main_menu/stagexl_main_menu.dart->package:stagexl_main_menu/src/CheckboxMenuItem.dart->package:stagexl/stagexl.dart->package:stagexl/src/text.dart->package:stagexl/src/engine.dart->dart:html

Package not compatible with runtime flutter-native of linux

Because of the import of dart:html via the import chain package:stagexl_main_menu/stagexl_main_menu.dart->package:stagexl_main_menu/src/CheckboxMenuItem.dart->package:stagexl/stagexl.dart->package:stagexl/src/text.dart->package:stagexl/src/engine.dart->dart:html

Package not compatible with runtime flutter-native of macos

Because of the import of dart:html via the import chain package:stagexl_main_menu/stagexl_main_menu.dart->package:stagexl_main_menu/src/CheckboxMenuItem.dart->package:stagexl/stagexl.dart->package:stagexl/src/text.dart->package:stagexl/src/engine.dart->dart:html

Package not compatible with runtime flutter-native of windows

Because of the import of dart:html via the import chain package:stagexl_main_menu/stagexl_main_menu.dart->package:stagexl_main_menu/src/CheckboxMenuItem.dart->package:stagexl/stagexl.dart->package:stagexl/src/text.dart->package:stagexl/src/engine.dart->dart:html

Package not compatible with runtime native-aot

Because of the import of dart:html via the import chain package:stagexl_main_menu/stagexl_main_menu.dart->package:stagexl_main_menu/src/CheckboxMenuItem.dart->package:stagexl/stagexl.dart->package:stagexl/src/text.dart->package:stagexl/src/engine.dart->dart:html

Package not compatible with runtime native-jit

Because of the import of dart:html via the import chain package:stagexl_main_menu/stagexl_main_menu.dart->package:stagexl_main_menu/src/CheckboxMenuItem.dart->package:stagexl/stagexl.dart->package:stagexl/src/text.dart->package:stagexl/src/engine.dart->dart:html

Health suggestions

Fix lib/src/CheckboxMenuItemInner.dart. (-1 points)

Analysis of lib/src/CheckboxMenuItemInner.dart reported 2 hints:

line 12 col 7: Avoid const keyword.

line 99 col 19: Unnecessary new keyword.

Fix lib/src/CanHaveChildMenuItems.dart. (-0.50 points)

Analysis of lib/src/CanHaveChildMenuItems.dart reported 1 hint:

line 22 col 26: Unnecessary new keyword.

Fix lib/src/MainMenu.dart. (-0.50 points)

Analysis of lib/src/MainMenu.dart reported 1 hint:

line 16 col 19: Unnecessary new keyword.

Maintenance suggestions

Package is getting outdated. (-40 points)

The package was last published 73 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
stagexl ^1.1.0 1.4.5
Transitive dependencies
charcode 1.1.3
collection 1.14.13
convert 2.1.1
meta 1.1.8 1.2.0
petitparser 3.0.4
typed_data 1.2.0
xml 4.2.0