Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class _ParentWidgetState extends State<MainFeedPage> with AfterLayoutMixin<MainFeedPage>{
- String empName;
- Future<List> getUserData() async{
- final response = await http.post("http://172.16.161.34:8080/ebs/cfs/android_test_app/accessfile.php?q=getUserData",body:{
- "emp_id": widget.empId,
- });
- var dataUser = jsonDecode(response.body);
- empName = dataUser[0]['name'];
- return null;
- }
- @override
- void initState() {
- super.initState();
- BackButtonInterceptor.add(myInterceptor);
- }
- @override
- void dispose() {
- BackButtonInterceptor.remove(myInterceptor);
- super.dispose();
- }
- bool myInterceptor(bool stopDefaultButtonEvent) {
- //print("BACK BUTTON!"); // Do some stuff.
- return true;
- }
- @override
- void afterFirstLayout(BuildContext context) {
- // Calling the same function "after layout" to resolve the issue.
- getUserData();
- }
- @override
- Widget build(BuildContext context) {
- // TODO: implement build
- return new MaterialApp(
- title: 'ALTURAS TEST APP',
- debugShowCheckedModeBanner: false,
- color: Colors.white,
- home: DefaultTabController(
- length: 3,
- child: new Scaffold(
- appBar: AppBar(
- iconTheme: new IconThemeData(color: Colors.black ),
- textTheme: TextTheme(
- title: TextStyle(
- color: Colors.black,
- )
- ),
- title: Text(empName),
- backgroundColor: Colors.white,
- actions: <Widget>[
- IconButton(icon: Icon(Icons.shopping_cart),onPressed:(){
- getUserData();
- },),
- IconButton(icon: Icon(Icons.person),onPressed:(){},),
- ],
- elevation: 0.0,
- ),
- drawer: Drawer(
- child: ListView(
- // Important: Remove any padding from the ListView.
- padding: EdgeInsets.zero,
- children: <Widget>[
- DrawerHeader(
- child: Text(''),
- decoration: BoxDecoration(
- color: Colors.white,
- ),
- ),
- ListTile(
- title: Text('Item 1'),
- onTap: () {
- // Update the state of the app
- // ...
- },
- ),
- ListTile(
- title: Text('Item 2'),
- onTap: () {
- // Update the state of the app
- // ...
- },
- ),
- ],
- ),
- ),
- body: new TabBarView(
- physics: NeverScrollableScrollPhysics(),
- children :<Widget>[
- new Screen1(),
- new Screen2(),
- new Screen3()
- ],
- ),
- bottomNavigationBar: new TabBar(
- tabs: [
- Tab(
- text: "Home",
- icon: new Icon(Icons.home,),
- ),
- Tab(
- text: "Profile",
- icon: new Icon(Icons.perm_identity),
- ),
- Tab(
- text: "Settings",
- icon: new Icon(Icons.settings),
- )
- ],
- labelStyle: TextStyle(fontSize: 12.0),
- labelColor: Colors.black,
- unselectedLabelColor: Colors.black38,
- indicatorSize: TabBarIndicatorSize.label,
- indicatorPadding: EdgeInsets.all(1.0),
- indicatorColor: Colors.black,
- ),
- backgroundColor: Colors.white,
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement