slide_container 1.1.3 copy "slide_container: ^1.1.3" to clipboard
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.

example/lib/main.dart

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,
          ),
        ),
      );
}
28
likes
30
points
23
downloads

Publisher

unverified uploader

Weekly Downloads

A container that can be slid vertically and horizontally with a smooth dampened motion. Offers a handful of callbacks for customization.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on slide_container