animated_item_picker 1.0.3 copy "animated_item_picker: ^1.0.3" to clipboard
animated_item_picker: ^1.0.3 copied to clipboard

outdated

Generic item picker that encapsulates single or multiple item selection logic.

example/lib/main.dart

import 'package:animated_item_picker/animated_item_picker.dart';
import 'package:example/model/day_of_week.dart';
import 'package:example/model/level.dart';
import 'package:example/ui/helper.dart';
import 'package:example/ui/item_widgets.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: Material(child: HomePage(), color: Colors.black));
  }
}

class HomePage extends StatelessWidget {
  static ColorTween _firstPickerColorTween1 = ColorTween(begin: Colors.white, end: Colors.redAccent);
  static ColorTween _firstPickerColorTween2 = ColorTween(begin: Colors.black, end: Colors.redAccent);

  static ColorTween _secondPickerColorTween1 = ColorTween(begin: Colors.black, end: Colors.yellow);
  static ColorTween _secondPickerColorTween2 = ColorTween(begin: Colors.white, end: Colors.yellow);

  @override
  Widget build(BuildContext context) {
    return Column(mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [
      decorateFirstItemPicker(
        AnimatedItemPicker(
            axis: Axis.horizontal,
            multipleSelection: false,
            itemCount: Level.LIST.length,
            pressedOpacity: 0.85,
            initialSelection: {Level.LIST.indexOf(Level.BEGINNER)},
            expandedItems: true,
            onItemPicked: (index, selected) {
              print("Gender: ${Level.LIST[index]}, selected: $selected");
            },
            itemBuilder: (index, animValue) => GenderItemWidget(
                  name: Level.LIST[index].toString(),
                  borderColor: _firstPickerColorTween2.transform(animValue)!,
                  textColor: _firstPickerColorTween1.transform(animValue)!,
                )),
      ),
      decorateSecondItemPicker(
        AnimatedItemPicker(
          axis: Axis.vertical,
          multipleSelection: true,
          itemCount: DayOfWeek.LIST.length,
          maxItemSelectionCount: 6,
          expandedItems: true,
          initialSelection: {1},
          onItemPicked: (index, selected) {
            print("Day: ${DayOfWeek.LIST[index]}, selected: $selected");
          },
          itemBuilder: (index, animValue) => DayItemWidget(
            name: DayOfWeek.LIST[index],
            textColor: _secondPickerColorTween2.transform(animValue)!,
            backgroundColor: _secondPickerColorTween1.transform(animValue)!,
          ),
        ),
      ),
    ]);
  }
}
34
likes
0
points
38
downloads

Publisher

verified publisherkirn.tech

Weekly Downloads

Generic item picker that encapsulates single or multiple item selection logic.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on animated_item_picker