slide_container 1.1.3 slide_container: ^1.1.3 copied to clipboard
A container that can be slid vertically and horizontally with a smooth dampened motion. Offers a handful of callbacks for customization.
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'help_page.dart';
import 'page1.dart';
import 'page2.dart';
import 'page3.dart';
import 'page4.dart';
import 'page5.dart';
void main() => runApp(App());
class App extends StatelessWidget {
static const double bottomNavigationBarHeight = 48;
@override
Widget build(BuildContext context) => MaterialApp(
theme: ThemeData(splashColor: Colors.transparent),
home: Scaffold(
body: _Body(),
),
);
}
class _Body extends StatefulWidget {
@override
_State createState() => _State();
}
class _State extends State<_Body> {
final TextStyle selectedItemStyle = TextStyle(color: Colors.amber[800]);
final List<Widget> pages = [
Page1(),
Page2(),
Page3(),
Page4(),
Page5(),
];
int selectedPageIndex = 0;
@override
void initState() {
super.initState();
SchedulerBinding.instance
.addPostFrameCallback((_) => Navigator.of(context).push(HelpPage()));
}
void onPageSelected(int index) {
if (mounted) setState(() => selectedPageIndex = index);
}
List<BottomNavigationBarItem> get bottomNavigationBarItems => List.generate(
pages.length,
(index) => BottomNavigationBarItem(
icon: Text('${index + 1}'),
activeIcon: Text('${index + 1}', style: selectedItemStyle),
title: Container(),
),
);
@override
Widget build(BuildContext context) => Scaffold(
body: pages[selectedPageIndex],
bottomNavigationBar: SizedBox(
height: App.bottomNavigationBarHeight,
child: BottomNavigationBar(
items: bottomNavigationBarItems,
currentIndex: selectedPageIndex,
onTap: onPageSelected,
),
),
);
}