Search code examples
flutterflutter-layout

Flutter: How to align on start and center in Flutter Row


I want create this layout layout

4 buttons align to left and Text and edit button align to center so in web there will be some space

I tried flexible with FlexFit but did not get result as i want (text and edit buton in middle)

EDIT: I manage to "hack" bad solution expected layout

but this cause overflowed warning

        Row(
          children: [
            Flexible(
              flex: 2,
              child: Row(
                children: [
                  IconButton(
                      onPressed: () => Get.offAllNamed(Verifications.ENDPOINT),
                      icon: const Icon(Icons.arrow_back)),
                  ...buildNavButtons(),
                ],
              ),
            ),
            const Spacer(
              flex: 99,
            ),
            Row(
              children: [
                GetBuilder<VerificationState>(builder: (_) {
                  return Text(_.verifications[verificationId]!.name);
                }),
                IconButton(onPressed: () {}, icon: const Icon(Icons.edit)),
              ],
            ),
            const Spacer(
              flex: 99,
            ),
          ],
        ),

EDIT 2: use Stack widget code example in answer


Solution

  • we need to use Stack widget

    Stack(
        children: [
            Row(
                children: [
                IconButton(
                    onPressed: () => Get.offAllNamed(Verifications.ENDPOINT),
                    icon: const Icon(Icons.arrow_back)),
                ...buildNavButtons(),
                ],
            ),
            Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                GetBuilder<VerificationState>(builder: (_) {
                    return Text(_.verifications[verificationId]!.name);
                }),
                IconButton(onPressed: () {}, icon: const Icon(Icons.edit)),
                ],
            )
        ],
    ),