横向的包一层container,指定高度;
纵向的用Flexible包裹起来;
这两个listview放在一个Column里面就可以了;
import 'package:flutter/material.dart';
void main()=>runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(''),),
body: Column(
children: <Widget>[
Container(
height: 28,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 100,
itemBuilder: (context, index) {
return Card(
child: Text('$index'),
);
}),
),
Flexible(
child: ListView.builder(
scrollDirection: Axis.vertical,
itemCount: 100,
itemBuilder: (context, index) {
return Card(
child: Text('$index'),
);
}),
),
],
),
);
}
}