editors 0.0.11

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

editors #

Simple Flutter Editors including StringEditor, IntEditor, EnumEditor, BoolEditor

[0.0.5] - 3/22/2020. #

  • titles refactoring + implement EditorsBuilder

[0.0.4] - 3/21/2020. #

  • update EnumEditor, prepared for combos 1.1.7

[0.0.3+2] - 3/19/2020. #

  • use combos 1.1.5

[0.0.3+1] - 3/17/2020. #

  • use combos 1.1.3

[0.0.3] - 3/17/2020. #

  • use combos 1.1.0

[0.0.2+4] - 3/15/2020. #

  • minor fix in EnumEditor

[0.0.2+3] - 3/15/2020. #

  • minor fix in EnumEditor

[0.0.2+2] - 3/15/2020. #

  • minor update in EnumEditor lable

[0.0.2+1] - 3/15/2020. #

  • move demo_items to separate repo, minor update in EnumEditor lable, minor update excmple

[0.0.2] - 3/15/2020. #

  • Implement editors for string, int, bool, enum values

[0.0.1] - 3/10/2020. #

  • Starting development

example/lib/main.dart

import 'package:combos/combos.dart';
import 'package:combos_example/main.dart';
import 'package:editors/editors.dart';
import 'package:flutter/material.dart';
import 'package:demo_items/demo_items.dart';
import 'package:titles/titles.dart';

void main() => runApp(const App());

class App extends StatelessWidget {
  const App();

  @override
  Widget build(BuildContext context) => MaterialApp(
        theme: ThemeData(
            inputDecorationTheme:
                const InputDecorationTheme(border: OutlineInputBorder())),
        title: 'Editors Sample App',
        home: const TitlesContext(
            parameters: TitleParameters(style: TextStyle(color: Colors.grey)),
            child: HomePage()),
      );
}

class HomePage extends StatefulWidget {
  const HomePage({Key key}) : super(key: key);
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final stringEditor = StringEditor(title: 'String Editor');
  final intEditor = IntEditor(title: 'Int Editor');
  final boolEditor = BoolEditor(title: 'Bool Editor', value: false);
  final enumEditor = EnumEditor<MainAxisAlignment>(
      title: 'Enum Editor', getList: () => [null, ...MainAxisAlignment.values]);
  final colorEditor = ColorEditor(title: 'Color Editor');

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(title: const Text('Editors Sample App')),
        body: ListView(padding: const EdgeInsets.all(16), children: [
          Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              DemoItem<StringProperties>(
                properties: StringProperties(),
                childBuilder: (properties, modifiedEditor) => EditorsContext(
                  onValueChanged: (editor, value) {
                    properties.value.value = value;
                    return true;
                  },
                  child: () {
                    stringEditor.value = properties.value.value;
                    return stringEditor.build();
                  }(),
                ),
              ),
              const SizedBox(height: 16),
              DemoItem<IntProperties>(
                properties: IntProperties(),
                childBuilder: (properties, modifiedEditor) => EditorsContext(
                  onValueChanged: (editor, value) {
                    properties.value.value = value;
                    return true;
                  },
                  child: () {
                    intEditor.value = properties.value.value;
                    intEditor.minValue = properties.minValue.value;
                    intEditor.maxValue = properties.maxValue.value;
                    intEditor.withIncrementer =
                        properties.withIncrementer.value;
                    return intEditor.build();
                  }(),
                ),
              ),
              const SizedBox(height: 16),
              DemoItem<BoolProperties>(
                properties: BoolProperties(),
                childBuilder: (properties, modifiedEditor) => EditorsContext(
                  onValueChanged: (editor, value) {
                    properties.value.value = value;
                    return true;
                  },
                  child: () {
                    boolEditor.value = properties.value.value;
                    return boolEditor.build();
                  }(),
                ),
              ),
              const SizedBox(height: 16),
              DemoItem<EnumProperties>(
                properties: EnumProperties(),
                childBuilder: (properties, modifiedEditor) {
                  final editorsContext = EditorsContext(
                    onValueChanged: (editor, value) {
                      properties.value.value = value;
                      return true;
                    },
                    child: () {
                      enumEditor.value = properties.value.value;
                      return enumEditor.build();
                    }(),
                  );
                  //return editorsContext;
                  return ComboContext(
                    parameters: ComboParameters(
                      popupContraints: properties.popupWidth.value == null
                          ? null
                          : BoxConstraints(
                              maxWidth: properties.popupWidth.value.toDouble(),
                            ),
                    ),
                    child:
                        properties.comboProperties.apply(child: editorsContext),
                  );
                },
              ),
              const SizedBox(height: 16),
              DemoItem<ColorProperties>(
                properties: ColorProperties(),
                childBuilder: (properties, modifiedEditor) {
                  final editorsContext = EditorsContext(
                    onValueChanged: (editor, value) {
                      properties.value.value = value;
                      return true;
                    },
                    child: () {
                      colorEditor.value = properties.value.value;
                      return colorEditor.build();
                    }(),
                  );
                  return ComboContext(
                    parameters: ComboParameters(
                      popupContraints: properties.popupWidth.value == null
                          ? null
                          : BoxConstraints(
                              maxWidth: properties.popupWidth.value.toDouble(),
                            ),
                    ),
                    child:
                        properties.comboProperties.apply(child: editorsContext),
                  );
                },
              ),
            ],
          ),
        ]),
      );
}

