-
-
Save sbis04/bf34764efa3ba8f86e254b9caebcac10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomeViewLarge extends StatefulWidget { | |
final int currentIndex; | |
/// Callback function | |
final Function(int selectedIndex) onTapped; | |
HomeViewLarge(this.currentIndex, this.onTapped); | |
@override | |
_HomeViewLargeState createState() => _HomeViewLargeState(); | |
} | |
class _HomeViewLargeState extends State<HomeViewLarge> { | |
int _index = 0; | |
@override | |
void initState() { | |
super.initState(); | |
_index = widget.currentIndex; | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
child: Row( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
mainAxisAlignment: MainAxisAlignment.start, | |
children: [ | |
Expanded( | |
flex: 2, | |
child: MenuWidget( | |
selectedIndex: _index, | |
onTapped: (selectedIndex) { | |
setState(() { | |
_index = selectedIndex; | |
// Invoking the callback | |
widget.onTapped(_index); | |
}); | |
}, | |
), | |
), | |
// ... | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment