Can I get the same effect in flutter as the <TouchableOpacity /> in React Native?

flutter animate text change
inkwell flutter
flutter vs react native
flutter opacity tween
flutter offstage animation
flutter show hide widget
fadeout flutter
flutter fade on scroll

I found that in React Native, when using component, pressing the corresponding area can have a opacity effect. In flutter, we sure can use InkWell widget, but i don't want a rectangle or square. Can we implement the same result using flutter. Cheers!

@Shan Liu you are correct that InkWell has its own "splash" effect which makes the rectangle or square you mentioned.

If you don't want that splash effect, use GestureDetector.

In below example, I put a Text inside a GestureDetector, but you can put your widget there instead:

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final title = 'InkWell Demo';

    return MaterialApp(
      title: title,
      home: MyHomePage(title: title),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final String title;

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: Center(child: MyButton()),
    );
  }
}

class MyButton extends StatefulWidget {
  @override
  MyButtonState createState() {
    return MyButtonState();
  }
}

class MyButtonState extends State<MyButton> {
  bool isTappedDown = false;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
      },
      onTapDown: (tapDownDetails) {
        setState(() {
          isTappedDown = true;
        });
      },
      onTapUp: (tapUpDetails) {
        setState(() {
          isTappedDown = false;
        });
      },
      child: Text(
        'Flat Button',
        style: TextStyle(
            fontSize: 30,
            fontWeight: FontWeight.bold,
            color: isTappedDown ? Colors.black.withOpacity(0.5) : Colors.black),
      ),
    );
  }
}

Can I get the same effect in flutter as the - html, I found that in React Native, when using component, pressing the corresponding area can have a opacity effect. In flutter, we sure can use InkWell widget, but i  Atrial flutter is not the same as a stroke or a heart attack. Although there are many tests to evaluate atrial flutter, the most common diagnostic test is an electrocardiogram ( ECG / EKG ). Antiarrhythmics, beta-blockers , and anticoagulants are the three general types of drugs used to treat and manage this type of heart disease .

I think you'll need to combine a gesture detector and an opacity animation. I couldn't find a ready to use example. But here is the example for opacity animation. Flutter opacity animation

The Simple Flute: From A to Z, Unfortunately, English does not use the throat sound. As far as I know, English speakers need to have a working knowledge of the guttural consonant to find an alternative for flutter tongue. Worst of all, the Japanese When you are comfortable with that, try producing the same effect without the vocal cords. The flute sound  Atrial flutter is an abnormality in the beating of the heart. WebMD provides a comprehensive look at the causes, symptoms, diagnosis, and treatment of atrial flutter and atrial fibrillation.

Here's a touchable class I created. (You could easily add transparency here)

class Touchable extends StatelessWidget {
  final Widget child;
  final Function() onPress;
  final double borderRadius;
  final double padding;

  const Touchable(
      {Key key, this.child, this.onPress, this.borderRadius, this.padding})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ClipRRect(
      borderRadius: BorderRadius.circular(borderRadius),
      child: Material(
        color: Colors.transparent,
        child: InkWell(
            child: Padding(
              padding: EdgeInsets.all(padding),
              child: child,
            ),
            onTap: this.onPress),
      ),
    );
  }
}

Programming Flutter: Native, Cross-Platform Apps the Easy Way, Setting a width higher than the view's width will have no effect: the result will be the same as on the first screenshot. Setting a height higher or lower than the  Yep, we are going to play with an animation running a likely 3-D effect. How it works At a first glance, the idea is simple: we have a stack of panels, each is broken into 2 halves, each half can

Use the code below:

import 'package:flutter/material.dart';

class TouchableOpacity extends StatefulWidget {
  final Widget child;
  final Function onTap;
  final Duration duration = const Duration(milliseconds: 50);
  final double opacity = 0.5;

  TouchableOpacity({@required this.child, this.onTap});

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

class _TouchableOpacityState extends State<TouchableOpacity> {
  bool isDown;

  @override
  void initState() {
    super.initState();
    setState(() => isDown = false);
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTapDown: (_) => setState(() => isDown = true),
      onTapUp: (_) => setState(() => isDown = false),
      onTapCancel: () => setState(() => isDown = false),
      onTap: widget.onTap,
      child: AnimatedOpacity(
        child: widget.child,
        duration: widget.duration,
        opacity: isDown ? widget.opacity : 1,
      ),
    );
  }
}

Usage:

TouchableOpacity(
  child: ....
  onTap: () {....}
)

Practical Flutter: Improve your Mobile Development with Google’s , Now, an exciting thing about this mechanism, which you will have noticed if you because it does a lot less work, but it gets you roughly the same effect (minus  I write an article to show how to make blur effect on Flutter by const EdgeInsets.all(15.0), decoration: new BoxDecoration( //you can get rid of below line also

Flutter, “I'm a fan, but I don't think it has the same effect on me as it probably does you. “So you've said, and enough times to make me think that maybe you reallydo  A while ago, I wrote an article on the basics of using a ListView and GridView in Flutter. This article is meant as a more detailed exploration on the ListView class, ScrollPhysics and tweaks and…

Unsteady Transonic Flow, Such problems have received increased attention with the advent of transonic and of all aerodynamic derivatives by the same amount has the same effect as, of strip theory can lead to large errors in the computed flutter speed near M = 1. Flutter provides the InkWell widget to perform this effect. Create a ripple effect using the following steps: Create a widget that supports tap. Wrap it in an InkWell widget to manage tap callbacks and ripple animations.

Flutter for React Native developers, In Cases XXIV. and XXV. strophanthus produced the same effects as had In Case I. the auricular flutter was not converted into fibrillation by digitalis, that when the drug induces fibrillation, it does so by depressing conductivity within the​  Flutter is a free, open-source mobile SDK that can be used to create native-looking Android and iOS apps from the same code base. Being in beta for a while, Flutter 1.0 was officially launched in December 2018.

Comments
  • That's one way to go. Cheers mate.
  • updates - if you tap on the text but release somewhere else. it would cause some side effects