Skip to content

Instantly share code, notes, and snippets.

@AbbasHoseini
Last active December 7, 2021 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbbasHoseini/8870f8081ed700a31ab164aae6caf8f6 to your computer and use it in GitHub Desktop.
Save AbbasHoseini/8870f8081ed700a31ab164aae6caf8f6 to your computer and use it in GitHub Desktop.
کد مدیریت state- 1
class MyHomepage extends StatefulWidget {
const MyHomepage({Key? key}) : super(key: key);
@override
_MyHomepageState createState() => _MyHomepageState();
}
class _MyHomepageState extends State {
int _index = 0;
@override
Widget build(BuildContext context) {
return BottomNavigationBar(
currentIndex: _index,
onTap: (newIndex) {
setState(() {
_index = newIndex;
});
},
// ... items ...
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment