jpnurmi / item_selector
1
// MIT License
2
//
3
// Copyright (c) 2020 J-P Nurmi
4
//
5
// The ItemSelector library is based on:
6
// Multi Select GridView in Flutter - by Simon Lightfoot:
7
// https://gist.github.com/slightfoot/a002dd1e031f5f012f810c6d5da14a11
8
//
9
// Copyright (c) 2019 Simon Lightfoot
10
//
11
// Permission is hereby granted, free of charge, to any person obtaining a copy
12
// of this software and associated documentation files (the "Software"), to deal
13
// in the Software without restriction, including without limitation the rights
14
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
// copies of the Software, and to permit persons to whom the Software is
16
// furnished to do so, subject to the following conditions:
17
//
18
// The above copyright notice and this permission notice shall be included in all
19
// copies or substantial portions of the Software.
20
//
21
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
// SOFTWARE.
28
//
29
// Thanks to Hugo Passos.
30
//
31
import 'package:flutter/widgets.dart';
32

33
/// Specifies how an item selection controller responds to user interaction.
34
///
35
/// See also [ItemSelectionController()].
36 1
enum ItemSelectionMode {
37
  /// No interactive selection.
38
  none,
39

40
  /// Single-selection by tap.
41
  single,
42

43
  /// Multi-selection by long-press and drag (default).
44
  multi,
45
}
46

47
/// Signature for a callback function that is called by [ItemSelectionController]
48
/// when items are interactively selected by the user.
49
typedef ItemSelectionActionCallback = bool Function(int start, int end);
50

51
/// Signature for a callback function that is called by [ItemSelection] when an
52
/// item selection state changes to [selected] at the specified [index].
53
typedef ItemSelectionChangeCallback = void Function(int index, bool selected);
54

55
/// Signature for a builder function that is called by [ItemSelectionBuilder] to
56
/// create a widget for a given [index] and [selected] state.
57
typedef ItemSelectionWidgetBuilder = Widget Function(
58
    BuildContext context, int index, bool selected);
59

60
class ItemSelectionMetaData {
61
  final int index;
62 1
  ItemSelectionMetaData({required this.index});
63
}

Read our documentation on viewing source code .

Loading