inkwell_splash 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 62

InkWellSplash #

Buy Me A Beer Donate

Flutter package which starts the splash effect of InkWell instantly if onDoubleTap is used. Additionally maximal time between two taps to recognize a double tap can be adjusted.

Explanation #

The problem with the current InkWell is the delayed start of the splash effect while using onDoubleTap

If you are using onTap & onDoubleTap side by side with an InkWell, then a single tap gets delayed. This is necessary for the recognition of a double tap but also the splash effect is delayed. With this package the splash effect is startet instantly.

All other functions are equal to the standard InkWell widget

Interactive Example

Usage #

Add this line to pubspec.yaml

dependencies:
  inkwell_splash: ^0.0.1

Import package

import 'package:inkwell_splash/inkwell_splash.dart';

Simple example:

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.redAccent,
      child: InkWellSplash(
        splashFactory: InkRipple.splashFactory,
        onTap: () => print("Single Tap"),
        onDoubleTap: () => print("Double Tap"),
        doubleTapTime: Duration(milliseconds: 300),
        child: Container(
          width: 120,
          height: 120,
          child: Text("Welcome to InkWellSplash"),
        ),
      ),
    );
  }
}

Parameters #

ParameterDescriptionType
doubleTapTimeMaximal time between two taps to recognize a double tapDuration

Additional all parameters of standard InkWell can be used as well

Note #

If another parent or child gesture widget (e.g. InkWell, GestureDetector) uses its own onDoubleTap function, the splash of the InkWellSplash is delayed again. This is because, the onTap function of all widgets will then be delayed.

[0.1.0] - 18.04.2020 #

  • Removed tap delay if onDoubleTab is not used

[0.0.1] - 18.04.2020 #

  • Initial Release

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: MyWidget(),
        ),
      ),
    );
  }
}

class MyWidget extends StatefulWidget {
  @override
  _MyWidgetState createState() => _MyWidgetState();
}

class _MyWidgetState extends State<MyWidget> {
  int inkWellTaps = 0;
  int inkWellDoubleTaps = 0;
  int inkWellSplashTaps = 0;
  int inkWellSplashDoubleTaps = 0;

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      children: [
        Material(
          color: Colors.redAccent,
          child: InkWell(
            splashFactory: InkRipple.splashFactory,
            onTap: () => setState(() => inkWellTaps++),
            onDoubleTap: () => setState(() => inkWellDoubleTaps++),
            child: Container(
              alignment: Alignment.center,
              width: 120,
              height: 120,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text('Standard InkWell', style: TextStyle(fontWeight: FontWeight.bold)),
                  SizedBox(height: 20),
                  Text('Taps: $inkWellTaps'),
                  Text('Double Taps: $inkWellDoubleTaps'),
                ],
              ),
            ),
          ),
        ),
        Material(
          color: Colors.redAccent,
          child: InkWellSplash(
            splashFactory: InkRipple.splashFactory,
            onTap: () => setState(() => inkWellSplashTaps++),
            onDoubleTap: () => setState(() => inkWellSplashDoubleTaps++),
            doubleTapTime: Duration(milliseconds: 300),
            child: Container(
              width: 120,
              height: 120,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text('InkWellSplash', style: TextStyle(fontWeight: FontWeight.bold)),
                  SizedBox(height: 20),
                  Text('Taps: $inkWellSplashTaps'),
                  Text('Double Taps: $inkWellSplashDoubleTaps'),
                ],
              ),
            ),
          ),
        ),
      ],
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  inkwell_splash: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:inkwell_splash/inkwell_splash.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
24
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

We analyzed this package on May 30, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.2
  • pana: 0.13.8-dev
  • Flutter: 1.17.1

Health issues and suggestions

Document public APIs. (-0.17 points)

34 out of 35 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/inkwell_splash.dart. (-0.50 points)

Analysis of lib/inkwell_splash.dart reported 1 hint:

line 6 col 7: This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: InkWellSplash.doubleTapTimer, InkWellSplash.isPressed, InkWellSplash.isSingleTap, InkWellSplash.isDoubleTap

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test