mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
remove navigation rail, update adaptive scaffold (#404)
This commit is contained in:
@@ -5,12 +5,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'pages/home.dart';
|
||||
import 'api/api.dart';
|
||||
import 'api/mock.dart';
|
||||
import 'pages/home.dart';
|
||||
import 'widgets/third_party/adaptive_scaffold.dart';
|
||||
|
||||
/// An app that shows a responsive dashboard.
|
||||
class DashboardApp extends StatelessWidget {
|
||||
class DashboardApp extends StatefulWidget {
|
||||
@override
|
||||
_DashboardAppState createState() => _DashboardAppState();
|
||||
}
|
||||
|
||||
class _DashboardAppState extends State<DashboardApp> {
|
||||
int _pageIndex = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MultiProvider(
|
||||
@@ -18,8 +26,34 @@ class DashboardApp extends StatelessWidget {
|
||||
Provider<DashboardApi>(create: (_) => MockDashboardApi()),
|
||||
],
|
||||
child: MaterialApp(
|
||||
home: HomePage(),
|
||||
home: AdaptiveScaffold(
|
||||
currentIndex: _pageIndex,
|
||||
destinations: [
|
||||
AdaptiveScaffoldDestination(title: 'Home', icon: Icons.home),
|
||||
AdaptiveScaffoldDestination(title: 'Entries', icon: Icons.list),
|
||||
AdaptiveScaffoldDestination(
|
||||
title: 'Settings', icon: Icons.settings),
|
||||
],
|
||||
body: _pageAtIndex(_pageIndex),
|
||||
onNavigationIndexChange: (newIndex) {
|
||||
setState(() {
|
||||
_pageIndex = newIndex;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static Widget _pageAtIndex(int index) {
|
||||
switch (index) {
|
||||
case 1:
|
||||
return Center(child: Text('page 2'));
|
||||
case 2:
|
||||
return Center(child: Text('page 3'));
|
||||
case 0:
|
||||
default:
|
||||
return HomePage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user