Widget createCards()

in frontend/frontend-flutter/lib/main.dart [1384:1532]


  Widget createCards(
      {required String? imagePath,
      required String? title,
      required String subTitle,
      required String text,
      required int badgeCount}) {
    return Expanded(
      child: Container(
        width: screenSize!.width / 3.5,
        //height: screenSize!.height / 6,
        child: Card(
          elevation: 10,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(10),
          ),
          // Define how the card's content should be clipped
          clipBehavior: Clip.antiAliasWithSaveLayer,
          // Define the child widget of the card
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              // Add padding around the row widget
              Padding(
                padding: const EdgeInsets.all(10),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    // Add an image widget to display an image
                    Image.asset(
                      imagePath!,
                      height: 70,
                      width: 70,
                      fit: BoxFit.cover,
                    ),
                    // Add some spacing between the image and the text
                    Container(width: 20),
                    // Add an expanded widget to take up the remaining horizontal space
                    Expanded(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          // Add some spacing between the top of the card and the title
                          Container(height: 5),
                          // Add a title widget
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Text(
                                title!,
                                style: TextStyle(
                                    fontSize: 18,
                                    fontWeight: FontWeight.bold,
                                    color: Color(0xFF37474F)),
                              ),
                              badges.Badge(
                                position: badges.BadgePosition.topEnd(
                                    top: -10, end: -12),
                                showBadge: true,
                                ignorePointer: false,
                                onTap: () {},
                                badgeContent: Text(
                                    badgeCount < 10
                                        ? "  " + badgeCount.toString()
                                        : badgeCount.toString(),
                                    style: TextStyle(
                                        fontSize: 15,
                                        color: Colors
                                            .white)), //Icon(Icons.check, color: Colors.white, size: 14),
                                badgeAnimation: badges.BadgeAnimation.rotation(
                                  animationDuration: Duration(seconds: 1),
                                  colorChangeAnimationDuration:
                                      Duration(seconds: 1),
                                  loopAnimation: false,
                                  curve: Curves.fastOutSlowIn,
                                  colorChangeAnimationCurve: Curves.easeInCubic,
                                ),
                                badgeStyle: badges.BadgeStyle(
                                  shape: badges.BadgeShape.instagram,
                                  badgeColor: Colors.red,
                                  //padding: EdgeInsets.all(5),
                                  borderRadius: BorderRadius.circular(4),
                                  borderSide:
                                      BorderSide(color: Colors.white, width: 2),
                                  elevation: 2,
                                ),
                                //child: Text('Badge'),
                              ),
                            ],
                          ),
                          // Add some spacing between the title and the subtitle
                          Container(height: 5),
                          // Add a subtitle widget
                          Text(
                            subTitle!,
                            style: Theme.of(context)
                                .textTheme
                                .bodyMedium!
                                .copyWith(
                                  color: Colors.grey[500],
                                ),
                          ),
                          // Add some spacing between the subtitle and the text
                          Container(height: 10),
                          // Add a text widget to display some text
                          Text(
                            text.length <= 35
                                ? text!
                                : text!.substring(0, 35) + ' ...',
                            style: Theme.of(context)
                                .textTheme
                                .titleMedium!
                                .copyWith(
                                  color: Colors.grey[700],
                                ),
                            maxLines: 1,
                          ),
                          Row(children: [
                            Spacer(),
                            TextButton(
                              style: TextButton.styleFrom(
                                foregroundColor: Colors.transparent,
                              ),
                              child: const Text(
                                "LOAD",
                                style: TextStyle(color: Color(0xFFFF4081)),
                              ),
                              onPressed: () {
                                print(
                                    'Bot() : build() : TextButton : onPressed() : START : text = $text');
                                //BlocProvider.of<LoadQuestionCubit>(context).loadQuestionToChat("test");
                                //setState(() {
                                textEditingController.text = text;
                                _isFirstQuestionNotAskedYet = false;
                                //});
                              },
                            ),
                          ])
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }