I am trying to learn how to design a sidebar and I found this image online. I have successfully developed a simple side bar but am not able to design exactly like this. As I am new to Flutter I don't know how to add this curve shape and animate when tapped. This is where I need your help.
This what I've done so far:
class HomeScreen extends StatefulWidget {
const HomeScreen({Key key}) : super(key: key);
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
int _selectedIndex = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
'Home',
style: TextStyle(color: Colors.white),
),
backgroundColor: Colors.red.withOpacity(0.3),
),
backgroundColor: Colors.red.withOpacity(0.3),
body: Row(
children: [
sideBar(),
],
),
);
}
Widget sideBar() {
final List<String> items = ['Snacks', 'Drinks', 'Food'];
return Container(
color: Colors.white,
child: Column(
children: items
.map((e) => Padding(
padding: const EdgeInsets.all(14.0),
child: GestureDetector(
onTap: () {
setState(() {
_selectedIndex = items.indexOf(e);
});
},
child: Row(
children: [
RotatedBox(quarterTurns: 3, child: Text(e)),
if (items.indexOf(e) == _selectedIndex)
const Padding(
padding: EdgeInsets.only(left: 8.0),
child: CircleAvatar(
backgroundColor: Colors.deepOrange,
radius: 5.0,
),
)
],
),
),
))
.toList(),
),
);
}
}
Here is the output: