PageView is the new hotness

439 views
Skip to first unread message

Adam Barth

unread,
Feb 9, 2017, 2:15:19 AM2/9/17
to Flutter Dev
I recently landed a change that removes PageableList.  This widget has been replaced with PageView:


PageView is quite similar to PageableList but uses the same scrolling engine as GridView and ListView.

I didn't find many direct uses of PageableList.  It's mostly commonly used through TabBarView, but if you're using it in that way you don't need to do any work to migrate because I've updated TabBarView to use PageView under the covers without changing TabBarView's interface.

PageView does have a slightly different feature set than PageableList.  If you were using a feature of PageableList that isn't supported in PageView, let me know and I'll probably be able to add it for you.

(As usual, If your code is internal to Google or in fuchsia.googlesource.com, I've migrated your code for you.)

Thanks, and happy paging,
Adam

David Yu

unread,
Feb 10, 2017, 12:09:32 PM2/10/17
to Adam Barth, Flutter Dev
On Thu, Feb 9, 2017 at 3:15 PM, 'Adam Barth' via Flutter Dev <flutt...@googlegroups.com> wrote:
I recently landed a change that removes PageableList.  This widget has been replaced with PageView:


PageView is quite similar to PageableList but uses the same scrolling engine as GridView and ListView.

I didn't find many direct uses of PageableList.  It's mostly commonly used through TabBarView, but if you're using it in that way you don't need to do any work to migrate because I've updated TabBarView to use PageView under the covers without changing TabBarView's interface.

PageView does have a slightly different feature set than PageableList.  If you were using a feature of PageableList that isn't supported in PageView, let me know and I'll probably be able to add it for you.
Does the new PageView have the equivalent to PageableLazyList? (which I believe has also been removed)
I liked the horizontal-swipe paging aspect.

Widget $todo_list(BuildContext context) {
final List<Todo> todos = app.todos;
final int page = todos.length == 0 ? -1 : ((todos.length - 1) / PAGE_SIZE).floor();

return new PageableLazyList(
scrollDirection: Axis.horizontal,
itemCount: page + 1,
itemBuilder: (BuildContext context, int start, int count) {
if (start != 0 && page <= 0) return const [];

final List<Widget> list = new List<Widget>(count);
for (int i = 0; i < count; i++, start++) {
list[i] = new Block(children: newTodoItems(todos, start * PAGE_SIZE));
}

return list;
},
);
}

This is my first post in this group.
Thanks for flutter @devs.  Hot-reload is great!.

(As usual, If your code is internal to Google or in fuchsia.googlesource.com, I've migrated your code for you.)

Thanks, and happy paging,
Adam

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
When the cat is away, the mouse is alone.
- David Yu

Adam Barth

unread,
Feb 10, 2017, 12:26:19 PM2/10/17
to David Yu, Flutter Dev
On Fri, Feb 10, 2017 at 9:09 AM David Yu <david....@gmail.com> wrote:
On Thu, Feb 9, 2017 at 3:15 PM, 'Adam Barth' via Flutter Dev <flutt...@googlegroups.com> wrote:
I recently landed a change that removes PageableList.  This widget has been replaced with PageView:


PageView is quite similar to PageableList but uses the same scrolling engine as GridView and ListView.

I didn't find many direct uses of PageableList.  It's mostly commonly used through TabBarView, but if you're using it in that way you don't need to do any work to migrate because I've updated TabBarView to use PageView under the covers without changing TabBarView's interface.

PageView does have a slightly different feature set than PageableList.  If you were using a feature of PageableList that isn't supported in PageView, let me know and I'll probably be able to add it for you.
Does the new PageView have the equivalent to PageableLazyList? (which I believe has also been removed)
I liked the horizontal-swipe paging aspect.

Yes:


Sorry, I should have mentioned that explicitly.

Widget $todo_list(BuildContext context) {
final List<Todo> todos = app.todos;
final int page = todos.length == 0 ? -1 : ((todos.length - 1) / PAGE_SIZE).floor();

return new PageableLazyList(
scrollDirection: Axis.horizontal,
itemCount: page + 1,
itemBuilder: (BuildContext context, int start, int count) {
if (start != 0 && page <= 0) return const [];

final List<Widget> list = new List<Widget>(count);
for (int i = 0; i < count; i++, start++) {
list[i] = new Block(children: newTodoItems(todos, start * PAGE_SIZE));
}

return list;
},
);
}
Widget $todo_list(BuildContext context) {
  final List<Todo> todos = app.todos;
  final int page = todos.length == 0 ? -1 : ((todos.length - 1) / PAGE_SIZE).floor();

  return new PageView.builder(
    itemCount: page + 1,
    itemBuilder: (BuildContext context, int index) {
      return new Block(children: newTodoItems(todos[index], index * PAGE_SIZE));
   },
  );
}

(scrollDirection: Axis.horizontal is the default)

Adam


This is my first post in this group.
Thanks for flutter @devs.  Hot-reload is great!.

(As usual, If your code is internal to Google or in fuchsia.googlesource.com, I've migrated your code for you.)

Thanks, and happy paging,
Adam

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

David Yu

unread,
Feb 10, 2017, 12:46:07 PM2/10/17
to Adam Barth, Flutter Dev
Thanks Adam.  I shall upgrade to current version and try it. 

Adam


This is my first post in this group.
Thanks for flutter @devs.  Hot-reload is great!.

(As usual, If your code is internal to Google or in fuchsia.googlesource.com, I've migrated your code for you.)

Thanks, and happy paging,
Adam

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
When the cat is away, the mouse is alone.
- David Yu

David Yu

unread,
Feb 10, 2017, 1:38:35 PM2/10/17
to Adam Barth, Flutter Dev
Your snippet had a little typo "todos[index]" but after fixing that, it works great.
The diff is here in case it interests anyone.

Thanks again! 

Adam


This is my first post in this group.
Thanks for flutter @devs.  Hot-reload is great!.

(As usual, If your code is internal to Google or in fuchsia.googlesource.com, I've migrated your code for you.)

Thanks, and happy paging,
Adam

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
When the cat is away, the mouse is alone.
- David Yu



--
When the cat is away, the mouse is alone.
- David Yu
Reply all
Reply to author
Forward
0 new messages