roller_list 0.5.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 75

Codemagic build status

roller_list package #

This widget is a list of values distributed in a circle. The main rules of the list are: a user could scroll it in one direction endlessly, list values are limited and repeated in the same order over and over again. Possible usage scheme: -time selection -piano notes selection -choice of any limited number of items, where it is not important what should go first and what should go last.

Example #

You can check Flutter for web build here Or see how it looks like on iphone:

How to use #

In the dependencies: section of your pubspec.yaml, add the following line:

roller_list: <latest version>

Then import this class:

import 'package:roller_list/roller_list.dart';

And add your list like this (with only programmatical scroll):

RollerList(
 items: slots,
 enabled: false,
 key: leftRoller,
)

Or like this (with enabled scroll):

RollerList(
  items: months,
  onSelectedIndexChanged: _changeMonths,
  initialIndex: 1,
)

where months is a list of widgets:

static const MONTHS = {
    "January": 31,
    "February": 29,
    "March": 31,
    "April": 30,
    "May": 31,
    "June": 30,
    "July": 31,
    "August": 31,
    "September": 30,
    "October": 31,
    "November": 30,
    "December": 31
  };

final List<Widget> months = MONTHS.keys
  .map((month) => Padding(
        padding: EdgeInsets.all(12.0),
        child: Text(
          month,
          textScaleFactor: 1.3,
          textAlign: TextAlign.center,
        ),
      ))
  .toList();

and _changeMonths will show the selection result somewhere in the widget tree:

void _changeMonths(int value) {
    setState(() {
      selectedMonth = MONTHS.keys.toList()[value];
    });
}

[0.5.5] - 09.03.2020 #

Add an example with one roller list that depends on another. Fix issue when initial selection is 0 and this value is not selected in list

[0.5.4] - 09.03.2020 #

Get rid of jumping animation when the selected item is outside the main range. Add an option to set thickness of the divider line. In example it is clear how to highlight selected item inside list

[0.5.3] - 09.02.2020 #

Add an option to build items in the list with function, fix some selection issues

[0.5.2] - 09.12.2019 #

Updates in dependency and description

[0.5.1] - 09.12.2019 #

This version has some state methods to make it possible to scroll programmatically to the required item or position

[0.0.1] - 07.12.2019 #

Initial version. The list works as a roller. The main aim is selecting a value inside list

example/lib/main.dart

import 'package:example_roller_list/slot_machine.dart';
import 'package:example_roller_list/time_selector.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'date_selector.dart';

void main() {
  if (kIsWeb) {
    runApp(new MyApp());
  } else {
    WidgetsFlutterBinding.ensureInitialized();
    SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
        .then((_) async {
      runApp(new MyApp());
    });
  }
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'RollerList Demo',
      theme: ThemeData(
        primarySwatch: Colors.red,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _MyHomePageState();
  }
}

class _MyHomePageState extends State<MyHomePage> {
  int selectedItem = 1;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("RollerList"),
        actions: <Widget>[
          Container(
            padding: EdgeInsets.symmetric(horizontal: 24.0),
            decoration: BoxDecoration(
              color: Colors.white10,
              border: Border.all(
                  width: 1.0,
                  style: BorderStyle.solid,
                  color: Colors.redAccent),
            ),
            child: DropdownButtonHideUnderline(
              child: DropdownButton<int>(
                value: selectedItem,
                items: <DropdownMenuItem<int>>[
                  new DropdownMenuItem(
                    child: new Text(
                      'CLOCK',
                      textAlign: TextAlign.right,
                    ),
                    value: 0,
                  ),
                  new DropdownMenuItem(
                    child: new Text(
                      'DATES',
                      textAlign: TextAlign.right,
                    ),
                    value: 1,
                  ),
                  new DropdownMenuItem(
                    child: new Text(
                      'SLOT MACHINE',
                    ),
                    value: 2,
                  ),
                ],
                onChanged: (int value) {
                  setState(() => selectedItem = value);
                },
              ),
            ),
          ),
        ],
      ),
      body: Padding(
        padding: EdgeInsets.all(16.0),
        child: Center(
            child: selectedItem == 0
                ? TimeSelector()
                : selectedItem == 1 ? DateSelector() : SlotMachine()),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  roller_list: ^0.5.5

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

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
infinite_listview ^1.0.1+1 1.0.1+1
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