stanley 0.6.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 66

stanley #

Common flutter widgets and helper methods.

Dependencies #

As of now, stanley is an opiniated package which includes dependencies to:

Main classes #

Decorator #

A all-in-one budget to manage layout and styling of other widgets. Based on the properties set, Decorator will encapsulate the child wigdet with whatever is needed to support:

  • Sizing
  • Margins
  • Paddings
  • Borders (including rounded)
  • Background color
  • Tap handler

Paddings and margins can be specified with various parameters that can be used to override defaults. For instance:

  • paddingAll: 16
  • paddingHoriz: 8
  • paddingLeft: 4

Will result in:

  • Top and bottom = 16 (paddingAll)
  • Right = 8 (overriden by paddingHoriz)
  • Left = 4 (overriden by paddingLeft)

The example uses Decorator for the buttons displayed on the page.

Native Dialog #

A class to display native dialogs and alert sheets on iOS and Android with unified interface. The example demonstrates several uses of this.

Other UI Helpers #

Other helpers include scaffold, text which basically embrace the same philosophy as Decorator: pass all required parmeters and these classes will do the work.

Forms #

A set of classes to quickly create vertical forms (definitely more Material than iOS). Those were mostly created for non-white backgrounds as they override a number decorations to fit your style. You can override PaddedFormField.textColor (defaults to white) if needed.

All widgets include the possibility to attach an icon as decoration that can be clicked to get help.

Widgets include:

  • DecoratedTextFormField: safe explanatory
  • DropdownField: encapsulated DropdownButtonFormField
  • ToggleFormField: specialized DropdownField for boolean choices

[0.6.2] - 2020-05-10 #

  • Fix Decorator when using Flex and GestureDetector simultaneously

[0.6.1] - 2020-05-09 #

  • Format

[0.6.0] - 2020-05-09 #

  • Keyboard hider
  • Support for flex
  • Support for italic in text
  • Support for FAB in scaffold
  • Support for images in ActionBar

[0.5.0] - 2020-04-30 #

  • Improved iOS dialog fidelity

[0.4.0] - 2020-04-25 #

  • Tabs with appbar actions dynamic update

[0.3.0] - 2020-04-25 #

  • Progress indicator

[0.2.1] - 2020-04-20 #

  • README.md update

[0.2.0] - 2020-04-20 #

  • Refactor of native dialogs
  • Updated example

[0.1.2] - 2020-04-17 #

  • Example
  • Avoid crash if no easy_localization

[0.1.1] - 2020-04-17 #

  • Flutter format

[0.1.0] - 2020-04-15 #

  • Initial migration from projects

example/lib/main.dart

import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:stanley/stanley.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return EasyLocalization(
      supportedLocales: [Locale('en', 'US')],
      fallbackLocale: Locale('en', 'US'),
      path: 'i18n',
      child: MaterialApp(
        title: 'Stanley Demo',
        home: MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends BottomBarState<MyHomePage> {

  List<Widget> _children;

  @override
  void initState() {

    // basic
    super.initState();

    // visibility flags
    List<ValueNotifier<bool>> visibilityFlags = initVisibilityFlags(count: 2);

    // init children
    _children = [
      DemoTab(visibilityFlag: visibilityFlags[0],),
      ShareTab(visibilityFlag: visibilityFlags[1],),
    ];
  }

  @override
  Widget buildWidget(BuildContext context) {
    return UIHelper.scaffold(
      title: 'Stanley Demo',
      paddingAll: 64,
      paddingVert: 256,
      actions: appBarActions,
      widget: _children[currentPage],
      bottomBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        onTap: onTabTapped,
        currentIndex: currentPage,
        items: [
          new BottomNavigationBarItem(
            icon: Icon(Icons.apps),
            title: UIHelper.text('Demo'),
          ),
          new BottomNavigationBarItem(
            icon: Icon(Icons.share),
            title: UIHelper.text('Share'),
          ),
        ],
      ),
    );
  }
}

class DemoTab extends BaseTabPage {

  DemoTab({
    Key key,
    visibilityFlag
  }) : super(key: key, visibilityFlag: visibilityFlag,);

  @override
  DemoState createState() => new DemoState();
}

class DemoState extends BaseTabState<DemoTab> {

  @override
  Widget buildWidget(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      children: [
        Button(
          label: 'Inform',
          onTap: () {
            NativeDialog.info(
              context,
              'This is Stanley',
            );
          },
        ),
        Button(
          label: 'Confirm',
          onTap: () {
            NativeDialog.alert(
              context: context,
              title: 'Are you sure?',
              content: 'Press "yes" only if you\'re really sure!',
              actions: [
                AlertDialogAction.cancel(
                  label: tr('no'),
                  isDefault: true,
                ),
                AlertDialogAction(
                  label: tr('yes'),
                  onTap: () {
                    NativeDialog.info(context, 'So be it!');
                  },
                )
              ],
            );
          },
        ),
        Button(
          label: 'Multiple choices',
          onTap: () {
            NativeDialog.alert(
              context: context,
              title: 'Please select one',
              actions: [
                AlertDialogAction(
                  label: 'Green',
                  color: Colors.green,
                ),
                AlertDialogAction(
                  label: 'Orange',
                  color: Colors.orange,
                  isDefault: true,
                ),
                AlertDialogAction(
                  label: 'Blue',
                  color: Colors.blue,
                ),
              ],
            );
          },
        ),
        Button(
          label: 'Native Bottom Sheet',
          onTap: () {
            NativeDialog.bottomSheet(
              context: context,
              title: 'Please select one',
              actions: [
                AlertDialogAction(
                  label: 'Green',
                  color: Colors.green,
                ),
                AlertDialogAction(
                  label: 'Orange',
                  color: Colors.orange,
                  isDefault: true,
                ),
                AlertDialogAction(
                  label: 'Blue',
                  color: Colors.blue,
                ),
              ],
              cancelAction: AlertDialogAction.cancel(isDefault: true),
            );
          },
        ),
        Button(
          label: 'Material Bottom Sheet',
          onTap: () {
            NativeDialog.bottomSheet(
              context: context,
              forceMaterial: true,
              title: 'Please select one',
              actions: [
                AlertDialogAction(
                  label: 'Green',
                  color: Colors.green,
                ),
                AlertDialogAction(
                  label: 'Orange',
                  color: Colors.orange,
                  isDefault: true,
                ),
                AlertDialogAction(
                  label: 'Blue',
                  color: Colors.blue,
                ),
              ],
              cancelAction: AlertDialogAction.cancel(isDefault: true),
            );
          },
        ),
      ],
    );

  }

  @override
  List<Widget> getAppBarActions(BuildContext context) {
    return [
      UIHelper.appBarIcon(icon: Icons.menu, onTap: () {
        NativeDialog.info(context, 'You tapped menu');
      }),
    ];
  }

}

