flutter divider: How could i add divider between each line in my code?

前端 未结 7 1375
野趣味
野趣味 2020-12-02 12:00

How could i add divider to list? I use flatter for android. I want to add a divider between each line and I want to colorize the divider and add styles.

I tried to

7条回答
  •  天涯浪人
    2020-12-02 12:41

    On the flutter getting started tutorial it is covered, the solution they provide is something like this:

      body: ListView.builder(
        itemCount: _kittens.length,
        itemExtent: 60.0,
        itemBuilder: (context, i) {
            // Add a one-pixel-high divider widget before each row in theListView.
            if (i.isOdd) return new Divider(color: Colors.purple); // notice color is added to style divider
    
            return _listItemBuilder();
          },
      ),
      ...
    

    That should add the dividers taking into account the odd and even rows to do so.

    Also to color the divider pas "color" to the Divider Class:

    new Divider(color: Colors.purple);
    

提交回复
热议问题