selectable_container 0.1.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 77

selectable_container #

A Selectable Container for Flutter. Easy to implement and customize.

Demo #

Demo:

Usage #

To use plugin, just import package import 'package:selectable_container/selectable_container.dart';

Example #

Check de example directory to access the project that implements the image shown above.

    import 'package:flutter/material.dart';
    import 'package:selectable_container/selectable_container.dart';

    class SimpleExamplePage extends StatefulWidget {
      @override
      _SimpleExamplePageState createState() => _SimpleExamplePageState();
    }

    class _SimpleExamplePageState extends State<SimpleExamplePage> {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('Selectable Container'),
          ),
          body: Column(
            children: <Widget>[
              Text(
                'Default container',
                style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
              ),
              SelectableContainer(
                onPressed: () {},
                child: Text('Tap me'),
                padding: 16.0,
              ),
            ],
          ),
        );
      }
    }

[0.0.1] - 2019-11-10

  • A selectable container for Flutter. Easy to implement and customize.

[0.0.2] - 2019-11-10

  • Beter license and documentation

[0.1.1] - 2019-11-10

  • All settings tested. Production version.

[0.1.2] - 2019-11-15

  • New setting 'elevation' and 'borderradius'

[0.1.3] - 2019-11-28

  • Property selected is now public

example/README.md

example #

Example project for SelectableContainer widget

Example #

    import 'package:flutter/material.dart';
    import 'package:selectable_container/selectable_container.dart';

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

    class MyApp extends StatelessWidget {
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Selectable Container Example',
          home: MyHomePage(),
        );
      }
    }

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

    class _MyHomePageState extends State<MyHomePage> {
      @override
      Widget build(BuildContext context) {
        var textStyles = Theme.of(context).textTheme;

        return Scaffold(
          appBar: AppBar(
            title: Text('Selectable Container Example'),
          ),
          body: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              SelectableContainer(
                child: buildTextContentOfContainer(
                    'Selectable Container', 'Default theme colors', textStyles),
                onPressed: () {},
                padding: 8.0,
              ),
              SizedBox(
                height: 16.0,
              ),
              SelectableContainer(
                selectedBorderColor: Colors.teal.shade700,
                selectedBackgroundColor: Colors.grey.shade100,
                unselectedBorderColor: Colors.teal.shade600,
                unselectedBackgroundColor: Colors.grey.shade200,
                iconAlignment: Alignment.topLeft,
                icon: Icons.thumb_up,
                iconSize: 24,
                unselectedOpacity: 0.5,
                padding: 8.0,
                child: buildTextContentOfContainer('Custom color',
                    'Icon, size, position en opacitiy changed', textStyles),
                onPressed: () {},
              ),
              SizedBox(
                height: 16.0,
              ),
              SelectableContainer(
                iconSize: 20,
                icon: Icons.star,
                iconColor: Colors.yellowAccent,
                unselectedOpacity: 0.3,
                opacityAnimationDuration: 300,
                child: buildDemoContent3(),
                padding: 16.0,
                onPressed: () {},
              )
            ],
          ),
        );
      }

      Widget buildTextContentOfContainer(
          String title, String subtitle, TextTheme textStyles) {
        return Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Text(
              title,
              style: textStyles.display1,
            ),
            Text(
              subtitle,
              style: textStyles.body1,
            ),
          ],
        );
      }

      Widget buildDemoContent3() {
        return Column(
          children: <Widget>[
            Row(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                CircleAvatar(
                  backgroundImage: AssetImage('images/flutter.png'),
                  radius: 25.0,
                ),
                SizedBox(
                  width: 8.0,
                ),
                Text(
                  'Develop with Flutter',
                  style: TextStyle(
                      fontWeight: FontWeight.w500,
                      fontSize: 20.0,
                      color: Colors.blue.shade700),
                ),
              ],
            )
          ],
        );
      }
    }

Use this package as a library

1. Depend on it

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


dependencies:
  selectable_container: ^0.1.3

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:selectable_container/selectable_container.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
55
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]
77
Learn more about scoring.

We analyzed this package on Dec 13, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.1+4
  • Flutter: 1.12.13+hotfix.4

Health suggestions

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

Analysis of lib/selectable_container.dart reported 1 hint:

line 7 col 7: This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: SelectableContainer.selected

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test