Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when moving items from one list to another untill is empty and then adding back #2

Closed
daybson opened this issue Mar 6, 2020 · 1 comment

Comments

@daybson
Copy link

daybson commented Mar 6, 2020

My two lists are initialized with 2 itens.
I move all from the first list to second one.
Then, I try to add an item of the second list to the first list.

Throws the exception:
RangeError (index): Invalid value: Valid value range is empty: 1

Edit: I've made a small overloading on constructor of BoardView to support a custom width instead the default value.

My full code:

import 'package:boardview/board_item.dart';
import 'package:boardview/board_list.dart';
import 'package:boardview/boardview.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class MyExample extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return MyExampleState();
  }
}

class MyExampleState extends State<MyExample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            Expanded(
                child: BoardView(
              lists: _get() + _get(), width: 150,
            )),
          ]),
    );
  }

  List<BoardList> _get() {
    var boardItem0 = BoardItem(
        item: Container(
            height: 20,
            color: Colors.indigo[100],
            child: Text(
              'ABC',
              style: TextStyle(fontSize: 12),
            )));
    var boardItem1 = BoardItem(
        item: Container(
            height: 20,
            color: Colors.purple[100],
            child: Text(
              '123',
              style: TextStyle(fontSize: 12),
            )));

    var listBoardItems = List<BoardItem>();
    listBoardItems.add(boardItem0);
    listBoardItems.add(boardItem1);

    var boardList = BoardList(
        headerBackgroundColor: Colors.green,
        header: Container(
          height: 50,
          color: Colors.blue,
        ),
        items: listBoardItems,
        footer: Container(
          height: 50,
          color: Colors.red,
        ));

    var listBoardListItems = List<BoardList>();
    listBoardListItems.add(boardList);

    return (listBoardListItems);
  }
}

Gif attached:

untitled

@jakebonk
Copy link
Owner

jakebonk commented Mar 7, 2020

I just updated the version to 0.0.5 so upgrade it and it should fix the error. In this version I changed the header parameter in BoardList to a List instead of a Widget so you can just wrap it in an array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants