what is the right way to use Ternary operator in flutter?

  android, conditional-operator, dart, flutter

I am using a ternary operator in my Flutter application for checking the length of questions.

child: isLoading
            ? Center(
                child: CircularProgressIndicator(),
              )
            : this.questions.length == 2
                ? Column(
                    children: [
                      Text(
                        "Quiz Started with ",
                        style: TextStyle(color: Colors.white),
                      ),
                    ],
                  )
                : this.questions.length < 2
                    ? Text('Incomplete', style: TextStyle(color: Colors.white),)
                    : this.questions.length == null ?? Text("Zero"),

I am getting the right answer for the above two levels of my condition, but getting an error for the null value.

 : this.questions.length == null ?? Text("Zero"), // I am not getting this vlaue..

Please suggest to me, How can I use it in a proper way.

Source: Android Questions

LEAVE A COMMENT