Why isn’t the Flutter page starting at the beginning by default?

Asked

Viewed 42 times

0

The scrollable page is starting at a place below the beginning, not in the middle, not at the end, I initially thought it was because I was using a Listview inside a Container, without specifying the heightand the widthof Container, but even after placing the result remains the same, if you can help me make the page start from the beginning thank you, follow the code,

@override

Widget build(BuildContext context) {
final double screenWidth = MediaQuery.of(context).size.width;
final double screenHeight = MediaQuery.of(context).size.height;

return PlatformScaffold(
  appBar: PlatformAppBar(
    title: Text("Relatório por Unidade"),
    android: (_) => MaterialAppBarData(
      backgroundColor: Colors.blue,
      leading: FlatButton(
        onPressed: () {
          Navigator.pop(context);
        },
        child: Icon(
          Icons.arrow_back,
          color: Colors.white,
        ),
      ),
    ),
  ),
  body: Container(
    height: MediaQuery.of(context).size.height,
    width: MediaQuery.of(context).size.width,
    color: Colors.grey[200],
    child: ListView( . . .)
    )
   )
  )
 );
}

The page starts like this,
inserir a descrição da imagem aqui


An important observation is that when trying to scroll to the page for the beginning it goes up to the beginning, but soon back to this image above,


foto ao segurar a página no início

  • Are you wearing any Stack?

  • No, only Container and inside Listview. In this case, that "body" is from Scaffold.

  • The cool would be you edit your question and put your entire Widget tree of that class in question... Sometimes you’re doing something wrong at another point, because this little structure that you’ve shown, it doesn’t help at all.

  • I will be posting, the only different is q to using a library that changes the aesthetics of the widget according to the IOS or Android platform.

  • @Paulooyama as already suggested the ideal is you post the full code, at least from the page where the problem is happening, the problem may perhaps be in this library that you are ultilizando, Flutter defends the use of a uniform Material Layout or Cupertino ... or a customized, but don’t mix them! If you need different layouts for different platforms, then you’ll need to write one page for IOS and another for Android. Update your question by putting at least the Scaffold of this page, next to the kind of Scroll you’re using.

  • Expensive as has the implementation of Android only, and the layout of the images does not match the implementation, so the way you’re using iOS, right?... Where is this app bar coming from with the title "Report per Vehicle"? Maybe if you implement iOS the error will be fixed.

  • Matheus the IOS style, comes from the Plataform plugin, this library allows a Widget as for example the "Platformscaffold" has the same style of the IOS or Android platform, so this Widget is making different styles in one code, depending on the user’s OS

  • You put that your Container should be the same height in px as the screen size of the appliance, but you’re forgetting that you an Appbar on top, which means that the piece corresponding to the height of the Appbar will be hidden initially unless the user makes a scroll, tries to change that height taking into account the Appbar and see what happens

  • I tried to change the screen size to 2x, but still, it did not work scroll ?

  • Try putting your Listview inside a Scrollcontroller, I’ve never had this problem, but maybe I can fix it. Maybe if you put all your widgets tree we can help you better

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.