class ShareTab extends BaseTabPage {

  ShareTab({
    Key key,
    visibilityFlag
  }) : super(key: key, visibilityFlag: visibilityFlag,);

  @override
  ShareState createState() => ShareState();
}

class ShareState extends BaseTabState<ShareTab> {

  @override
  Widget buildWidget(BuildContext context) {
    return Decorator(
      centered: true,
      child: UIHelper.text('Nothing here except app bar icons', size: 32),
    );
  }

  @override
  List<Widget> getAppBarActions(BuildContext context) {
    return [
      UIHelper.appBarIcon(icon: Icons.share, onTap: () {
        NativeDialog.info(context, 'You tapped share');
      }),
      UIHelper.appBarIcon(icon: Icons.close, onTap: () {
        NativeDialog.info(context, 'You tapped close');
      }),
    ];
  }
}

class Button extends StatelessWidget {
  final String label;
  final Function onTap;
  const Button({
    Key key,
    this.label,
    this.onTap,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Decorator(
      centered: true,
      paddingVert: 8,
      paddingHoriz: 16,
      borderColor: Colors.black,
      borderWidth: 1,
      borderRadius: 4,
      child: UIHelper.text(label, size: 18),
      onTap: onTap,
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  stanley: ^0.6.2

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:stanley/stanley.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
33
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform android

Because of import path [package:stanley/stanley.dart, package:stanley/src/i18n.dart, package:easy_localization/easy_localization.dart, package:easy_localization/src/public_ext.dart, package:easy_localization/src/easy_localization_app.dart, package:shared_preferences/shared_preferences.dart, package:shared_preferences_linux/shared_preferences_linux.dart] that declares support for platforms: linux

Package does not support Flutter platform ios

Because of import path [package:stanley/stanley.dart, package:stanley/src/i18n.dart, package:easy_localization/easy_localization.dart, package:easy_localization/src/public_ext.dart, package:easy_localization/src/easy_localization_app.dart, package:shared_preferences/shared_preferences.dart, package:shared_preferences_linux/shared_preferences_linux.dart] that declares support for platforms: linux

Package does not support Flutter platform macos

Because of import path [package:stanley/stanley.dart, package:stanley/src/i18n.dart, package:easy_localization/easy_localization.dart, package:easy_localization/src/public_ext.dart, package:easy_localization/src/easy_localization_app.dart, package:shared_preferences/shared_preferences.dart, package:shared_preferences_linux/shared_preferences_linux.dart] that declares support for platforms: linux

Package does not support Flutter platform web

Because of import path [package:stanley/stanley.dart, package:stanley/src/i18n.dart, package:easy_localization/easy_localization.dart, package:easy_localization/src/public_ext.dart, package:easy_localization/src/easy_localization_app.dart, package:shared_preferences/shared_preferences.dart, package:shared_preferences_linux/shared_preferences_linux.dart] that declares support for platforms: linux

Package does not support Flutter platform windows

Because of import path [package:stanley/stanley.dart, package:stanley/src/i18n.dart, package:easy_localization/easy_localization.dart, package:easy_localization/src/public_ext.dart, package:easy_localization/src/easy_localization_app.dart, package:shared_preferences/shared_preferences.dart] that declares support for platforms: android, ios, linux, macos, web

Package not compatible with SDK dart

because of import path [stanley] that is in a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
easy_localization ^2.1.0+1 2.3.2
flutter 0.0.0
intl ^0.16.0 0.16.1
Transitive dependencies
args 1.6.0
collection 1.14.12 1.14.13
file 5.2.1
flutter_localizations 0.0.0
flutter_web_plugins 0.0.0
meta 1.1.8 1.2.1
path 1.6.4 1.7.0
path_provider_linux 0.0.1+2
path_provider_platform_interface 1.0.2
platform 2.2.1
plugin_platform_interface 1.0.2
process 3.0.13
shared_preferences 0.5.8
shared_preferences_linux 0.0.2+1
shared_preferences_macos 0.0.1+10
shared_preferences_platform_interface 1.0.4
shared_preferences_web 0.1.2+7
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
xdg_directories 0.1.0
Dev dependencies
flutter_test