flutter_adaptive_sidebar 0.3.1
flutter_adaptive_sidebar: ^0.3.1 copied to clipboard
Material and Cupertino sidebars that share one controller.
flutter_adaptive_sidebar #
EN / 中文
Material and Cupertino sidebars driven by a shared controller.
The package handles sidebar presentation and state, while your app controls the responsive layout. You decide when to show the sidebar and when to display the content on its own.
Features #
- Material and Cupertino sidebar styles
- Shared selection, expansion, and width state
- Built-in primary and auxiliary navigation lists
- Custom content, item styles, tooltips, and action labels
- Resizable sidebars and an optional Cupertino collapsed bar
- Window-control obstruction insets and RTL support
See it in action #
| Material | Cupertino |
|---|---|
| [Material sidebar expanding and collapsing] | Standard [Cupertino sidebar expanding and collapsing] Edge · light[Cupertino edge sidebar expanding from its default collapsed state] |
Getting started #
Add the package:
flutter pub add flutter_adaptive_sidebar
Use the same controller with either sidebar. The content parameter accepts any
widget. For a ready-made navigation list, use MaterialSidebarNavigation or
CupertinoSidebarNavigation; both support destinations pinned to the bottom.
Their row widgets are MaterialWideNavigationRailButton and
CupertinoSidebarDestination, respectively.
final Widget page = AnimatedBuilder(
animation: controller,
builder: (context, _) => useMaterial
? Row(
children: [
MaterialSidebar(
controller: controller,
content: MaterialSidebarNavigation(
destinations: destinations,
selection: controller.selection,
onSelectionChanged: controller.select,
),
),
Expanded(child: body),
],
)
: CupertinoSidebar(
controller: controller,
content: CupertinoSidebarNavigation(
destinations: destinations,
selection: controller.selection,
onSelectionChanged: controller.select,
),
child: body,
),
);
Use the controller to select a destination or toggle the sidebar:
controller.select(const SidebarPrimarySelection(0));
controller.toggleExpanded();
Dispose the controller when it is no longer needed. For responsive layouts and additional configuration, see the example app.
Cupertino appearance #
CupertinoSidebar.edge provides neutral light and dark surfaces inspired by
the iPadOS 27 sidebar. Edge and Liquid destination accents follow
CupertinoTheme.primaryColor, including the collapsed bar.
Use CupertinoSidebarThemeData.edgeBackgroundColor in ThemeData.extensions
to tint Edge surfaces throughout an app, or pass backgroundColor to customize
one sidebar. Both accept dynamic colors, and transparent colors retain backdrop
blur. For per-state destination colors, use CupertinoSidebarItemStyle.
More examples #
Explore the example app
cd example
fvm flutter run
The example covers theme-color switching, responsive layouts, Material and Cupertino styles, custom navigation content, collapsed bars, and window-control obstruction insets.
Development #
Local checks
# Format, analyze, and test the package and example application.
make check
Donate #
License #
This project is licensed under the MIT License. See LICENSE for the full license text.
MIT License
Copyright (c) 2026 Fries_I23
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.