Would it be possible to use the PageView
widget just for the contents within Expanded
widget in the code below? Essentially trying to swipe right for the items only within the Expanded
widget instead of the entire screen.
class _MyHomeScreenState extends State<MyHomeScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Column(
children: [
Container(),
Container(),
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
Container(),
Container(),
ListView.builder(itemBuilder: itemBuilder),
],
),
),
),
],
),
);
}
}
By doing this code below using the PageView
widget, I get this error 'Horizontal viewport was given unbounded height'.
class _MyHomeScreenState extends State<MyHomeScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Column(
children: [
Container(),
Container(),
PageView(
children: [
Container(
child: Expanded(
child: SingleChildScrollView(
child: Column(
children: [
Container(),
Container(),
ListView.builder(itemBuilder: itemBuilder),
],
),
),
),
),
Container(),
],
),
],
),
);
}
}
CodePudding user response:
You should wrap the pageview inside expanded. you are using an expanded inside pageview
This should fix the issue