Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

side menu not showing after logout. #31

Closed
Ahtsham0715 opened this issue Oct 25, 2022 · 14 comments
Closed

side menu not showing after logout. #31

Ahtsham0715 opened this issue Oct 25, 2022 · 14 comments
Labels
bug Something isn't working

Comments

@Ahtsham0715
Copy link

Ahtsham0715 commented Oct 25, 2022

side menu not showing after logout and then login again, but when I restart the app it shows correctly but then not navigating between different pages.
I there is something not disposing and build only on app startup.
it should be built on page startup like when build method called or something like that

@Jamalianpour
Copy link
Owner

This is a known issue but currently I have no idea why this problem happen.

@Jamalianpour Jamalianpour added bug Something isn't working help wanted Extra attention is needed labels Oct 25, 2022
@Ahtsham0715
Copy link
Author

can you solve this issue please?
I need this in 1 or 2 days
otherwise I have to rewrite code for this design.

@Ahtsham0715
Copy link
Author

is there something static in the code of plugin?

Jamalianpour added a commit that referenced this issue Oct 26, 2022
@Jamalianpour Jamalianpour removed the help wanted Extra attention is needed label Oct 26, 2022
@Ahtsham0715
Copy link
Author

facing same issue after upgrading package too

@Jamalianpour
Copy link
Owner

Jamalianpour commented Oct 26, 2022

Package dose not update on pub.dev yet
You should use mater branch

easy_sidemenu:
  git:
    url: https://github.com/Jamalianpour/easy_sidemenu.git
    ref: master

Don't forget read example first because Navigation system and onTap has been changed.

@Ahtsham0715
Copy link
Author

okay thanks

@Ahtsham0715
Copy link
Author

It has same issue again.
I followed the latest method from example code but issue is remain the same.

@Ahtsham0715 Ahtsham0715 reopened this Oct 27, 2022
@Jamalianpour
Copy link
Owner

I can not do any things without code
Please send me your code to check that

@Ahtsham0715
Copy link
Author

import 'package:easy_sidemenu/easy_sidemenu.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';
import 'package:music_app/auth/login_ui.dart';
import 'package:music_app/constants.dart';
import 'package:music_app/custom%20widgets/custom_formfield.dart';
import 'package:music_app/custom%20widgets/utils.dart';
import 'package:music_app/music%20pages/dashboard_ui.dart';
import 'package:music_app/music%20pages/category_ui.dart';
import 'package:music_app/music%20pages/downloads_ui.dart';
import 'package:music_app/music%20pages/playlist_ui.dart';
import 'package:music_app/music%20pages/profile_ui.dart';
import 'package:music_app/player/music_player_ui.dart';

class MainWidget extends StatefulWidget {
const MainWidget({super.key});

@OverRide
State createState() => _MainWidgetState();
}

