如何在DoubleTap flutter时钟暂停、恢复和复位的卡上添加onTap?

bgibtngc  于 2023-01-09  发布在  Flutter
关注(0)|答案(2)|浏览(130)

这包括具有.pause的lib can neon _circular_countdown_timer()和.resume带.reset的()()功能的状态,也卡只允许对儿童,它有点有线混乱的时钟就像2在卡的每一边,我想onTap和onDoubleTap检测与暂停和恢复与重置调用。但由于儿童与卡的限制是不同的。所有它需要一些调用它暂停,但可以得到恢复?因为它返回空

//import 'package:circular_countdown_timer/circular_countdown_timer.dart';
import 'package:flutter/material.dart';
import 'package:neon_circular_timer/neon_circular_timer.dart';

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

class MyApp extends StatelessWidget {
  MyApp({super.key});
  final CountDownController controller = CountDownController();
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.teal,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: const Pads(),
    );
  }
}

class Pads extends StatelessWidget {
  const Pads({super.key});

  // ignore: non_constant_identifier_names
  get your_controller => 00;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('CHESS APP'),
          leading: const Icon(Icons.image_aspect_ratio),
          toolbarHeight: 50,
        ),
        body: Column(children: <Widget>[
          SizedBox(
            height: 360,
            width: 500,
            child: InkWell(
              onTap: () {
                if (your_controller) {
                  your_controller.pause();
                }
              },
              child: Card(
                // ignore: sort_child_properties_last
                child: NeonCircularTimer(
                  width: 200,
                  duration: 300,
                  isReverse: true,
                  isReverseAnimation: true,
                  controller: your_controller,
                  isTimerTextShown: true,
                  neumorphicEffect: true,
                  innerFillColor: Colors.black12,
                  backgroudColor: Colors.blueAccent,
                  innerFillGradient: LinearGradient(colors: [
                    Colors.greenAccent.shade200,
                    Colors.blueAccent.shade400
                  ]),
                  neonGradient: LinearGradient(colors: [
                    Colors.greenAccent.shade200,
                    Colors.blueAccent.shade400
                  ]),
                ),
                elevation: 20,
                shadowColor: Colors.blueGrey,
                color: Colors.blueAccent,
                margin: const EdgeInsets.all(10),
                shape: const RoundedRectangleBorder(
                    borderRadius: BorderRadius.all(Radius.circular(10))),
                clipBehavior: Clip.hardEdge,
              ),
            ),
          ),
          SizedBox(
            height: 360,
            width: 500,
            child: Card(
              // ignore: sort_child_properties_last
              child: NeonCircularTimer(
                width: 200,
                duration: 300,
                isReverse: true,
                isReverseAnimation: true,
                controller: your_controller,
                isTimerTextShown: true,
                neumorphicEffect: true,
                innerFillColor: Colors.black12,
                backgroudColor: Colors.green,
                innerFillGradient: LinearGradient(colors: [
                  Colors.greenAccent.shade200,
                  Colors.blueAccent.shade400
                ]),
                neonGradient: LinearGradient(colors: [
                  Colors.greenAccent.shade200,
                  Colors.blueAccent.shade400
                ]),
              ),
              elevation: 20,
              shadowColor: Colors.blueGrey,
              color: Colors.green,
              margin: const EdgeInsets.all(10),
              shape: const RoundedRectangleBorder(
                  borderRadius: BorderRadius.all(Radius.circular(10))),
              clipBehavior: Clip.hardEdge,
            ),
          )
        ]));
  }
}

只是gesturecontrol在时钟上点击它就像我们播放视频和双标签手势将重置它

jdgnovmf

jdgnovmf1#

我认为您可能在寻找GestureDetector小部件https://api.flutter.dev/flutter/widgets/GestureDetector-class.html
你可以用它 Package 你的卡,它允许你处理像点击,双击,长按等事件。

SizedBox(
width: ...,
height: ..., 
child: GestureDetector(
  onTap : () => doSomething(),
  onDoubleTap : () => doSomethingElse(),
  child : Card(...)
  ),
)

但老实说我不太明白你的问题。

t30tvxxf

t30tvxxf2#

你必须用GestureDetector Package 你的主部件-GestureDetector可以检测你的onTap行为,比如不透明。

  • 对于onTap-〉,检测小工具上的单次点击。
  • 对于onDoubleTap-〉,检测小工具上的双击。
GestureDetector(
       onTap: (){
            controller.pause();

       },
       onDoubleTap: (){
             controller.reset();

       },

相关问题