我有一个多层用户应用程序,在其中实现了基于角色的小部件,例如:
final user=Provider.of<UserNotifier>(context).getRole(); //returns role string
(user=="Admin")?SomeWidget():Container(),
还有另一种选择,例如:
Visibility (
visible: (user=="Admin"),
child: SomeWidget()
),
在这两种方法中,哪种是最好的选择?