class _MainWidgetState extends State {
final PageController page = PageController(initialPage: 0);
final TextEditingController _search = TextEditingController();
static SideMenuController sidecontroller = SideMenuController();

List pages = [
const CategoriesUi(),
PlaylistUi(items: const {
'category_name': 'Category ',
'items_list': [
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQjSzVO5ZPeF-f5kucYJG1doKpXiPiooQfHKq0Rev-iVtpZE6zIPp9ylmrHabLcZpwk2gs&usqp=CAU',
'https://i1.sndcdn.com/avatars-000528843336-cug73s-t500x500.jpg',
'https://www.musicgrotto.com/wp-content/uploads/2021/09/best-songs-of-all-time-graphic-art.jpg',
'https://i.ytimg.com/vi/vBGUB1dWfRg/maxresdefault.jpg',
'https://i.ytimg.com/vi/wZl3j0I0fiA/maxresdefault.jpg',
'https://i.ytimg.com/vi/-hg7ILmqadg/maxresdefault.jpg',
'https://www.nettv4u.com/uploads/18-06-2019/top-10-indian-music-directors.jpg',
],
}),
DownloadUi(items: const {
'category_name': 'Category ',
'items_list': [
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQjSzVO5ZPeF-f5kucYJG1doKpXiPiooQfHKq0Rev-iVtpZE6zIPp9ylmrHabLcZpwk2gs&usqp=CAU',
'https://i1.sndcdn.com/avatars-000528843336-cug73s-t500x500.jpg',
'https://www.musicgrotto.com/wp-content/uploads/2021/09/best-songs-of-all-time-graphic-art.jpg',
'https://i.ytimg.com/vi/vBGUB1dWfRg/maxresdefault.jpg',
'https://i.ytimg.com/vi/wZl3j0I0fiA/maxresdefault.jpg',
'https://i.ytimg.com/vi/-hg7ILmqadg/maxresdefault.jpg',
'https://www.nettv4u.com/uploads/18-06-2019/top-10-indian-music-directors.jpg',
],
}),
const ProfileUi(),
const ProfileUi(),
];

List items = [
SideMenuItem(
// Priority of item to show on SideMenu, lower value is displayed at the top
priority: 0,
title: 'Dashboard',
onTap: (page, _) => sidecontroller.changePage(page),
icon: const Icon(
Icons.dashboard,
size: 25.0,
),
),
SideMenuItem(
// Priority of item to show on SideMenu, lower value is displayed at the top
priority: 1,
title: 'Playlist',
onTap: (page, _) => sidecontroller.changePage(page),
icon: const Icon(
Icons.playlist_play,
size: 25.0,
),
),
SideMenuItem(
// Priority of item to show on SideMenu, lower value is displayed at the top
priority: 2,
title: 'Downloads',
onTap: (page, _) => sidecontroller.changePage(page),
icon: const Icon(
Icons.download,
size: 25.0,
),
),
SideMenuItem(
priority: 3,
title: 'Browse & Play',
onTap: (page, _) async {
await filepicker(filetype: FileType.audio).then((filepath) {
print(filepath);
playerbox.write('isplaying', false);
Get.to(() => const MusicPlayerUi(), arguments: {
'isAsset': true,
'filepath': filepath.path.toString(),
});
});
},
icon: const Icon(Icons.browse_gallery_outlined),
),
SideMenuItem(
priority: 4,
title: 'My Account',
onTap: (page, _) => sidecontroller.changePage(page),
icon: const Icon(Icons.account_circle_outlined),
),
SideMenuItem(
priority: 5,
title: 'Logout',
onTap: (page, _) {
print('logged out');
// Get.to(
// () => const LoginUi(),
// );
customYesNoDialog(
titletext: 'Are you sure?',
contenttext: 'Do you want to logout?',
yesOnTap: () {
loginbox.write('islogin', false);
// sidecontroller.dispose();
Get.to(
() => const LoginUi(),
// preventDuplicates: true,
);
});

    // page.keepPage;
  },
  icon: const Icon(Icons.logout_outlined),
),

];

List categories = [
'Pop',
'Rock',
'Hip Hop',
'Classical',
'Jazz',
'Disco',
'Electronic',
'Traditional',
'Mixed Genre',
];

@OverRide
void initState() {
print('building state');
sidecontroller.addListener((p0) {
page.jumpToPage(p0);
});
super.initState();
}

@OverRide
Widget build(BuildContext context) {
print('build');
return Scaffold(
backgroundColor: Colors.grey.shade100.withOpacity(1.0),
appBar: AppBar(
automaticallyImplyLeading: false,
elevation: 0.0,
leadingWidth: 180.0,
centerTitle: true,
backgroundColor: Colors.transparent,
toolbarHeight: 50.0,
leading: Center(
child: Text(
'InshopMedia Player',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 18.0,
color: Colors.black,
fontFamily: font_family,
),
),
),
title: SizedBox(
height: 50,
width: MediaQuery.of(context).size.width * 0.4,
child: customsearchField(
"Search",
_search,
(value) {},
(value) {
_search.text = value!;
},
responsiveHW(context, wd: 100),
responsiveHW(context, ht: 100),
OutlineInputBorder(
borderRadius: BorderRadius.circular(50.0),
borderSide: const BorderSide(
style: BorderStyle.none,
color: Colors.white,
),
),
),
),
actions: [
Center(
child: Text(
'Shami',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 18.0,
fontFamily: font_family,
color: Colors.black,
),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: CircleAvatar(
backgroundColor: Colors.grey.shade300,
// radius: 40.0,
// foregroundImage: NetworkImage(
// 'https://w7.pngwing.com/pngs/831/88/png-transparent-user-profile-computer-icons-user-interface-mystique-miscellaneous-user-interface-design-smile.png',
// ),
child: const Icon(
Icons.person,
color: Colors.black45,
),
),
),
],
),
body: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SideMenu(
style: SideMenuStyle(
// backgroundColor: Colors.grey,
openSideMenuWidth: 200.0,
selectedColor: Colors.grey.shade200.withOpacity(0.9),
hoverColor: Colors.grey.shade200.withOpacity(0.9),
),
// Page controller to manage a PageView
controller: sidecontroller,
// Will shows on top of all items, it can be a logo or a Title text
title: Container(
margin: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.shade300.withOpacity(0.8),
spreadRadius: 3,
blurRadius: 5,
offset: const Offset(0, 3), // changes position of shadow
),
],
borderRadius: BorderRadius.circular(10.0),
color: Colors.grey.shade100.withOpacity(1.0)),
height: MediaQuery.of(context).size.height * 0.4,
// width: MediaQuery.of(context).size.width * 0.5,
child: ListView.builder(
padding: const EdgeInsets.all(5.0),
itemCount: categories.length,
itemBuilder: ((context, index) {
return ListTile(
onLongPress: (() {}),
onTap: () {
// print('pressed');
Get.to(() => CategoryUi(), arguments: {
'category_name': '${categories[index]}',
'items_list': [
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQjSzVO5ZPeF-f5kucYJG1doKpXiPiooQfHKq0Rev-iVtpZE6zIPp9ylmrHabLcZpwk2gs&usqp=CAU',
'https://i1.sndcdn.com/avatars-000528843336-cug73s-t500x500.jpg',
'https://www.musicgrotto.com/wp-content/uploads/2021/09/best-songs-of-all-time-graphic-art.jpg',
'https://i.ytimg.com/vi/vBGUB1dWfRg/maxresdefault.jpg',
'https://i.ytimg.com/vi/wZl3j0I0fiA/maxresdefault.jpg',
'https://i.ytimg.com/vi/-hg7ILmqadg/maxresdefault.jpg',
'https://www.nettv4u.com/uploads/18-06-2019/top-10-indian-music-directors.jpg',
],
});
},
hoverColor: Colors.grey.shade300,
tileColor: Colors.grey.shade100.withOpacity(1.0),
title: Text(
'${categories[index]}',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 18.0,
fontFamily: font_family,
),
),
);
}),
),
),
showToggle: true,

        items: items,
      ),
      Expanded(
        child: PageView.builder(
          itemBuilder: (context, index) {
            return pages[index];
          },
          controller: page,
        ),
      ),
    ],
  ),
);

}
}

