Last active
March 7, 2020 09:42
-
-
Save iamEtornam/1a8469f417d7b4f6a901c117955d3a35 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
//add to pubspec: material_segmented_control: ^2.0.9 | |
import 'package:flutter/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/rendering.dart'; | |
import 'package:flutter_icons/flutter_icons.dart'; | |
import 'package:material_segmented_control/material_segmented_control.dart'; | |
class TeamDashboardPage extends StatefulWidget { | |
@override | |
_TeamDashboardPageState createState() => _TeamDashboardPageState(); | |
} | |
class _TeamDashboardPageState extends State<TeamDashboardPage> { | |
int sharedValue; | |
final Map<int, Widget> headerWidgets = const <int, Widget>{ | |
0: Text('Page One'), | |
1: Text('Page Two'), | |
}; | |
List<Widget> _children = [ | |
PageOne(), | |
PageTwo(), | |
]; | |
@override | |
void initState() { | |
sharedValue = 0; | |
super.initState(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text( | |
'Tabs', | |
style: TextStyle(color: fromHex('#019BA3')), | |
), | |
), | |
body: Column( | |
children: <Widget>[ | |
Container( | |
width: MediaQuery.of(context).size.width, | |
child: MaterialSegmentedControl( | |
children: headerWidgets, | |
selectionIndex: sharedValue, | |
borderColor: Colors.red, | |
selectedColor: Colors.red, | |
unselectedColor: Colors.white, | |
borderRadius: 8.0, | |
onSegmentChosen: (index) { | |
setState(() { | |
sharedValue = index; | |
}); | |
}, | |
), | |
), | |
Expanded( | |
child: _children[sharedValue], | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment