'Android Studio builds an old version of the file

I was tasked with making a page for a project, and for some reason whenever i build a new apk(or hot restart or reload), it keeps the old layout of the page instead of actually showing what i have in my file.

I have commited and pushed the first version to the gitlab project, so maybe that has to do with something. I didn't find much on google, except someone saying that i should delete the build folder in the project, and that didn't help, obviously.

I have also tried all of the standard things like Flutter clean, cache invalidation and rebuilding, but the issue still persists. The issue seems to be only on my computer, i have built the app on my co-workers pc and phone, and it looked like it should.

This is what i need(Dont mind the labels and black lines, ive pulled this image from figma)

And this is what i get

enter image description here

Here is my code

import 'package:citizen/constants/uiConstants.dart';
import 'package:citizen/constants/uiImages.dart';
import 'dart:math';
import 'package:citizen/constants/uiStrings.dart';
import 'package:citizen/constants/uiThemes.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class FirstLoginPage extends StatefulWidget {
  @override
  _FirstLoginPageState createState() => _FirstLoginPageState();
}

class _FirstLoginPageState extends State<FirstLoginPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _rootWidget(),
    );
  }

  Widget _rootWidget() {
    return Container(
      padding: EdgeInsets.only(
          left: UiConstants.firstLoginPageContentPaddingLR,
          right: UiConstants.firstLoginPageContentPaddingLR),
      child: ScrollConfiguration(
        behavior: MyBehavior(),
        child: ListView(
          physics: BouncingScrollPhysics(),
          children: [
            Container(
                margin: EdgeInsets.only(
                    bottom: UiConstants.firstLoginPageLogoMarginBottom,
                    top: kToolbarHeight),
                height: UiConstants.firstLoginPageLogoHeight,
                width: UiConstants.firstLoginPageLogoWidth,
                child: SvgPicture.asset(UiImages.logoAppBarSVG)),
            Column(
              children: [
                Container(
                  child: Column(
                    children: [
                      Text(
                        UiStrings.firstLoginPageLuchany(context),
                        style: TextStyle(
                            fontSize: UiConstants.firstLoginPageTitleFontSize,
                            fontFamily: UiTheme.bold,
                            fontWeight: FontWeight.w700),
                      ),
                      Padding(
                        padding: EdgeInsets.only(
                            top: UiConstants.firstLoginPageSubtextPaddingTop,
                            bottom:
                                UiConstants.firstLoginPageSubtextPaddingBottom),
                        child: Text(
                          UiStrings.firstLoginPageFirstCommunity(context),
                          style: TextStyle(
                              fontFamily: UiTheme.bold,
                              fontWeight: FontWeight.w600),
                        ),
                      )
                    ],
                  ),
                ),
                Container(
                  child: Column(
                    children: [
                      _chatBubbleWidget(
                          UiImages.chatBubbleFemaleProfileIcon6,
                          UiStrings.firstLoginPageOlenaBuyvol(context),
                          UiStrings.firstLoginPageFirstChatBubbleText(context)),
                      _mirroredChatBubbleWidget(
                          UiImages.chatBubbleMaleProfileIcon8,
                          UiStrings.firstLoginPageOlegLyubomyr(context),
                          UiStrings.firstLoginPageSecondChatBubbleText(context),
                          UiConstants.firstLoginPageSubtextPaddingTop),
                      _chatBubbleWidget(
                          UiImages.chatBubbleMaleProfileIcon1,
                          UiStrings.firstLoginPageAndriiGotsul(context),
                          UiStrings.firstLoginPageThirdChatBubbleText(context)),
                      _mirroredChatBubbleWidget(
                          UiImages.chatBubbleFemaleProfileIcon2,
                          UiStrings.firstLoginPageYulyaSavinska(context),
                          UiStrings.firstLoginPageFourthChatBubbleText(context),
                          UiConstants.firstLoginPageLogoMarginBottom),
                      InkWell(
                        onTap: () {},
                        child: Container(
                          padding: EdgeInsets.only(
                              top: UiConstants
                                  .changeUsernameContainerButtonPaddingTB,
                              bottom: UiConstants
                                  .changeUsernameContainerButtonPaddingTB),
                          margin: EdgeInsets.only(
                              top: UiConstants.firstLoginPageButtonPaddingTop),
                          width: double.infinity,
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(
                                UiConstants.changeUsernameButtonBorderRadius),
                            color: UiTheme.containerButtonColorBlue,
                          ),
                          alignment: Alignment.center,
                          child: Text(
                            UiStrings.firstLoginPageButtonLabel(context),
                            style: TextStyle(
                                fontSize:
                                    UiConstants.changeUsernameTextFontSize,
                                color: UiTheme.white,
                                fontFamily: UiTheme.MontserratSemiBold),
                          ),
                        ),
                      ),
                      Padding(
                        padding: EdgeInsets.only(
                            top: UiConstants.changeUsernameContainerPaddingTB,
                            bottom: UiConstants.firstLoginPageLogoMarginBottom),
                        child: InkWell(
                          onTap: () {},
                          child: Text(
                            UiStrings.firstLoginPageAlreadyHaveAnAccount(
                                context),
                            style: TextStyle(
                              fontFamily: UiTheme.MontserratMedium,
                              fontSize: UiConstants.changeUsernameTextFontSize,
                              color: Theme.of(context).colorScheme.onPrimary,
                            ),
                          ),
                        ),
                      )
                    ],
                  ),
                )
              ],
            ),
          ],
        ),
      ),
    );
  }

  Widget _chatBubbleWidget(String profileIcon, String name, String message) {
    return Row(
      children: [
        Padding(
          padding: EdgeInsets.only(
              top: UiConstants.firstLoginPageSubtextPaddingTop,
              right: UiConstants.firstLoginPageContentPaddingLR),
          child: Image.asset(
            profileIcon,
            height: UiConstants.firstLoginPageProfileIconHeight,
            width: UiConstants.firstLoginPageProfileIconWidth,
          ),
        ),
        Stack(
          children: [
            Container(
              height: UiConstants.firstLoginPageBubbleIconHeight,
              width: UiConstants.firstLoginPageBubbleIconWidth,
              child: SvgPicture.asset(
                UiImages.chatBubbleIcon,
                fit: BoxFit.fill,
              ),
            ),
            Padding(
              padding: EdgeInsets.only(
                  left: UiConstants.firstLoginPageBubbleIconTextPaddingLeft,
                  top: UiConstants.firstLoginPageBubbleIconTextPaddingTop),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    name,
                    style: TextStyle(
                        fontFamily: UiTheme.regular,
                        fontWeight: FontWeight.w700,
                        fontSize: UiConstants.firstLoginPageFontSize),
                  ),
                  Text(
                    message,
                    style: TextStyle(
                        fontFamily: UiTheme.regular,
                        fontSize: UiConstants.firstLoginPageFontSize),
                  ),
                ],
              ),
            )
          ],
        )
      ],
    );
  }

  Widget _mirroredChatBubbleWidget(
      String profileIcon, String name, String message, double leftPadding) {
    return Transform(
      alignment: Alignment.center,
      transform: Matrix4.rotationY(pi),
      child: Row(
        children: [
          Padding(
            padding: EdgeInsets.only(
                top: UiConstants.firstLoginPageSubtextPaddingTop,
                right: UiConstants.firstLoginPageContentPaddingLR),
            child: Image.asset(
              profileIcon,
              height: UiConstants.firstLoginPageProfileIconHeight,
              width: UiConstants.firstLoginPageProfileIconWidth,
            ),
          ),
          Stack(
            children: [
              Container(
                height: UiConstants.firstLoginPageBubbleIconHeight,
                width: UiConstants.firstLoginPageBubbleIconWidth,
                child: SvgPicture.asset(
                  UiImages.chatBubbleIcon,
                  fit: BoxFit.fill,
                ),
              ),
              Padding(
                padding: EdgeInsets.only(
                    left: leftPadding,
                    top: UiConstants.firstLoginPageBubbleIconTextPaddingTop),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  children: [
                    Container(
                      child: Transform(
                        alignment: Alignment.center,
                        transform: Matrix4.rotationY(pi),
                        child: Text(
                          name,
                          style: TextStyle(
                              fontFamily: UiTheme.regular,
                              fontWeight: FontWeight.w700,
                              fontSize: UiConstants.firstLoginPageFontSize),
                        ),
                      ),
                    ),
                    Transform(
                      alignment: Alignment.center,
                      transform: Matrix4.rotationY(pi),
                      child: Text(
                        message,
                        style: TextStyle(
                            fontFamily: UiTheme.regular,
                            fontSize: UiConstants.firstLoginPageFontSize),
                      ),
                    ),
                  ],
                ),
              )
            ],
          )
        ],
      ),
    );
  }
}

class MyBehavior extends ScrollBehavior {
  @override
  Widget buildViewportChrome(
      BuildContext context, Widget child, AxisDirection axisDirection) {
    return child;
  }
}

Here is my Flutter Doctor output

doctor --verbose
[√] Flutter (Channel stable, 2.0.3, on Microsoft Windows [Version 10.0.18363.1316], locale en-US)
    • Flutter version 2.0.3 at C:\src\flutter
    • Framework revision 4d7946a68d (5 weeks ago), 2021-03-18 17:24:33 -0700
    • Engine revision 3459eb2436
    • Dart version 2.12.2

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\Admin\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] Connected device (2 available)
    • SM A310F (mobile) • 192.168.0.136:5555 • android-arm    • Android 7.0 (API 24)
    • Chrome (web)      • chrome             • web-javascript • Google Chrome 89.0.4389.128

• No issues found!
Process finished with exit code 0

If i have something else you need to know, tell me in the comments. Thanks for your help.



Solution 1:[1]

You had configured a flavor in middle of development, and working on a dirty state now.

You should run:

flutter clean

Then update the android studio run configuration to match your flavor (x86 is the emulator one)

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mariano ArgaƱaraz