简体   繁体   中英

How to the Listview can scroll both Horizontal and Vertical in Flutter

I have Listview just scroll Horizontal or Vertical. So how the Listview can scroll both Horizontal and Vertical in Flutter?

Widget build(BuildContext context) {
return Scaffold(
    resizeToAvoidBottomInset: false, // set it to false
    appBar: AppBar(
      title: Text("List Machine"),
      centerTitle: true,
    ),
    body: ListView(
      scrollDirection: Axis.horizontal,
        children: [_createDataTable()]));
}

wrap the list view with ScrollBar

scrollbar

To scroll listview in vertical and horizontal you have to define scroll direction.

Widget build(BuildContext context) {
return Scaffold(
    appBar: AppBar(
      title: Text("List Machine"),
      centerTitle: true,
    ),
    body: ListView(
      scrollDirection: Axis.horizontal ,
        children:[],
}

You can use Axis.horizontal attribute and Axis.vertical

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM