### StatefulWidget Build Method Example Source: https://pub.dev/documentation/flutter_boardview/latest/board_item/BoardItemState/build.html This illustrates the typical structure of a build method within a Flutter State object. It returns a Widget that describes the UI. The framework calls this method when the widget needs to be rendered or updated. ```dart class MyButton extends StatefulWidget { const MyButton({super.key, this.color = Colors.teal}); final Color color; // ... } class MyButtonState extends State { // ... @override Widget build(BuildContext context) { return SpecialWidget( handler: () { print('color: ${widget.color}'); }, ); } } ``` -------------------------------- ### BoardViewController Constructor Implementation Source: https://pub.dev/documentation/flutter_boardview/latest/boardview_controller/BoardViewController/BoardViewController.html The default constructor for BoardViewController. No specific setup or parameters are required. ```dart BoardViewController(); ``` -------------------------------- ### Flutter initState Implementation Example Source: https://pub.dev/documentation/flutter_boardview/latest/board_list/BoardListState/initState.html This snippet demonstrates a typical implementation of the initState method in a Flutter State object. It initializes a local state variable '_header' with a value from the widget's configuration and calls the superclass's initState. ```dart @override void initState() { setState(() { _header = widget.header; }); super.initState(); } ``` -------------------------------- ### OnDropItem Typedef Implementation Source: https://pub.dev/documentation/flutter_boardview/latest/board_item/OnDropItem.html Provides a concrete implementation of the OnDropItem typedef. This example shows how to declare the function signature for handling drop events in a Flutter BoardView. ```dart typedef OnDropItem = void Function(int? listIndex, int? itemIndex, int? oldListIndex, int? oldItemIndex, BoardItemState state); ``` -------------------------------- ### onStartDragItem Property Declaration Source: https://pub.dev/documentation/flutter_boardview/latest/board_item/BoardItem/onStartDragItem.html This snippet shows the declaration of the onStartDragItem property within the BoardItem class. It is an optional callback that can be used to intercept and manage the start of a drag event for a board item. ```dart final OnStartDragItem? onStartDragItem; ``` -------------------------------- ### Capture Widget Dimensions after First Layout Source: https://pub.dev/documentation/flutter_boardview/latest/board_item/BoardItemState/afterFirstLayout.html This method should be called after the widget has been laid out for the first time to get its dimensions. It safely captures height and width, printing any errors in debug mode. ```dart void afterFirstLayout(BuildContext context) { try { height = context.size!.height; width = context.size!.width; } catch (e) { if (kDebugMode) { print(e.toString()); } } } ``` -------------------------------- ### Declare Pointer Variable Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState/pointer.html Declares a dynamic variable named 'pointer'. This is the initial setup for the getter/setter pair. ```dart var pointer; ``` -------------------------------- ### offsetX Property Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState/offsetX.html The offsetX property allows you to get or set the horizontal offset of the board view. It is a nullable double. ```APIDOC ## offsetX Property ### Description The `offsetX` property represents the horizontal offset of the board view. It is a nullable double that can be accessed via a getter and setter. ### Getter/Setter This property is implemented as a getter and setter pair. ### Implementation ```dart double? offsetX; ``` ``` -------------------------------- ### BoardViewState Constructors Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState-class.html Initializes a new instance of the BoardViewState class. ```APIDOC ## BoardViewState() ### Description Initializes a new instance of the BoardViewState class. ### Constructors - **BoardViewState()** ``` -------------------------------- ### Configure BoardItem Source: https://pub.dev/packages/flutter_boardview Illustrates how to configure a BoardItem with callback methods for drag and drop events, and the item widget itself. ```dart BoardItem( onStartDragItem: (int? listIndex, int? itemIndex, BoardItemState state) { }, onDropItem: (int? listIndex, int? itemIndex, int oldListIndex, int oldItemIndex, BoardItemState state) { }, onTapItem: (int? listIndex, int? itemIndex, BoardItemState state) async { }, item: Card( child: Padding( padding: const EdgeInsets.all(8), child: Text("Board Item"), ), ) ); ``` -------------------------------- ### Configure BoardList Source: https://pub.dev/packages/flutter_boardview Shows how to configure a BoardList, including callback methods for drag and drop events, background colors, and header items. ```dart BoardList( onStartDragList: (int? listIndex) { }, onTapList: (int? listIndex) async { }, onDropList: (int? listIndex, int? oldListIndex) { }, headerBackgroundColor: Color.fromARGB(255, 235, 236, 240), backgroundColor: Color.fromARGB(255, 235, 236, 240), header: [ Expanded( child: Padding( padding: EdgeInsets.all(5), child: Text( "List Item", style: TextStyle(fontSize: 20), ))) ], items: items, ); ``` -------------------------------- ### BoardViewController Constructor Source: https://pub.dev/documentation/flutter_boardview/latest/boardview_controller/BoardViewController/BoardViewController.html Initializes a new instance of the BoardViewController class. ```APIDOC ## BoardViewController() ### Description Initializes a new instance of the BoardViewController class. ### Method Constructor ### Endpoint N/A ### Parameters None ### Request Example None ### Response #### Success Response (Instance) - **BoardViewController** (BoardViewController) - An initialized instance of the BoardViewController. #### Response Example None ``` -------------------------------- ### BoardViewController Constructors Source: https://pub.dev/documentation/flutter_boardview/latest/boardview_controller/BoardViewController-class.html Initializes a new instance of the BoardViewController class. ```APIDOC ## BoardViewController() ### Description Initializes a new instance of the BoardViewController class. ### Method Constructor ### Endpoint N/A ### Parameters None ``` -------------------------------- ### BoardItem Constructor Source: https://pub.dev/documentation/flutter_boardview/latest/board_item/BoardItem-class.html Initializes a new BoardItem instance. It accepts various optional parameters to customize the item's appearance, behavior, and interactions. ```APIDOC ## BoardItem Constructor ### Description Initializes a new BoardItem instance. It accepts various optional parameters to customize the item's appearance, behavior, and interactions. ### Parameters - **key** (Key?): Controls how one widget replaces another widget in the tree. - **boardList** (BoardListState?): The state object for the parent board list. - **item** (Widget?): The widget to display as the item's content. - **index** (int?): The index of this item within the board list. - **onDropItem** (OnDropItem?): Callback function triggered when an item is dropped. - **onTapItem** (OnTapItem?): Callback function triggered when an item is tapped. - **onStartDragItem** (OnStartDragItem?): Callback function triggered when an item starts being dragged. - **draggable** (bool): Determines if the item is draggable. Defaults to true. - **onDragItem** (OnDragItem?): Callback function triggered during the drag operation. ``` -------------------------------- ### BoardListState Build Method Source: https://pub.dev/documentation/flutter_boardview/latest/board_list/BoardListState/build.html Renders the UI for a single board list, including its header, items, and footer. Handles tap and long-press events for drag-and-drop functionality. ```dart @override Widget build(BuildContext context) { super.build(context); List listWidgets = []; if (_header != null) { Color? headerBackgroundColor = Theme.of(context).colorScheme.outlineVariant.withOpacity(0.4); if (widget.headerBackgroundColor != null) { headerBackgroundColor = widget.headerBackgroundColor; } listWidgets.add(GestureDetector( onTap: () { if (widget.onTapList != null) { widget.onTapList!(widget.index); } }, onTapDown: (otd) { if (widget.draggable) { RenderBox object = context.findRenderObject() as RenderBox; Offset pos = object.localToGlobal(Offset.zero); widget.boardView!.initialX = pos.dx; widget.boardView!.initialY = pos.dy; widget.boardView!.rightListX = pos.dx + object.size.width; widget.boardView!.leftListX = pos.dx; } }, onTapCancel: () {}, onLongPress: () { if (!widget.boardView!.widget.isSelecting && widget.draggable) { _startDrag(widget, context); } }, child: Container( decoration: BoxDecoration( color: headerBackgroundColor, borderRadius: const BorderRadius.vertical(top: Radius.circular(8)), ), child: Row(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: _header!), ))); } if (widget.items != null) { if (widget.listBuilder != null) { listWidgets.add(Flexible(fit: FlexFit.tight, child: widget.listBuilder!(_itemBuilder))); } else { listWidgets.add(Flexible( fit: FlexFit.tight, child: ListView.builder( shrinkWrap: true, physics: const AlwaysScrollableScrollPhysics(), controller: boardListController, itemCount: widget.items!.length, itemBuilder: _itemBuilder, ))); } } if (widget.footer != null) { listWidgets.add(widget.footer!); } Color? backgroundColor = Theme.of(context).colorScheme.onInverseSurface; if (widget.backgroundColor != null) { backgroundColor = widget.backgroundColor; } if (widget.boardView!.listStates.length > widget.index!) { widget.boardView!.listStates.removeAt(widget.index!); } widget.boardView!.listStates.insert(widget.index!, this); return Container( margin: const EdgeInsets.all(8), decoration: BoxDecoration( color: backgroundColor, borderRadius: const BorderRadius.all(Radius.circular(8)), ), child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.end, children: listWidgets, )); } ``` -------------------------------- ### BoardViewState Build Method Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState/build.html The main build method for the BoardViewState. It includes debug logging, scroll position updates via addPostFrameCallback, and renders the ListView for the board lists. It also handles opacity for dragged lists. ```dart @override Widget build(BuildContext context) { super.build(context); if (kDebugMode) { print("dy:$dy"); print("topListY:$topListY"); print("bottomListY:$bottomListY"); } if (boardViewController.hasClients) { WidgetsBinding.instance.addPostFrameCallback((Duration duration) { try { boardViewController.position.didUpdateScrollPositionBy(0); } catch (e) { if (kDebugMode) { print(e.toString()); } } bool scrollShown = boardViewController.position.maxScrollExtent != 0; if (scrollShown != shown) { setState(() { shown = scrollShown; }); } }); } Widget listWidget = ListView.builder( physics: const ClampingScrollPhysics(), itemCount: widget.lists!.length, scrollDirection: Axis.horizontal, controller: boardViewController, itemBuilder: (BuildContext context, int index) { if (widget.lists![index].boardView == null) { widget.lists![index] = BoardList( key: widget.lists![index].key, items: widget.lists![index].items, headerBackgroundColor: widget.lists![index].headerBackgroundColor, backgroundColor: widget.lists![index].backgroundColor, footer: widget.lists![index].footer, header: widget.lists![index].header, boardView: this, draggable: widget.lists![index].draggable, onDropList: widget.lists![index].onDropList, onTapList: widget.lists![index].onTapList, onStartDragList: widget.lists![index].onStartDragList, listBuilder: widget.lists![index].listBuilder, ); } if (widget.lists![index].index != index) { widget.lists![index] = BoardList( key: widget.lists![index].key, items: widget.lists![index].items, headerBackgroundColor: widget.lists![index].headerBackgroundColor, backgroundColor: widget.lists![index].backgroundColor, footer: widget.lists![index].footer, header: widget.lists![index].header, boardView: this, draggable: widget.lists![index].draggable, index: index, onDropList: widget.lists![index].onDropList, onTapList: widget.lists![index].onTapList, onStartDragList: widget.lists![index].onStartDragList, listBuilder: widget.lists![index].listBuilder, ); } var temp = Container( width: widget.width, padding: EdgeInsets.fromLTRB(0, 0, 0, widget.bottomPadding ?? 0), child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [Expanded(child: widget.lists![index])], )); if (draggedListIndex == index && draggedItemIndex == null) { return Opacity( opacity: 0.0, child: temp, ); } else { return temp; } }, ); List stackWidgets = [listWidget]; bool isInBottomWidget = false; if (dy != null) { if (MediaQuery.of(context).size.height - dy! < 80) { isInBottomWidget = true; } } if (widget.itemInMiddleWidget != null && _isInWidget != isInBottomWidget) { widget.itemInMiddleWidget!(isInBottomWidget); _isInWidget = isInBottomWidget; } if (initialX != null && initialY != null && offsetX != null && offsetY != null && dx != null && dy != null && height != null) { if (canDrag && dxInit != null && dyInit != null && !isInBottomWidget) { if (draggedItemIndex != null && draggedItem != null && topItemY != null && bottomItemY != null) { //dragging item if (0 <= draggedListIndex! - 1 && dx! < leftListX! + 45) { //scroll left if (boardViewController.hasClients) { boardViewController.animateTo( boardViewController.position.pixels - 5, duration: const Duration(milliseconds: 10), curve: Curves.ease); if (listStates[draggedListIndex!].mounted) { RenderBox object = listStates[draggedListIndex!] .context .findRenderObject() as RenderBox; Offset pos = object.localToGlobal(Offset.zero); leftListX = pos.dx; rightListX = pos.dx + object.size.width; } } } if (widget.lists!.length > draggedListIndex! + 1 && dx! > rightListX! - 45) { //scroll right if (boardViewController.hasClients) { boardViewController.animateTo( boardViewController.position.pixels + 5, duration: const Duration(milliseconds: 10), curve: Curves.ease); if (listStates[draggedListIndex!].mounted) { RenderBox object = listStates[draggedListIndex!] ``` -------------------------------- ### BoardViewState Methods Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState-class.html Provides methods for interacting with and manipulating the state of the BoardView, including methods for moving items and lists, and managing the widget lifecycle. ```APIDOC ## BoardViewState Methods ### Description Provides methods for interacting with and manipulating the state of the BoardView, including methods for moving items and lists, and managing the widget lifecycle. ### Methods - **build(BuildContext context) → Widget** Describes the part of the user interface represented by this widget. - **initState() → void** Called when this object is inserted into the tree. - **moveDown() → void** - **moveLeft() → void** - **moveListLeft() → void** - **moveListRight() → void** - **moveRight() → void** - **moveUp() → void** - **run() → void** - **setState(VoidCallback fn) → void** Notify the framework that the internal state of this object has changed. ### Inherited Methods - **activate() → void** Called when this object is reinserted into the tree after having been removed via deactivate. - **deactivate() → void** Called when this object is removed from the tree. - **debugFillProperties(DiagnosticPropertiesBuilder properties) → void** Add additional properties associated with the node. - **didChangeDependencies() → void** Called when a dependency of this State object changes. - **didUpdateWidget(covariant BoardView oldWidget) → void** Called whenever the widget configuration changes. - **dispose() → void** Called when this object is removed from the tree permanently. - **noSuchMethod(Invocation invocation) → dynamic** Invoked when a nonexistent method or property is accessed. - **reassemble() → void** Called whenever the application is reassembled during debugging, for example during hot reload. - **toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode** Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. - **toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String** A string representation of this object. - **toStringShort() → String** A brief description of this object, usually just the runtimeType and the hashCode. - **updateKeepAlive() → void** Ensures that any AutomaticKeepAlive ancestors are in a good state, by firing a KeepAliveNotification or triggering the KeepAliveHandle as appropriate. ``` -------------------------------- ### Initialize BoardView Source: https://pub.dev/documentation/flutter_boardview/latest/index.html Initializes a BoardView widget with a list of BoardLists and an optional BoardViewController for animations. ```dart BoardViewController boardViewController = BoardViewController(); List _lists = List(); BoardView( lists: _lists, boardViewController: boardViewController, ); ``` -------------------------------- ### BoardList Constructor Implementation Source: https://pub.dev/documentation/flutter_boardview/latest/board_list/BoardList/BoardList.html The implementation of the BoardList constructor, showing how parameters are assigned to instance variables. Used for initializing a new BoardList instance. ```dart const BoardList({ Key? key, this.header, this.items, this.footer, this.backgroundColor, this.headerBackgroundColor, this.boardView, this.draggable = true, this.index, this.onDropList, this.onTapList, this.onStartDragList, this.listBuilder, }) : super(key: key); ``` -------------------------------- ### Run Method Implementation Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState/run.html This method updates the pointer's position and rebuilds the UI. Ensure the widget is mounted before calling setState. ```dart void run() { if (pointer != null) { dx = pointer.position.dx; dy = pointer.position.dy; if (mounted) { setState(() {}); } } } ``` -------------------------------- ### initialX Property Implementation Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState/initialX.html This snippet shows the declaration and default initialization of the initialX property. ```dart double? initialX = 0; ``` -------------------------------- ### BoardItemState Constructors Source: https://pub.dev/documentation/flutter_boardview/latest/board_item/BoardItemState-class.html Initializes a new instance of the BoardItemState class. ```APIDOC ## Constructors ### BoardItemState() Initializes a new instance of the BoardItemState class. ``` -------------------------------- ### BoardList Constructor Source: https://pub.dev/documentation/flutter_boardview/latest/board_list/BoardList/BoardList.html The BoardList constructor allows for the creation of a customizable list within the board view. It accepts various parameters to define its appearance, content, and behavior, including drag-and-drop capabilities and custom list builders. ```APIDOC ## BoardList Constructor ### Description Initializes a new instance of the BoardList widget. ### Parameters - **key** (Key?) - Optional - A unique identifier for the widget. - **header** (List?) - Optional - A list of widgets to display at the top of the list. - **items** (List?) - Optional - A list of BoardItem widgets to display within the list. - **footer** (Widget?) - Optional - A widget to display at the bottom of the list. - **backgroundColor** (Color?) - Optional - The background color of the list. - **headerBackgroundColor** (Color?) - Optional - The background color of the list header. - **boardView** (BoardViewState?) - Optional - The state object for the parent BoardView. - **draggable** (bool) - Optional - Determines if the list items are draggable. Defaults to true. - **index** (int?) - Optional - The index of this list within the BoardView. - **onDropList** (OnDropList?) - Optional - Callback function invoked when an item is dropped onto this list. - **onTapList** (OnTapList?) - Optional - Callback function invoked when the list is tapped. - **onStartDragList** (OnStartDragList?) - Optional - Callback function invoked when dragging starts on a list item. - **listBuilder** (BoxScrollView Function(NullableIndexedWidgetBuilder itemBuilder)?) - Optional - A custom builder function for the scrollable list view. ``` -------------------------------- ### BoardItemState Constructor Source: https://pub.dev/documentation/flutter_boardview/latest/board_item/BoardItemState/BoardItemState.html Creates a new instance of the BoardItemState class. This is the primary way to initialize a board item's state. ```APIDOC ## BoardItemState() ### Description Constructs a new BoardItemState object. This is used to initialize the state of a board item. ### Method constructor ### Parameters None ### Response #### Success Response (Instance of BoardItemState) - Returns a new BoardItemState object with default initial values. ### Response Example ```dart final boardItemState = BoardItemState(); ``` ``` -------------------------------- ### BoardViewState Build Method Logic Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState/build.html This snippet outlines the logic within the build method of BoardViewState, handling scrolling, item movement, and positioning of dragged elements. It's crucial for the drag-and-drop interface. ```dart if (rightListX != null) { rightListX = rightListX! + 5; } } } if (widget.lists!.length > draggedListIndex! + 1 && dx! > rightListX! - 45) { //scroll right if (boardViewController.hasClients) { boardViewController.animateTo( boardViewController.position.pixels + 5, duration: const Duration(milliseconds: 10), curve: Curves.ease); if (leftListX != null) { leftListX = leftListX! - 5; } if (rightListX != null) { rightListX = rightListX! - 5; } } } if (widget.lists!.length > draggedListIndex! + 1 && dx! > rightListX!) { //move right moveListRight(); } if (0 <= draggedListIndex! - 1 && dx! < leftListX!) { //move left moveListLeft(); } } } if (widget.middleWidget != null) { stackWidgets .add(Container(key: _middleWidgetKey, child: widget.middleWidget)); } WidgetsBinding.instance.addPostFrameCallback((timeStamp) { if (mounted) { setState(() {}); } }); stackWidgets.add(Positioned( width: widget.width, height: height, left: (dx! - offsetX!) + initialX!, top: (dy! - offsetY!) + initialY!, child: Opacity(opacity: .7, child: draggedItem), )); } return Listener( onPointerMove: (opm) { if (draggedItem != null) { dxInit ??= opm.position.dx; dyInit ??= opm.position.dy; dx = opm.position.dx; dy = opm.position.dy; if (mounted) { setState(() {}); } } }, onPointerDown: (opd) { RenderBox box = context.findRenderObject() as RenderBox; Offset pos = box.localToGlobal(opd.position); offsetX = pos.dx; offsetY = pos.dy; pointer = opd; if (mounted) { setState(() {}); } }, onPointerUp: (opu) { if (onDropItem != null) { int? tempDraggedItemIndex = draggedItemIndex; int? tempDraggedListIndex = draggedListIndex; int? startDraggedItemIndex = startItemIndex; int? startDraggedListIndex = startListIndex; if (_isInWidget && widget.onDropItemInMiddleWidget != null) { onDropItem!(startDraggedListIndex, startDraggedItemIndex); widget.onDropItemInMiddleWidget( startDraggedListIndex, startDraggedItemIndex, opu.position.dx / MediaQuery.of(context).size.width); } else { onDropItem!(tempDraggedListIndex, tempDraggedItemIndex); } } if (onDropList != null) { int? tempDraggedListIndex = draggedListIndex; if (_isInWidget && widget.onDropItemInMiddleWidget != null) { onDropList!(tempDraggedListIndex); widget.onDropItemInMiddleWidget!(tempDraggedListIndex, null, opu.position.dx / MediaQuery.of(context).size.width); } else { onDropList!(tempDraggedListIndex); } } draggedItem = null; offsetX = null; offsetY = null; initialX = null; initialY = null; dx = null; dy = null; draggedItemIndex = null; draggedListIndex = null; onDropItem = null; onDropList = null; dxInit = null; dyInit = null; leftListX = null; rightListX = null; topListY = null; bottomListY = null; topItemY = null; bottomItemY = null; startListIndex = null; startItemIndex = null; if (mounted) { setState(() {}); } }, child: Stack( children: stackWidgets, )); } ``` -------------------------------- ### BoardView Constructor Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardView/BoardView.html The BoardView constructor allows for the creation of a customizable board view with various configuration options. ```APIDOC ## BoardView Constructor ### Description Initializes a new instance of the BoardView widget. ### Parameters - **key** (Key?) - Optional - A unique identifier for the widget. - **itemInMiddleWidget** (dynamic Function(bool)?) - Optional - A callback function that determines the widget to display in the middle. - **boardViewController** (BoardViewController?) - Optional - Controller for managing the board view's state. - **dragDelay** (int) - Optional - The delay in milliseconds before dragging starts. Defaults to 300. - **onDropItemInMiddleWidget** (OnDropBottomWidget?) - Optional - Callback function triggered when an item is dropped in the middle. - **isSelecting** (bool) - Optional - Flag to enable selection mode. Defaults to false. - **lists** (List?) - Optional - A list of BoardList objects to display. - **width** (double) - Optional - The width of the board view. Defaults to 280. - **middleWidget** (Widget?) - Optional - A widget to display in the middle section. - **bottomPadding** (double?) - Optional - Padding at the bottom of the board view. - **scrollController** (ScrollController?) - Optional - Controller for managing the scroll behavior. ``` -------------------------------- ### Create a BoardList Source: https://pub.dev/documentation/flutter_boardview/latest/index.html Defines a BoardList with customizable header, background colors, and drag/tap callbacks. The header expects a Row widget. ```dart BoardList( onStartDragList: (int? listIndex) { }, onTapList: (int? listIndex) async { }, onDropList: (int? listIndex, int? oldListIndex) { }, headerBackgroundColor: Color.fromARGB(255, 235, 236, 240), backgroundColor: Color.fromARGB(255, 235, 236, 240), header: [ Expanded( child: Padding( padding: EdgeInsets.all(5), child: Text( "List Item", style: TextStyle(fontSize: 20), ))), ], items: items, ); ``` -------------------------------- ### BoardItem Constructor Implementation Source: https://pub.dev/documentation/flutter_boardview/latest/board_item/BoardItem/BoardItem.html This snippet shows the Dart implementation of the BoardItem constructor, including its parameters and initialization. ```dart const BoardItem( {Key? key, this.boardList, this.item, this.index, this.onDropItem, this.onTapItem, this.onStartDragItem, this.draggable = true, this.onDragItem}) : super(key: key); ``` -------------------------------- ### BoardViewController Methods Source: https://pub.dev/documentation/flutter_boardview/latest/boardview_controller/BoardViewController-class.html Provides methods for interacting with the BoardViewController. ```APIDOC ## animateTo(int index, {Duration? duration, Curve? curve}) ### Description Animates the board view to the specified index with optional duration and curve. ### Method Instance Method ### Parameters - **index** (int) - Required - The index to animate to. - **duration** (Duration?) - Optional - The duration of the animation. - **curve** (Curve?) - Optional - The curve of the animation. ``` ```APIDOC ## noSuchMethod(Invocation invocation) ### Description Invoked when a nonexistent method or property is accessed. ### Method Instance Method (inherited) ### Parameters - **invocation** (Invocation) - Required - The invocation details. ``` ```APIDOC ## toString() ### Description Returns a string representation of this object. ### Method Instance Method (inherited) ### Returns - **String**: A string representation of the object. ``` -------------------------------- ### BoardItemState Methods Source: https://pub.dev/documentation/flutter_boardview/latest/board_item/BoardItemState-class.html Provides methods for managing the lifecycle and behavior of the BoardItemState, including build, setState, and onDropItem. ```APIDOC ## Methods ### activate() - **Returns**: void - **Description**: Called when this object is reinserted into the tree after having been removed via deactivate. ### afterFirstLayout(BuildContext context) - **Returns**: void ### build(BuildContext context) - **Returns**: Widget - **Description**: Describes the part of the user interface represented by this widget. - **Override**: Yes ### deactivate() - **Returns**: void - **Description**: Called when this object is removed from the tree. ### debugFillProperties(DiagnosticPropertiesBuilder properties) - **Returns**: void - **Description**: Add additional properties associated with the node. - **Override**: Yes ### didChangeDependencies() - **Returns**: void - **Description**: Called when a dependency of this State object changes. ### didUpdateWidget(covariant BoardItem oldWidget) - **Returns**: void - **Description**: Called whenever the widget configuration changes. ### dispose() - **Returns**: void - **Description**: Called when this object is removed from the tree permanently. ### initState() - **Returns**: void - **Description**: Called when this object is inserted into the tree. ### noSuchMethod(Invocation invocation) - **Returns**: dynamic - **Description**: Invoked when a nonexistent method or property is accessed. ### onDropItem(int? listIndex, int? itemIndex) - **Returns**: void ### reassemble() - **Returns**: void - **Description**: Called whenever the application is reassembled during debugging, for example during hot reload. ### setState(VoidCallback fn) - **Returns**: void - **Description**: Notify the framework that the internal state of this object has changed. ### toDiagnosticsNode({String? name, DiagnosticTreeStyle? style}) - **Returns**: DiagnosticsNode - **Description**: Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. ### toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) - **Returns**: String - **Description**: A string representation of this object. ### toStringShort() - **Returns**: String - **Description**: A brief description of this object, usually just the runtimeType and the hashCode. ### updateKeepAlive() - **Returns**: void - **Description**: Ensures that any AutomaticKeepAlive ancestors are in a good state, by firing a KeepAliveNotification or triggering the KeepAliveHandle as appropriate. ``` -------------------------------- ### BoardView Constructor Implementation Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardView/BoardView.html This code snippet shows the implementation of the BoardView constructor, detailing its parameters and default values. It is used when initializing a BoardView widget. ```dart const BoardView({ Key? key, this.itemInMiddleWidget, this.boardViewController, this.dragDelay = 300, this.onDropItemInMiddleWidget, this.isSelecting = false, this.lists, this.width = 280, this.middleWidget, this.bottomPadding, this.scrollController, }) : super(key: key); ``` -------------------------------- ### BoardList Methods Source: https://pub.dev/documentation/flutter_boardview/latest/board_list/BoardList-class.html Provides methods for managing the state and lifecycle of the BoardList widget. ```APIDOC ## BoardList Methods ### Description Provides methods for managing the state and lifecycle of the BoardList widget. ### Methods - **createElement() → StatefulElement**: Creates a StatefulElement to manage this widget's location in the tree. - **createState() → State**: Creates the mutable state for this widget at a given location in the tree. - **debugDescribeChildren() → List**: Returns a list of DiagnosticsNode objects describing this node's children. - **debugFillProperties(DiagnosticPropertiesBuilder properties) → void**: Add additional properties associated with the node. - **noSuchMethod(Invocation invocation) → dynamic**: Invoked when a nonexistent method or property is accessed. - **toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String**: A string representation of this object. - **toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String**: Returns a string representation of this node and its descendants. - **toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String**: Returns a one-line detailed description of the object. - **toStringShort() → String**: A short, textual description of this widget. - **toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode**: Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. ``` -------------------------------- ### Initialize listStates Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState/listStates.html Initializes the listStates property as an empty list. This is typically done when setting up the BoardViewState. ```dart List listStates = []; ``` -------------------------------- ### Implement createState for BoardViewState Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardView/createState.html This is the specific implementation of the createState method for the BoardViewState class. It returns a new instance of BoardViewState. ```dart @override State createState() { return BoardViewState(); } ``` -------------------------------- ### BoardItemState Build Method Source: https://pub.dev/documentation/flutter_boardview/latest/board_item/BoardItemState/build.html This snippet shows the build method for BoardItemState. It handles adding the item to a list of states after the first layout, manages item removal and insertion, and sets up gesture detectors for tap and long press events to enable drag functionality. ```dart @override Widget build(BuildContext context) { super.build(context); WidgetsBinding.instance .addPostFrameCallback((_) => afterFirstLayout(context)); if (widget.boardList!.itemStates.length > widget.index!) { widget.boardList!.itemStates.removeAt(widget.index!); } widget.boardList!.itemStates.insert(widget.index!, this); return GestureDetector( onTapDown: (otd) { if (widget.draggable) { RenderBox object = context.findRenderObject() as RenderBox; Offset pos = object.localToGlobal(Offset.zero); RenderBox box = widget.boardList!.context.findRenderObject() as RenderBox; Offset listPos = box.localToGlobal(Offset.zero); widget.boardList!.widget.boardView!.leftListX = listPos.dx; widget.boardList!.widget.boardView!.topListY = listPos.dy; widget.boardList!.widget.boardView!.topItemY = pos.dy; widget.boardList!.widget.boardView!.bottomItemY = pos.dy + object.size.height; widget.boardList!.widget.boardView!.bottomListY = listPos.dy + box.size.height; widget.boardList!.widget.boardView!.rightListX = listPos.dx + box.size.width; widget.boardList!.widget.boardView!.initialX = pos.dx; widget.boardList!.widget.boardView!.initialY = pos.dy; } }, onTapCancel: () {}, onTap: () { if (widget.onTapItem != null) { widget.onTapItem!(widget.boardList!.widget.index, widget.index, this); } }, onLongPress: () { if (!widget.boardList!.widget.boardView!.widget.isSelecting && widget.draggable) { _startDrag(widget, context); } }, child: widget.item, ); } ``` -------------------------------- ### startItemIndex Property Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState/startItemIndex.html The startItemIndex property is a getter/setter pair that holds an optional integer value representing the initial index of an item. This is useful for controlling the initial visible item or for programmatic manipulation of the board view's state. ```APIDOC ## startItemIndex Property ### Description An optional integer that represents the starting index of an item in the board view. This property can be both read and written to. ### Getter/Setter This property is implemented as a getter and setter pair, allowing direct manipulation of the starting item's index. ### Type `int?` ### Implementation ```dart int? startItemIndex; ``` ``` -------------------------------- ### moveLeft Method Implementation Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState/moveLeft.html This snippet shows the full implementation of the moveLeft method. It handles removing the item from the current list, finding the correct insertion point in the left list, inserting the item, and updating the UI. It also includes logic for animating the board view and updating item positions. ```dart void moveLeft() { var item = widget.lists![draggedListIndex!].items![draggedItemIndex!]; var itemState = listStates[draggedListIndex!].itemStates[draggedItemIndex!]; widget.lists![draggedListIndex!].items!.removeAt(draggedItemIndex!); listStates[draggedListIndex!].itemStates.removeAt(draggedItemIndex!); if (listStates[draggedListIndex!].mounted) { listStates[draggedListIndex!].setState(() {}); } if (draggedListIndex != null) { draggedListIndex = draggedListIndex! - 1; } double closestValue = 10000; draggedItemIndex = 0; for (int i = 0; i < listStates[draggedListIndex!].itemStates.length; i++) { if (listStates[draggedListIndex!].itemStates[i].mounted) { RenderBox box = listStates[draggedListIndex!] .itemStates[i] .context .findRenderObject() as RenderBox; Offset pos = box.localToGlobal(Offset.zero); var temp = (pos.dy - dy! + (box.size.height / 2)).abs(); if (temp < closestValue) { closestValue = temp; draggedItemIndex = i; dyInit = dy; } } } widget.lists![draggedListIndex!].items!.insert(draggedItemIndex!, item); listStates[draggedListIndex!] .itemStates .insert(draggedItemIndex!, itemState); canDrag = false; if (listStates[draggedListIndex!].mounted) { listStates[draggedListIndex!].setState(() {}); } if (boardViewController.hasClients) { int? tempListIndex = draggedListIndex; int? tempItemIndex = draggedItemIndex; boardViewController .animateTo(draggedListIndex! * widget.width, duration: const Duration(milliseconds: 400), curve: Curves.ease) .whenComplete(() { RenderBox object = listStates[tempListIndex!].context.findRenderObject() as RenderBox; Offset pos = object.localToGlobal(Offset.zero); leftListX = pos.dx; rightListX = pos.dx + object.size.width; RenderBox box = listStates[tempListIndex] .itemStates[tempItemIndex!] .context .findRenderObject() as RenderBox; Offset itemPos = box.localToGlobal(Offset.zero); topItemY = itemPos.dy; bottomItemY = itemPos.dy + box.size.height; Future.delayed(Duration(milliseconds: widget.dragDelay), () { canDrag = true; }); }); } if (mounted) { setState(() {}); } } ``` -------------------------------- ### BoardView Constructor Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardView-class.html Initializes a new instance of the BoardView widget. It allows customization of various properties like item in middle widget, drag delay, drop callbacks, selection state, lists, width, middle widget, bottom padding, and scroll controller. ```APIDOC ## BoardView Constructor ### Description Initializes a new instance of the BoardView widget. It allows customization of various properties like item in middle widget, drag delay, drop callbacks, selection state, lists, width, middle widget, bottom padding, and scroll controller. ### Parameters * **key** (Key?) - Optional - Controls how one widget replaces another widget in the tree. * **itemInMiddleWidget** (dynamic Function(bool)?) - Optional - A widget builder for the item in the middle. * **boardViewController** (BoardViewController?) - Optional - Controller for managing the BoardView state. * **dragDelay** (int) - Optional - The delay in milliseconds before a drag operation starts. Defaults to 300. * **onDropItemInMiddleWidget** (OnDropBottomWidget?) - Optional - Callback for when an item is dropped in the middle. * **isSelecting** (bool) - Optional - Whether the board view is in a selection mode. Defaults to false. * **lists** (List?) - Optional - The initial list of board lists to display. * **width** (double) - Optional - The width of each board list. Defaults to 280. * **middleWidget** (Widget?) - Optional - A widget to display in the middle of the board. * **bottomPadding** (double?) - Optional - Padding at the bottom of the board view. * **scrollController** (ScrollController?) - Optional - Controller for managing the scroll position of the board view. ``` -------------------------------- ### moveUp Method Implementation Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState/moveUp.html This snippet shows the implementation of the moveUp method. It adjusts item positions and updates the state of the list when an item is moved upwards. ```dart void moveUp() { if (topItemY != null) { topItemY = topItemY! - listStates[draggedListIndex!] .itemStates[draggedItemIndex! - 1] .height; } if (bottomItemY != null) { bottomItemY = bottomItemY! - listStates[draggedListIndex!] .itemStates[draggedItemIndex! - 1] .height; } var item = widget.lists![draggedListIndex!].items![draggedItemIndex!]; widget.lists![draggedListIndex!].items!.removeAt(draggedItemIndex!); var itemState = listStates[draggedListIndex!].itemStates[draggedItemIndex!]; listStates[draggedListIndex!].itemStates.removeAt(draggedItemIndex!); if (draggedItemIndex != null) { draggedItemIndex = draggedItemIndex! - 1; } widget.lists![draggedListIndex!].items!.insert(draggedItemIndex!, item); listStates[draggedListIndex!] .itemStates .insert(draggedItemIndex!, itemState); if (listStates[draggedListIndex!].mounted) { listStates[draggedListIndex!].setState(() {}); } } ``` -------------------------------- ### startItemIndex Property Declaration Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState/startItemIndex.html This snippet shows the declaration of the nullable integer startItemIndex property. ```dart int? startItemIndex; ``` -------------------------------- ### BoardItem Methods Source: https://pub.dev/documentation/flutter_boardview/latest/board_item/BoardItem-class.html Provides methods for managing the state and lifecycle of a BoardItem widget, including creating its element, state, and debugging information. ```APIDOC ## BoardItem Methods ### Description Provides methods for managing the state and lifecycle of a BoardItem widget, including creating its element, state, and debugging information. ### Methods - **createState() → State** Creates the mutable state for this widget at a given location in the tree. - **debugDescribeChildren() → List** Returns a list of DiagnosticsNode objects describing this node's children. - **debugFillProperties(DiagnosticPropertiesBuilder properties) → void** Add additional properties associated with the node for debugging purposes. - **noSuchMethod(Invocation invocation) → dynamic** Invoked when a nonexistent method or property is accessed. - **toDiagnosticsNode({String? name, DiagnosticTreeStyle? style}) → DiagnosticsNode** Returns a debug representation of the object that is used by debugging tools. - **toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String** A string representation of this object. - **toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String** Returns a string representation of this node and its descendants. - **toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String** Returns a one-line detailed description of the object. - **toStringShort() → String** A short, textual description of this widget. ``` -------------------------------- ### initState Implementation for BoardView Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState/initState.html This snippet shows the typical implementation of initState for a BoardView. It calls the superclass's initState, assigns the current state to a controller if provided, and initializes a scroll controller. ```dart @override void initState() { super.initState(); if (widget.boardViewController != null) { widget.boardViewController!.state = this; } boardViewController = widget.scrollController ?? ScrollController(); } ``` -------------------------------- ### Initialize BoardViewController Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState/boardViewController.html Declare and initialize the ScrollController for the boardViewController. This is typically done using a late keyword to ensure it's initialized before use. ```dart late ScrollController boardViewController; ``` -------------------------------- ### OnStartDragItem Typedef Definition Source: https://pub.dev/documentation/flutter_boardview/latest/board_item/OnStartDragItem.html Defines the signature for a callback function that is invoked when a drag operation begins on a board item. It provides the index of the list, the index of the item within the list, and the state of the board item. ```dart typedef OnStartDragItem = void Function( int? listIndex, int? itemIndex, BoardItemState state); ``` -------------------------------- ### Initialize BoardListController Source: https://pub.dev/documentation/flutter_boardview/latest/board_list/BoardListState/boardListController.html Initializes the ScrollController for boardListController. This is used to manage scrolling behavior. ```dart ScrollController boardListController = ScrollController(); ``` -------------------------------- ### dxInit Property Implementation Source: https://pub.dev/documentation/flutter_boardview/latest/flutter_boardview/BoardViewState/dxInit.html This snippet shows the basic declaration of the dxInit property as a nullable double. ```dart double? dxInit; ```