ModBaseLayoutController class
Controller para gerenciamento dinâmico do estado do ModBaseLayout.
Similar ao funcionamento de um TextEditingController para TextField, este controller permite a manipulação programática e reativa dos dados do layout, possibilitando atualizações em tempo real sem necessidade de navegação.
Exemplo básico:
// Criação do controller
final layoutController = ModBaseLayoutController(
claims: ['admin', 'user:read'],
menuGroups: myMenuGroups,
userProfile: UserProfile(userName: 'João'),
);
// Uso no ModBaseLayout
ModBaseLayout(
title: 'Minha App',
body: HomePage(),
controller: layoutController,
)
// Atualização dinâmica dos dados
layoutController.updateClaims(['admin', 'user:read', 'user:write']);
layoutController.updateUserProfile(UserProfile(userName: 'Maria'));
Integração com GetController:
class MyController extends GetxController {
late final ModBaseLayoutController layoutController;
@override
void onInit() {
super.onInit();
layoutController = ModBaseLayoutController(
claims: [],
menuGroups: [],
);
}
void onUserLogin(User user) {
layoutController.updateClaims(user.permissions);
layoutController.updateUserProfile(
UserProfile(userName: user.name, userEmail: user.email),
);
layoutController.updateMenuGroups(buildMenuForUser(user));
}
@override
void onClose() {
layoutController.dispose();
super.onClose();
}
}
- Inheritance
-
- Object
- ChangeNotifier
- ModBaseLayoutController
Constructors
-
ModBaseLayoutController({List<
String> ? claims, List<ModuleMenu> ? moduleMenuGroups, UserProfile? userProfile, List<Widget> ? appBarActions, Widget? sidebarHeader, Widget? drawerHeader, ChatbotConfig? chatbotConfig, Widget? logo, String? title}) - Cria um novo ModBaseLayoutController com valores iniciais opcionais.
Properties
-
appBarActions
→ List<
Widget> ? -
Retorna as ações do AppBar atuais
no setter
- chatbotConfig → ChatbotConfig?
-
Retorna a configuração do chatbot atual
no setter
-
claims
→ List<
String> ? -
Retorna a lista atual de claims
no setter
- drawerHeader → Widget?
-
Retorna o header do drawer atual
no setter
-
Retorna o footer atual
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- logo → Widget?
-
Retorna o logo atual
no setter
-
Retorna os grupos de menu atuais
no setter
-
moduleMenuGroups
→ List<
ModuleMenu> ? -
Retorna os módulos de menu atuais
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
Retorna o footer do sidebar atual
no setter
-
Retorna o header do sidebar atual
no setter
- title → String?
-
Retorna o título atual
no setter
- userProfile → UserProfile?
-
Retorna o perfil do usuário atual
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
clear(
) → void - Limpa todos os dados do controller e notifica os listeners.
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
refresh(
) → void - Força uma atualização do layout, notificando todos os listeners.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
updateAll(
{List< String> ? claims, List<ModuleMenu> ? moduleMenuGroups, UserProfile? userProfile, List<Widget> ? appBarActions, Widget? sidebarHeader, Widget? drawerHeader, ChatbotConfig? chatbotConfig, Widget? logo, String? title}) → void - Atualiza múltiplas propriedades de uma vez e notifica os listeners.
-
updateAppBarActions(
List< Widget> ? appBarActions) → void - Atualiza as ações do AppBar e notifica os listeners.
-
updateChatbotConfig(
ChatbotConfig? chatbotConfig) → void - Atualiza a configuração do chatbot e notifica os listeners.
-
updateClaims(
List< String> ? claims) → void - Atualiza a lista de claims e notifica os listeners.
-
updateDrawerHeader(
Widget? drawerHeader) → void - Atualiza o header do drawer mobile e notifica os listeners.
- Atualiza o footer da aplicação e notifica os listeners.
-
updateLogo(
Widget? logo) → void - Atualiza o logo e notifica os listeners.
-
updateMenuGroups(
) → void - Atualiza os grupos de menu e notifica os listeners.
-
updateModuleMenuGroups(
List< ModuleMenu> ? moduleMenuGroups) → void - Atualiza os módulos de menu e notifica os listeners.
- Atualiza o footer do sidebar e notifica os listeners.
-
updateSidebarHeader(
Widget? sidebarHeader) → void - Atualiza o header do sidebar e notifica os listeners.
-
updateTitle(
String? title) → void - Atualiza o título e notifica os listeners.
-
updateUserProfile(
UserProfile? userProfile) → void - Atualiza o perfil do usuário e notifica os listeners.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited