snap_scroll_physics 0.0.1+3 copy "snap_scroll_physics: ^0.0.1+3" to clipboard
snap_scroll_physics: ^0.0.1+3 copied to clipboard

Scroll physics to snap the user scroll at different offsets

example/lib/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:snap_scroll_physics/snap_scroll_physics.dart';
import 'examples/material.dart';
import 'examples/cupertino.dart';
import 'examples/music.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int index = 0;
  @override
  Widget build(BuildContext context) {
    bool showBottomBar = true;
    return Scaffold(
      body: [
        () => MaterialExamplePage(),
        () => CupertinoExamplePage(),
        () => MusicExamplePage(),
      ][index](),
      bottomNavigationBar: showBottomBar ? BottomNavigationBar(
        currentIndex: index,
        onTap: (index) => setState(() => this.index = index),
        items: [
          BottomNavigationBarItem(
            label: 'Material',
            icon: Icon(Icons.adb),
          ),
          BottomNavigationBarItem(
            label: 'Cupertino',
            icon: Icon(Icons.tab),
          ),
          BottomNavigationBarItem(
            label: 'Music',
            icon: Icon(Icons.music_note),
          )
        ],
      ) : null,
    );
  }
}
68
likes
110
pub points
86%
popularity

Publisher

unverified uploader

Scroll physics to snap the user scroll at different offsets

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on snap_scroll_physics