showResult method

void showResult()

Implementation

void showResult() {
  DialogRF(rf.context,
      height: 440,
      avatarIcon: FontAwesomeIcons.bookOpen,
      hideAvatar: true,
      avatarIconSize: 25,
      hideDefaultControls: true,
      type: DialogType.popup,
      title: 'Quiz Result',
      subTitle: quiz!.Title!,
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Center(
            child: Container(
              height: 80,
              width: 80,
              margin: const EdgeInsets.all(15),
              decoration: BoxDecoration(
                boxShadow: [
                  BoxShadow(
                      offset: Offset(6, 6),
                      color: Colors.black38,
                      blurRadius: 20),
                  BoxShadow(
                      offset: Offset(-6, -6),
                      color: Colors.white.withValues(alpha: 0.85),
                      blurRadius: 20)
                ],
                color: Colors.white38,
                borderRadius: BorderRadius.circular(20.0),
              ),
              child: Center(
                  child: TextRF(
                totalEarnedMark.toString(),
                color: Colors.cyan,
                size: 30,
                weight: FontWeight.bold,
              )),
            ),
          ),
          GapRF(15),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: [
              Container(
                height: 30,
                padding: const EdgeInsets.symmetric(horizontal: 6),
                decoration: new BoxDecoration(
                  color: Colors.deepPurpleAccent[100]!.withValues(alpha: 0.2),
                  borderRadius: new BorderRadius.all(Radius.circular(4)),
                ),
                child: Center(
                  child: TextRF(
                    questions.length.toString() + " Questions",
                    size: 15,
                    color: Colors.deepPurple,
                    weight: FontWeight.w300,
                  ),
                ),
              ),
              Container(
                height: 30,
                padding: const EdgeInsets.symmetric(horizontal: 6),
                decoration: new BoxDecoration(
                  color: Colors.blue[200]!.withValues(alpha: 0.3),
                  borderRadius: new BorderRadius.all(Radius.circular(4)),
                ),
                child: Center(
                  child: TextRF(
                    answered.toString() + " Answered",
                    size: 15,
                    color: Colors.blue,
                    weight: FontWeight.w300,
                  ),
                ),
              ),
              Container(
                height: 30,
                padding: const EdgeInsets.symmetric(horizontal: 6),
                decoration: new BoxDecoration(
                  color: Colors.deepOrange[200]!.withValues(alpha: 0.3),
                  borderRadius: new BorderRadius.all(Radius.circular(4)),
                ),
                child: Center(
                  child: TextRF(
                    (questions.length - answered).toString() + " Skipped",
                    size: 15,
                    color: Colors.deepOrange,
                    weight: FontWeight.w300,
                  ),
                ),
              )
            ],
          ),
          GapRF(50),
          TextRF(
            "Here is your answers :",
            size: 16,
            color: Colors.black87,
            weight: FontWeight.w300,
          ),
          GapRF(10),
          Container(
            height: 60,
            child: ListView.builder(
              scrollDirection: Axis.horizontal,
              itemCount: answerList.length,
              itemBuilder: (context, i) {
                return TweenAnimationBuilder(
                  tween: Tween<double>(begin: 0, end: 1),
                  curve: Curves.elasticOut,
                  duration: Duration(milliseconds: 800 * i),
                  builder:
                      (BuildContext context, double size, Widget? child) {
                    return Transform.scale(
                      scale: size,
                      child: Center(
                        child: Container(
                          width: 40,
                          height: 40,
                          margin: const EdgeInsets.all(5),
                          decoration: new BoxDecoration(
                            gradient: LinearGradient(
                                colors: answerList[i].IsCorrect != 1
                                    ? [
                                        Colors.deepOrange[700]!,
                                        Colors.red[200]!
                                      ]
                                    : [
                                        Colors.green[700]!,
                                        Colors.green[200]!
                                      ],
                                begin: Alignment.topRight,
                                end: Alignment.bottomLeft),
                            borderRadius:
                                new BorderRadius.all(Radius.circular(100)),
                          ),
                          color: answerList[i].IsCorrect == 1
                              ? Colors.green
                              : Colors.red,
                          child: Center(
                            child: TextRF(
                              (i + 1).toString(),
                              size: 18,
                              color: Colors.black,
                            ),
                          ),
                        ),
                      ),
                    );
                  },
                );
              },
            ),
          ),
        ],
      ),
      onAccept: () {
        rf.page.back(rf.context);
      },
      onCancel: () => rf.page.back(rf.context));
}