I’m using the Scaffold’s bottomSheet property to permanently display a DraggableScrollableSheet however it goes beyond the status bar and wrapping it with SafeArea doesn’t seem to solve my problem. I also tried to get statusbar / bottom navigationbar height so that I can deduct them manually but they always return 0.
Similar issues were all fixed with showBottomSheet()’s safe area property but in my case I don’t use a function I use the property of scaffold to display it. Are there any workaround for this or am I missing something? I’m on stable channel 3.16.5
class DraggableProblem extends StatelessWidget {
const DraggableProblem({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
bottomSheet: SafeArea(
key: ValueKey('IM NOT WORKING'),//NOT WORKING
child: DraggableScrollableSheet(
initialChildSize: 1,
minChildSize: 0.1,
shouldCloseOnMinExtent: false,
snapSizes: const [0.1, 1],
expand: false,
snap: true,
builder: (context, controller) {
return Container(
color: Colors.red,
child: ListView.builder(
controller: controller,
itemBuilder: (context, index) {
return ListTile(
title: Text('Item $index'),
);
},
),
);
}),
),
bottomNavigationBar: BottomNavigationBar(
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(icon: Icon(Icons.person), label: 'Profile'),
],
),
);
}
}
2
Answers
Problem is [AppBar] because if you’re not using [AppBar], [SafeArea] will not work properly.
Try using Stack widget to overlay the DraggableScrollableSheet on top of the Scaffold and manually handle the safe area.