Ask Your Question
2

How do I position the Widget in the middle of the body using tabBarView()?

asked 2021-11-21 11:00:00 +0000

bukephalos gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-12-01 18:00:00 +0000

scrum gravatar image

To position a widget in the middle of the body using tabBarView(), you can wrap the widget in a Center widget and place it as a child of the TabBarView.

Here's an example code snippet:

Scaffold(
  appBar: AppBar(
    title: Text('Example'),
  ),
  body: TabBarView(
    children: [
      // First Tab
      Center(
        child: Text('This is the first tab'),
      ),

      // Second Tab
      Center(
        child: Text('This is the second tab'),
      ),

      // Third Tab
      Center(
        child: Text('This is the third tab'),
      ),
    ],
  ),
);

By wrapping the Text widgets in a Center widget, they will be horizontally and vertically centered in the TabBarView.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-11-21 11:00:00 +0000

Seen: 17 times

Last updated: Dec 01 '22