不要将PageView居中 - Flutter
创始人
2025-01-10 20:00:13
0

要将PageView居中,可以在父容器中使用Align组件。以下是一个示例代码:

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('PageView'),
        ),
        body: Center(
          child: Container(
            width: MediaQuery.of(context).size.width,
            height: 200,
            child: Align(
              alignment: Alignment.center,
              child: PageView(
                children: [
                  Container(
                    color: Colors.red,
                    child: Center(
                      child: Text('Page 1'),
                    ),
                  ),
                  Container(
                    color: Colors.blue,
                    child: Center(
                      child: Text('Page 2'),
                    ),
                  ),
                  Container(
                    color: Colors.green,
                    child: Center(
                      child: Text('Page 3'),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}

在这个示例中,我们使用一个Container来限制PageView的宽度和高度。然后,我们使用Align组件将PageView居中。通过设置alignment属性为Alignment.center,我们可以将PageView在父容器中居中显示。

相关内容

热门资讯

黑科技好牌(wepoke透明黑... 赢率提升策略‌;黑科技好牌(wepoke透明黑科技)wepoke透明挂操作技巧(WepoKe)好像真...
黑科技线上(wepoke黑科技... 黑科技线上(wepoke黑科技)wepoke有吗(wepOke)果然存在有挂(有挂详细)-哔哩哔哩;...
黑科技科技(wepoke智能a... 黑科技科技(wepoke智能ai)wepoke软件透明挂是真的么(wEPoke)往昔有挂(有挂猫腻)...
黑科技科技(wepoke辅助插... 黑科技科技(wepoke辅助插件)wepoke真的有挂(wepoke)原来真的有挂(竟然有挂)-哔哩...
黑科技ai(wepoke智能a... 自定义系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助器,不管你是想分享给你好...
黑科技安卓版(wepokeai... 黑科技安卓版(wepokeai代打)wepoke辅助机器人(wepOkE)果然是有挂(有挂秘笈)-哔...
黑科技软件(wepoke智能a... 黑科技软件(wepoke智能ai)wopoker系统机制(wePoKe)一向是有挂(有挂猫腻)-哔哩...
黑科技中牌率(wepokeai... 黑科技中牌率(wepokeai代打)Wepoke辅助从哪里下载(WepoKe)本然真的是有挂(的确有...
黑科技存在(wepoke智能a... 黑科技存在(wepoke智能ai)wepoke系统(wEPOKE)最初是有挂(发现有挂)-哔哩哔哩关...
黑科技辅助挂(wepoke真的... 黑科技辅助挂(wepoke真的有挂)wopoker辅助真的假的(wEpOke)素来真的是有挂(确实有...