theodornk added a commit to theodornk/easy_sidemenu that referenced this issue Nov 21, 2022
@AyberkAhmet
Copy link

AyberkAhmet commented Jan 26, 2023

I have same problem. I updated 0.4.1.1+1 version because of Badge Error. I have 7 different page with SideMenu. When I open a page with SideMenu, it shows the SideMenu at the first time. But when I enter any page with SideMenu for the 2nd time, SideMenu does not appear.

@AyberkAhmet
Copy link

SideMenu is one of the pages I use:

class _MyProfilePageState extends State<MyProfilePage> {
  WorkerModel? _worker;
  int workerID = 0;

  final GlobalKey<FormState> _formKey = GlobalKey<FormState>();

  PageController page = PageController();
  SideMenuController sideMenuController = SideMenuController();

  @override
  void initState() {
    sideMenuController.addListener((p0) {
      page.jumpToPage(p0);
    });
    super.initState();
  }

  @override
  void dispose() {
    page.dispose();
    sideMenuController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    final authViewModel = Provider.of<AuthViewModel>(context);
    final workerViewModel = Provider.of<WorkerViewModel>(context);

    workerID = authViewModel.currentWorkerID!;

    return Scaffold(
      appBar: AppBar(),
      body: FutureBuilder(
          future: Future.wait([
            workerViewModel.getWorkerByID(workerID).then((value) => _worker = value),
          ]),
          builder: (context, snapshot) {
            if (snapshot.hasData) {
              return Row(
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
                  SideMenu(
                    controller: sideMenuController,
                    style: StyleConstants.sideMenuStyle,
                    title: const SideMenuHeader(),
                    //footer: const SideMenuFooter(),
                    items: getSideMenuItems(),
                  ),
                  Expanded(
                    child: PageView(
                      controller: page,
                      children: [WorkerProfilePage(_worker!), WorkerTimesheetPage(_worker!), const JobTrackingCalendarPage()],
                    ),
                  ),
                ],
              );
            } else {
              return const CenteredCircularProgressIndicator();
            }
          }),
    );
  }
 // get side menu items
  List<SideMenuItem> getSideMenuItems() {
    return [
      SideMenuItem(
        priority: 0,
        title: 'Profile',
        onTap: (page, _) {
          sideMenuController.changePage(0);
        },
        icon: const Icon(Icons.dashboard),
      ),
      SideMenuItem(
        priority: 1,
        title: 'Arbeitzeiten und Pausen',
        onTap: (page, _) {
          sideMenuController.changePage(page);
        },
        icon: const Icon(Icons.note_alt_rounded),
      ),
      SideMenuItem(
        priority: 2,
        title: 'Dokumentation der Arbeitszeit',
        onTap: (page, _) {
          sideMenuController.changePage(page);
        },
        icon: const Icon(Icons.pattern_rounded),
      ),
    ];
  }
}

