slide_container 1.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new72

Slide Container

A container that can be slid vertically and horizontally with a smooth dampened motion.

Features a customized GestureDetector to reduce nested GestureDetector conflicts.

Build the example folder with flutter run for a demo, or check the video in this blog post:

https://tengio.com/blog/flutter-slide-container/

Install instructions and doc are available here:

https://pub.dartlang.org/packages/slide_container

1.0.3 - 2018-10-10

  • Improved logic to reduce nested GestureDetector conflicts. Now if the container as been slid to its max extent in one direction, trying to slid it more in this direction will not count as a gesture, thus allowing other GestureDetectors to get and handle the event.

1.0.2 - 2018-10-09

  • Updated README.

1.0.1 - 2018-10-06

  • Added support for horizontal sliding.
  • Breaking change
    • Renamed class VerticalSlideContainer to SlideContainer
    • Renamed enum VerticalSlideContainerDirection to SlideContainerDirection and changed its values.

1.0.0 - 2018-10-05

  • Initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:slide_container/slide_container.dart';

void main() => runApp(App());

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) => MaterialApp(
        home: Scaffold(
          body: _Body(),
        ),
      );
}

class _Body extends StatefulWidget {
  @override
  _State createState() => _State();
}

class _State extends State<_Body> {
  double position = 0.0;

  double get maxSlideDistance => MediaQuery.of(context).size.height * 0.4;

  void onSlide(double position) {
    setState(() => this.position = position);
  }

  @override
  Widget build(BuildContext context) => new Stack(
        children: <Widget>[
          Positioned(
            top: MediaQuery.of(context).size.height * 0.20,
            width: MediaQuery.of(context).size.width,
            child: Text(
              "❤️",
              style: TextStyle(fontSize: 46.0),
              textAlign: TextAlign.center,
            ),
          ),
          Positioned(
            bottom: MediaQuery.of(context).size.height * 0.20,
            width: MediaQuery.of(context).size.width,
            child: Text(
              "✌️",
              style: TextStyle(fontSize: 46.0),
              textAlign: TextAlign.center,
            ),
          ),

          /// This GestureDetector is here to demonstrate how the gesture event only propagate to the parent when the
          /// SlideContainer can not slide more in the direction of the drag.
          GestureDetector(
            onVerticalDragStart: (_) => print(
                "Container cannot be slid further in that direction, this GestureDetector can take control and hadle the gesture."),
            child: SlideContainer(
              slideDirection: SlideContainerDirection.vertical,
              onSlide: onSlide,
              maxSlideDistance: maxSlideDistance,
              child: Container(
                width: MediaQuery.of(context).size.width,
                height: MediaQuery.of(context).size.height,
                alignment: Alignment.center,
                decoration: BoxDecoration(
                  gradient: LinearGradient(
                    begin: Alignment.topLeft,
                    end: Alignment.bottomRight,
                    colors: [
                      Color.lerp(
                          Color(0xfffddb92), Color(0xfffed6e3), position),
                      Color.lerp(
                          Color(0xffd1fdff), Color(0xff9a9ce2), position),
                    ],
                  ),
                  boxShadow: [
                    BoxShadow(
                      color: Color(0x90000000),
                      blurRadius: 15.0,
                      spreadRadius: 10.0,
                    ),
                  ],
                ),
                child: Center(
                  child: Text(
                    "Slide me!",
                    style: TextStyle(fontSize: 26.0),
                  ),
                ),
              ),
            ),
          ),
        ],
      );
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  slide_container: ^1.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:slide_container/slide_container.dart';
  
Version Uploaded Documentation Archive
1.0.3 Oct 10, 2018 Go to the documentation of slide_container 1.0.3 Download slide_container 1.0.3 archive
1.0.2 Oct 9, 2018 Go to the documentation of slide_container 1.0.2 Download slide_container 1.0.2 archive
1.0.1 Oct 6, 2018 Go to the documentation of slide_container 1.0.1 Download slide_container 1.0.1 archive
1.0.0 Oct 6, 2018 Go to the documentation of slide_container 1.0.0 Download slide_container 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
45
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
72
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4
  • Flutter: 0.9.5

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8