ModBaseLayout class
Widget base para criar layouts responsivos com menu lateral, header e footer.
O ModBaseLayout oferece uma estrutura completa de layout com suporte a:
- Menu lateral colapsável (desktop) e drawer (mobile)
- Sistema de módulos e grupos de menu
- Validação de permissões baseada em claims
- Temas claro/escuro dinâmicos
- Internacionalização (i18n)
- Header customizável com logo, ações e perfil de usuário
- Footer opcional
Exemplo básico:
ModBaseLayout(
title: 'Minha Aplicação',
body: MinhaHomePage(),
menuGroups: [
MenuGroup(
title: Text('Menu Principal'),
items: [
MenuItem(title: 'Dashboard', icon: Icons.dashboard, route: '/dashboard'),
MenuItem(title: 'Configurações', icon: Icons.settings, route: '/settings'),
],
),
],
userProfile: UserProfile(
userName: 'João Silva',
userEmail: 'joao@example.com',
onLogout: () => Get.offNamed('/login'),
),
)
Customização de cores do header:
ModBaseLayout(
title: 'App',
body: HomePage(),
menuGroups: myMenuGroups,
// Customizar cores dos elementos do header
headerMenuIconColor: Colors.white,
headerTitleColor: Colors.white,
headerThemeIconColor: Colors.amber,
headerProfileColor: Colors.white,
headerLanguageIconColor: Colors.white,
)
Customização de cores do footer:
ModBaseLayout(
title: 'App',
body: HomePage(),
menuGroups: myMenuGroups,
footer: Text('© 2024 Minha Empresa'),
footerBackgroundColor: Colors.blueGrey,
footerHeight: 60.0,
)
Chatbot integrado (Windows/Web):
ModBaseLayout(
title: 'App',
body: HomePage(),
menuGroups: myMenuGroups,
chatbotConfig: ChatbotConfig(
chatWidget: MyChatbotWidget(),
position: ChatbotPosition.bottomRight,
icon: Icons.support_agent,
backgroundColor: Colors.blue,
),
)
Uso com Controller para atualizações dinâmicas:
// Crie o controller (pode ser em um GetController ou StatefulWidget)
final layoutController = ModBaseLayoutController(
claims: userClaims,
menuGroups: myMenuGroups,
userProfile: UserProfile(userName: 'João'),
);
// Use no ModBaseLayout
ModBaseLayout(
title: 'App',
body: HomePage(),
controller: layoutController,
)
// Atualize dinamicamente em qualquer lugar
layoutController.updateClaims(newClaims);
layoutController.updateUserProfile(newUserProfile);
layoutController.refresh(); // Força rebuild
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ModBaseLayout
Constructors
-
ModBaseLayout({Key? key, ModBaseLayoutController? controller, required String title, Widget? logo, required Widget? body, List<
String> ? claims, List<ModuleMenu> ? moduleMenuGroups, UserProfile? userProfile, List<Widget> ? appBarActions, bool showDefaultActions = true, Widget? sidebarHeader, Color? sidebarBackgroundColor, Color? sidebarSelectedColor, Color? sidebarUnselectedColor, Widget? drawerHeader, Color? lightBackgroundColor, Color? darkBackgroundColor, Color? lightForegroundColor, Color? darkForegroundColor, bool showAppBar = true, Color? drawerBackgroundColor, String? loginRoute, VoidCallback? onNoAccessRedirect, bool disableClaimsValidation = false, Color? headerMenuIconColor, Color? headerTitleColor, Color? headerThemeIconColor, Color? headerProfileColor, Color? headerLanguageIconColor, ChatbotConfig? chatbotConfig}) -
const
Properties
-
appBarActions
→ List<
Widget> ? -
Ações customizadas adicionais para o AppBar
final
- body → Widget?
-
Conteúdo principal da aplicação
final
- chatbotConfig → ChatbotConfig?
-
Configuração do chatbot flutuante.
Quando fornecido, exibe um botão flutuante que abre uma janela de chat.
Visível apenas em plataformas Windows e Web.
final
-
claims
→ List<
String> ? -
Lista de claims para validação de permissões (ex:
'admin', 'user:read')final - controller → ModBaseLayoutController?
-
Controller para gerenciamento dinâmico do estado do layout.
final
- darkBackgroundColor → Color?
-
Cor de fundo do header no tema escuro
final
- darkForegroundColor → Color?
-
Cor de primeiro plano do header no tema escuro
final
- disableClaimsValidation → bool
-
Se true, desabilita validação de claims (padrão: false)
final
- drawerBackgroundColor → Color?
-
Cor de fundo do drawer mobile
final
- drawerHeader → Widget?
-
Widget customizado para o cabeçalho do drawer (mobile)
final
-
Widget customizado para o footer da aplicação
final
-
Cor de fundo do footer
final
-
Borda customizada para o footer
final
-
Altura do footer (padrão: 50.0)
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- headerLanguageIconColor → Color?
-
Cor opcional para o ícone de idioma no header.
Se não informado, usa Get.theme.colorScheme.onPrimary
final
- headerMenuIconColor → Color?
-
Cor opcional para o ícone do menu no header.
Se não informado, usa Get.theme.colorScheme.onPrimary
final
- headerProfileColor → Color?
-
Cor opcional para os elementos do perfil no header.
Se não informado, usa Get.theme.colorScheme.onPrimary
final
- headerThemeIconColor → Color?
-
Cor opcional para o ícone de tema (light/dark) no header.
Se não informado, usa Get.theme.colorScheme.onPrimary
final
- headerTitleColor → Color?
-
Cor opcional para o texto do título no header.
Se não informado, usa Get.theme.colorScheme.onPrimary
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- lightBackgroundColor → Color?
-
Cor de fundo do header no tema claro
final
- lightForegroundColor → Color?
-
Cor de primeiro plano do header no tema claro
final
- loginRoute → String?
-
Rota para redirect quando usuário não tem acesso
final
- logo → Widget?
-
Widget de logo customizado para o header (substitui o título quando fornecido)
final
-
Grupos de menu para navegação (usado quando não há módulos)
final
-
moduleMenuGroups
→ List<
ModuleMenu> ? -
Sistema de módulos com múltiplos grupos de menu
final
- onNoAccessRedirect → VoidCallback?
-
Callback executado quando usuário sem acesso tenta fazer logout
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showAppBar → bool
-
Se true, exibe o AppBar (padrão: true)
final
- showDefaultActions → bool
-
Se true, mostra botões de tema e idioma no header (padrão: true)
final
-
Cor de fundo do menu lateral
final
-
Widget customizado para o rodapé do menu lateral (desktop)
final
-
Widget customizado para o cabeçalho do menu lateral (desktop)
final
-
Cor do item de menu selecionado
final
-
Cor dos itens de menu não selecionados
final
- title → String
-
Título da aplicação exibido no header (quando não há logo)
final
- userProfile → UserProfile?
-
Widget de perfil do usuário exibido no header
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< ModBaseLayout> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited