2

I have AlertDilaog with TextField and DropDownButton.

Problem:

As soon as, I launch the dialog and clicks on textfield, the alertdialog shifts up and label animation in textfield happens. But while happening this I see jank. And I did profiling and I am still trying to understand the why it is happening.

Here is the screenshotenter image description here

And here is the profiling file: https://filebin.net/7wulbm9j88m6jjt3

Can anyone help me in understanding what is this VsyncProcessCallback and whatever happening in selected section(brackets)?

I am just trying to find the root cause of the Jank and remove it.

Thank you in advance.

Code of TextField:

Widget _addProtocolTextField(BuildContext context) {
    return Container(
      height: 7.h,
      width: 70.w,
      child: TextField(
        controller: _protocolNameController,
        style: TextStyle(
          color: Theme.of(context).textColor,
          fontSize: 13.sp,
        ),
        textAlign: TextAlign.left,
        maxLines: 1,
        decoration: InputDecoration(
          labelText: Strings.protocol_name_lable,
          labelStyle: TextStyle(color: ColorConstants.primaryColor),
          enabledBorder: _getBorder(),
          disabledBorder: _getBorder(),
          focusedBorder: _getBorder(),
          border: _getBorder(),
        ),
      ),
    );
  }

  OutlineInputBorder _getBorder() {
    return OutlineInputBorder(
      borderSide: BorderSide(color: ColorConstants.primaryColor),
    );
  }

AkshayT
  • 2,901
  • 2
  • 28
  • 32

1 Answers1

0

Since this much code is not enough to provide the real solution, you can refer to the following tips:

  1. Don't make Widget with Function, Prefer to make a separate stateless or stateful widget as per your requirement
  2. You can try this on release build to see if it helps: https://flutter.dev/docs/perf/rendering/shader
  • I am just trying to understand the jank trace. I have used AlertDialog as stateful widget – AkshayT Aug 01 '21 at 23:42
  • Jank mostly happens when you use animation [reducing as flutter is progressing] or when you are too much dependent on setState, so try to use providers, bloc or cubit – Anshul Arora Aug 02 '21 at 12:53
  • Yeah, But again I am trying to understand trace I mentioned above. :) – AkshayT Aug 02 '21 at 18:09
  • Did you find the solution where Jank is coming from? I have exactly same thing – just-Luka Dec 25 '21 at 18:11
  • No sir. I did not find anything. But somewhere in the view I was using SVG. So, I replaced them with images. I am not sure how this solves it. But short answer, No. – AkshayT Mar 28 '22 at 11:50
  • have you tried replacing Container with SizedBox()? Also are you able to share the full build() function? – Lingster Oct 30 '22 at 07:04