class DemoItem<TProperties extends ElementProperties>
    extends DemoItemBase<TProperties> {
  const DemoItem({
    Key key,
    @required TProperties properties,
    @required ChildBuilder<TProperties> childBuilder,
  }) : super(key: key, properties: properties, childBuilder: childBuilder);
  @override
  DemoItemState<TProperties> createState() => DemoItemState<TProperties>();
}

class DemoItemState<TProperties extends ElementProperties>
    extends DemoItemStateBase<TProperties> {
  @override
  Widget buildChild() {
    final properties = widget.properties;
    return EditorsContext(
        parameters: EditorParameters(
          enabled: properties.enabled.value,
          constraints:
              BoxConstraints(maxWidth: properties.maxWidth.value.toDouble()),
        ),
        child: TitlesContext(
            parameters:
                TitleParameters(placement: properties.titlePlacement.value),
            child: super.buildChild()));
  }

  @override
  Widget buildProperties() {
    final editors = widget.properties.editors;
    return ListView.separated(
      padding: const EdgeInsets.all(16),
      shrinkWrap: true,
      physics: ClampingScrollPhysics(),
      itemCount: editors.length,
      separatorBuilder: (context, index) => const SizedBox(height: 16),
      itemBuilder: (context, index) => editors[index].build(),
    );
  }
}

class ElementProperties {
  final enabled = BoolEditor(title: 'Enabled', value: true);
  final titlePlacement = EnumEditor<TitlePlacement>(
      title: 'Title Placement',
      getList: () => [null, ...TitlePlacement.values]);
  final maxWidth = IntEditor(title: 'MaxWidth', value: 200);

  List<EditorsBuilder> get editors => [enabled, titlePlacement, maxWidth];
}

class StringProperties extends ElementProperties {
  final value = StringEditor(title: 'Value');

  @override
  List<EditorsBuilder> get editors => [value, ...super.editors];
}

class IntProperties extends ElementProperties {
  final value = IntEditor(title: 'Value');
  final minValue = IntEditor(title: 'Min Value', value: 0);
  final maxValue = IntEditor(title: 'Max Value');
  final withIncrementer = BoolEditor(title: 'With Incrementer', value: true);

  @override
  List<EditorsBuilder> get editors =>
      [minValue, maxValue, withIncrementer, value, ...super.editors];
}

class BoolProperties extends ElementProperties {
  final value = BoolEditor(value: false, title: 'Value');

  @override
  List<EditorsBuilder> get editors => [value, ...super.editors];
}

class EnumProperties extends ElementProperties {
  factory EnumProperties() {
    final comboProperties = ComboProperties(withChildDecorator: false)
      ..position.value = PopupPosition.bottomMatch;
    final popupWidth = IntEditor(
        title: 'Popup Width',
        onChanged: (value) => comboProperties.position.value =
            value == null ? PopupPosition.bottomMatch : PopupPosition.bottom);
    return EnumProperties._(popupWidth, comboProperties);
  }
  EnumProperties._(this.popupWidth, this.comboProperties);

  final value = EnumEditor<MainAxisAlignment>(
      title: 'Value', getList: () => [null, ...MainAxisAlignment.values]);
  final IntEditor popupWidth;
  final ComboProperties comboProperties;

  @override
  List<EditorsBuilder> get editors => [
        value,
        ...super.editors,
        const EditorsSeparator('Combo Properties'),
        popupWidth,
        ...comboProperties.editors,
      ];
}

class ColorProperties extends ElementProperties {
  factory ColorProperties() {
    final comboProperties = ComboProperties(withChildDecorator: false);
    final popupWidth = IntEditor(
        title: 'Popup Width',
        onChanged: (value) => comboProperties.position.value =
            value == null ? PopupPosition.bottomMatch : PopupPosition.bottom);
    return ColorProperties._(popupWidth, comboProperties);
  }
  ColorProperties._(this.popupWidth, this.comboProperties);

  final value = ColorEditor(title: 'Value');
  final IntEditor popupWidth;
  final ComboProperties comboProperties;

  @override
  List<EditorsBuilder> get editors => [
        value,
        ...super.editors,
        const EditorsSeparator('Combo Properties'),
        popupWidth,
        ...comboProperties.editors,
      ];
}

Use this package as a library

1. Depend on it

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


dependencies:
  editors: ^0.0.11

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:editors/editors.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
44
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • editors that is a package requiring null.

Package not compatible with runtime flutter-web on Web

Because:

  • package:editors/editors.dart that imports:
  • package:creo_color_picker/creo_color_picker.dart that imports:
  • package:combos/combos.dart that imports:
  • dart:io

Health suggestions

Fix lib/editors.dart. (-0.50 points)

Analysis of lib/editors.dart reported 1 hint:

line 718 col 7: The declaration '_NumTextInputFormatter' isn't referenced.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
calendart ^1.0.5 1.0.7
combos ^1.2.0 1.2.0
creo_color_picker ^0.0.4 0.0.4
flutter 0.0.0
titles 0.0.4 0.0.4
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
pedantic ^1.8.0