@rojicp
Copy link

rojicp commented Mar 17, 2023

I had the same issue, I have checked the code locally, and found _widthSize function on class SideMenu is returning width as Zero for some reason, this is the reason Side Menu is not visible some times.

@sadik5397
Copy link

@Jamalianpour
Here is the solution:
Caution: You must edit the package file to solve this bug temporarily.

  1. Open .../easy_sidemenu-<version>/lib/src/side_menu.dart
  2. Replace the _widthSize function with this code snippet:
double _widthSize(SideMenuDisplayMode mode, BuildContext context) {
  if (mode == SideMenuDisplayMode.auto) {
    if (MediaQuery.of(context).size.width > collapseWidth &&
        Global.displayModeState.value != SideMenuDisplayMode.open) {
      Global.displayModeState.change(SideMenuDisplayMode.open);
      _notifyParent();
      Future.delayed(_toggleDuration(), () {
        Global.showTrailing = true;
        for (var update in Global.itemsUpdate) {
          update();
        }
      });
      return Global.style.openSideMenuWidth ?? 300;
    }
    if (MediaQuery.of(context).size.width <= collapseWidth &&
        Global.displayModeState.value != SideMenuDisplayMode.compact) {
      Global.displayModeState.change(SideMenuDisplayMode.compact);
      _notifyParent();
      Global.showTrailing = false;
      return Global.style.compactSideMenuWidth ?? 50;
    }
    return _currentWidth;
  } else
  if (mode == SideMenuDisplayMode.open) return 250;
  if (mode == SideMenuDisplayMode.compact) return 66;
}

You can change the value 250 and 66 as your need....

### DONE!

@aditya113141
Copy link
Contributor

@Jamalianpour Here is the solution: Caution: You must edit the package file to solve this bug temporarily.

  1. Open .../easy_sidemenu-<version>/lib/src/side_menu.dart
  2. Replace the _widthSize function with this code snippet:
double _widthSize(SideMenuDisplayMode mode, BuildContext context) {
  if (mode == SideMenuDisplayMode.auto) {
    if (MediaQuery.of(context).size.width > collapseWidth &&
        Global.displayModeState.value != SideMenuDisplayMode.open) {
      Global.displayModeState.change(SideMenuDisplayMode.open);
      _notifyParent();
      Future.delayed(_toggleDuration(), () {
        Global.showTrailing = true;
        for (var update in Global.itemsUpdate) {
          update();
        }
      });
      return Global.style.openSideMenuWidth ?? 300;
    }
    if (MediaQuery.of(context).size.width <= collapseWidth &&
        Global.displayModeState.value != SideMenuDisplayMode.compact) {
      Global.displayModeState.change(SideMenuDisplayMode.compact);
      _notifyParent();
      Global.showTrailing = false;
      return Global.style.compactSideMenuWidth ?? 50;
    }
    return _currentWidth;
  } else
  if (mode == SideMenuDisplayMode.open) return 250;
  if (mode == SideMenuDisplayMode.compact) return 66;
}

You can change the value 250 and 66 as your need....

### DONE!

@sadik5397 Your code is written in way that it can return null values. Maybe you can remove the last if condition and simply write return 66. The logic won't change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants