A browser app is used in a resizable window. A desktop-sized screenshot does not prove that the layout will work beside another window, at a larger text setting or on a phone browser.
Let the parent describe available space
Use a constraint-based layout at the component boundary. This example chooses a navigation rail only when there is enough width. The 800-pixel threshold is a design decision for this screen, not a rule for every tablet.
In a local Flutter 3.50 app, keep the generated material_ui dependency (or add it with flutter pub add material_ui). This example uses the standalone design package.
import 'package:material_ui/material_ui.dart';
void main() => runApp(const MaterialApp(home: BrowserLayout()));
class BrowserLayout extends StatefulWidget {
const BrowserLayout({super.key});
@override
State<BrowserLayout> createState() => _BrowserLayoutState();
}
class _BrowserLayoutState extends State<BrowserLayout> {
int selected = 0;
static const labels = ['Lessons', 'Saved'];
@override
Widget build(BuildContext context) => LayoutBuilder(
builder: (context, constraints) {
final wide = constraints.maxWidth >= 800;
return Scaffold(
appBar: AppBar(title: const Text('Learning workspace')),
body: Row(children: [
if (wide) NavigationRail(
selectedIndex: selected,
onDestinationSelected: (value) => setState(() => selected = value),
labelType: NavigationRailLabelType.all,
destinations: const [
NavigationRailDestination(icon: Icon(Icons.menu_book), label: Text('Lessons')),
NavigationRailDestination(icon: Icon(Icons.bookmark_outline), label: Text('Saved')),
],
),
Expanded(child: Center(child: Text(labels[selected]))),
]),
bottomNavigationBar: wide ? null : NavigationBar(
selectedIndex: selected,
onDestinationSelected: (value) => setState(() => selected = value),
destinations: const [
NavigationDestination(icon: Icon(Icons.menu_book), label: 'Lessons'),
NavigationDestination(icon: Icon(Icons.bookmark_outline), label: 'Saved'),
],
),
);
},
);
}
Keep state outside the layout choice
The selected destination belongs to the page state. Both navigation controls read and update that value. Resizing the window changes the presentation while keeping the current destination. Duplicating state inside two separate navigation branches would make it easier for them to disagree.
Test more than dragging the window
Use Tab and Shift+Tab to reach controls, and verify that focus is visible. Try Enter or Space where the control supports activation. Zoom the browser and increase text size. Read long labels at a narrow width, then switch destinations and widen the window again.
Hover can add a hint, but an essential action needs an accessible label and a touch-friendly path. Do not make a control depend on a mouse being present. A horizontal layout that looks elegant with two short labels can still fail when translated.
Exercise
Replace the center label with a scrollable lesson list and an empty-state message. Preserve the selected destination at the breakpoint and check that focus remains usable. Use the layout chapter to diagnose constraints instead of adding arbitrary fixed heights.