Home > Enterprise >  Highlight InkWell when focused
Highlight InkWell when focused

Time:01-06

I am creating an app for android Tv using Flutter.I want to implement a feature in which if an InkWell has focus there should be boundary visible.

Container(
      decoration: BoxDecoration(
          border: Border.all(
              color: _focusNode.hasFocus ? Colors.black : Colors.transparent)),
      child: InkWell(
          focusNode: _focusNode,
          onTap: () {
            if (onTap != null) {
              onTap();
            }
          },
          onDoubleTap: onDoubleTap,
          borderRadius: borderRadius ?? BorderRadius.circular(50),
          child: child),
    );

CodePudding user response:

Try by adding this line in inkwell:

splashColor: Colors.grey,

CodePudding user response:

your are not proper manage focus request.

Container(
        decoration: BoxDecoration(
            border: Border.all(
                color: _focusNode.hasFocus
                    ? Colors.black
                    : Colors.transparent)),
        child: InkWell(
            focusNode: _focusNode,
            onTap: () {
              setState(() {
                FocusScope.of(context).requestFocus(_focusNode);
              });
            },
             onDoubleTap:(){
               _focusNode.unfocus();
             },
             borderRadius: BorderRadius.circular(50),
            child: Text("Hello")),
      )
  • Related