Text doesn't accept new FontWeight of modified TextStyle

55 views Asked by At

I have a TextStyle called headline2, which is bold. Now I want to have a text with headline2, but not in bold. I can modify headline2 with textTheme.headline2!.copyWith(fontWeight: FontWeight.normal);or I use apply(fontWeightDelta: -3). Either way, if I use the new TextStyle in a Text or a TextSpan, it still shows up bold, even tho the new TextStyle has a FontWeight of 3.

   Expanded(
                    child: Padding(
                      padding: const EdgeInsets.only(top: GlobalSpacing.s),
                      child: ListView.separated(
                      shrinkWrap: true,
                    separatorBuilder: (context, index) =>
                    const Divider(
                      thickness: 1,
                    ),
                    itemCount: controller.currentStep + 3,
                    itemBuilder: (context, index) {
                      return Column(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: [
                          (controller.currentStep + 3 - 1 != index) ?
                          Padding(
                            padding: const EdgeInsets.fromLTRB(GlobalSpacing.m, 0.0, GlobalSpacing.m, 0.0),
                            child: Text.rich(
                              TextSpan(
                                style: textTheme.headline2,
                                text: "Text to be bold",
                                children: <TextSpan>[
                                  TextSpan(
                                style: textTheme.headline2!.copyWith(fontWeight: FontWeight.normal)),
                                    text: "text to be normal",
                                  ),
                                ],
                              ),
                            ),
                            /*
                            Row(
                            mainAxisSize: MainAxisSize.min,
                            children: [
                              Text("Bold", style: textTheme.headline2),
                              const Spacer(),
                              Text("Not bold", style: textTheme.headline2!.copyWith(fontWeight: FontWeight.normal)),
                            ],
                          ), */
                          ) :
                      createCurrentNodeWidget(textTheme),
                        ],
                      );
                    },
                  ),
                    ),
                    ),
0

There are 0 answers