This commit is contained in:
kejaro committed 2026-09-27 13:51:25 +01:00
commit ffc2051e20
80 files changed
+2915

No files matched your search

@@ -0,0 +1,105 @@
import 'package:flutter/material.dart';
const double largeScreenMinWidth = 640.0;
class NavigationDestinationItem {
const NavigationDestinationItem({
required this.icon,
required this.selectedIcon,
required this.label,
});
final Widget icon;
final Widget selectedIcon;
final String label;
}
class ResponsiveScaffold extends StatelessWidget {
const ResponsiveScaffold({
super.key,
required this.selectedIndex,
required this.onDestinationSelected,
required this.destinations,
required this.body,
this.appBarTitle,
this.actions,
this.floatingActionButton,
});
final int selectedIndex;
final ValueChanged<int> onDestinationSelected;
final List<NavigationDestinationItem> destinations;
final Widget body;
final Widget? appBarTitle;
final List<Widget>? actions;
final Widget? floatingActionButton;
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
final isLargeScreen = constraints.maxWidth >= largeScreenMinWidth;
if (isLargeScreen) {
return Scaffold(
appBar: AppBar(
title: appBarTitle,
actions: actions,
),
floatingActionButton: floatingActionButton,
body: Row(
children: [
NavigationRail(
selectedIndex: selectedIndex,
onDestinationSelected: onDestinationSelected,
labelType: NavigationRailLabelType.all,
destinations: destinations.map((d) {
return NavigationRailDestination(
icon: d.icon,
selectedIcon: d.selectedIcon,
label: Text(d.label),
);
}).toList(),
),
const VerticalDivider(thickness: 1, width: 1),
Expanded(
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 960),
child: body,
),
),
),
],
),
);
}
return Scaffold(
appBar: AppBar(
title: appBarTitle,
actions: actions,
),
body: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 640),
child: body,
),
),
bottomNavigationBar: NavigationBar(
selectedIndex: selectedIndex,
onDestinationSelected: onDestinationSelected,
destinations: destinations.map((d) {
return NavigationDestination(
icon: d.icon,
selectedIcon: d.selectedIcon,
label: d.label,
);
}).toList(),
),
floatingActionButton: floatingActionButton,
);
},
);
}
}