0
votes

I'm right-dominant, but a close friend is left-dominant. He always complains about apps being developed for right-handed people, so while developing my apps I want to give lefties the option.

My method works, but it feels wordy and inelegant. Here's what I'm doing:

String userDominantHand = 'right';
    
Scaffold (
    endDrawer: userDominantHand == 'left' ? Drawer(...) : null,
    drawer: userDominantHand == 'right' ? Drawer(...) : null,
)

A toggle in the settings switches from 'right' to 'left'. I can't think of a better way to achieve this, since drawer and endDrawer are separated in Scaffold().

Flutter docs say to use TextDirection.rtl and TextDirection.ltr, but I can't figure out where to put that to move the drawer. Wrapping it in a Directionality() widget didn't work.

Is there something I'm missing? A better way to achieve this functionality?

1

1 Answers

0
votes

If this is only for a page and it is working, there is no problem in my opinion, now if you need to use this in many screens and widgets you could create a class with two values bool right; bool left;, after initializing it you could access everywhere like UserDominantHand.left ? Drawer() : null.