flutter_master_detail 1.1.5
flutter_master_detail: ^1.1.5 copied to clipboard
A package that simplifies building flexible adaptive master detail views for different screen sizes
import './views/grouped.dart';
import './views/paintings.dart';
import './views/ungrouped.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.indigo,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _selectedIndex = 0;
static const List<Widget> _widgetOptions = [
Ungrouped(),
Grouped(),
Paintings()
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: _widgetOptions.elementAt(_selectedIndex),
bottomNavigationBar: BottomNavigationBar(
items: const [
BottomNavigationBarItem(
label: 'Example One',
icon: Icon(Icons.group_off),
),
BottomNavigationBarItem(
label: 'Example Two',
icon: Icon(Icons.group),
),
BottomNavigationBarItem(
label: 'Example Three',
icon: Icon(Icons.art_track),
),
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
}