0

in my application user can be register and my application can save user information with sqlite, each registered user can be verify his mobile number with sms and user can active his account on application by userActive item on database

now, i have some list of items witch that created by class:

  final List<DashboardItems> dashboardItems = [
    DashboardItems(menuItem: MenuItems.dashboard, title: Strings.drawerItemHome, icon: 'assets/icons/home.png', forActiveUser: false),
    DashboardItems(menuItem: MenuItems.healthProfile, title: Strings.drawerItemProfile, icon: 'assets/icons/cannabis.png', forActiveUser: true),
  ];

in application and there are some items for registered user and who active account by sms, in DashboardItems class this field is forActiveUser

for example suppose i have simple Container, who can i colorize white that for active users?

with below code i should be have one white container as MenuItems.dashboard and one gray container as MenuItems.healthProfile.

but i have two white container

decoration: BoxDecoration(
    color:
          user != null && user.userActive == 1 ? Colors.white :
          user == null || (user != null && user.userActive == 0) || !item.forActiveUser ? Colors.white :
    Colors.grey,
        borderRadius: BorderRadius.all(Radius.circular(5.0)), 
    boxShadow: [
      BoxShadow(
        blurRadius: 0.5,
        color: Colors.black,
        offset: Offset(0.0, 0.0),
      )
    ]),

UPDATED:

container should be white when:

`user!=null` and `user.userActive`==1   <-- all containers should be white

otherwise:

`user` is `null` && `user!=null and user.userActive==0` <-- containers should be gray when `forActiveUser` is true

1 Answer 1

1

If I understand you right - the condition should be like this:


decoration: BoxDecoration(
    color: (user != null
           && user.userActive == 1) || !item.forActiveUsers ? Colors.white : Colors.grey,
    borderRadius: BorderRadius.all(Radius.circular(5.0)), 
    boxShadow: [
      BoxShadow(
        blurRadius: 0.5,
        color: Colors.black,
        offset: Offset(0.0, 0.0),
      )
    ]),

UPDATED

Sign up to request clarification or add additional context in comments.

1 Comment

Updated my answer. Any active user will have all the menus white and any menu that is not for an active user will also be white.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.