Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 在垂直页面视图中调整图像大小而不影响每个元素之间的空间?_Flutter_Spacing_Sizing_Flutter Pageview_Animatedcontainer - Fatal编程技术网

Flutter 在垂直页面视图中调整图像大小而不影响每个元素之间的空间?

Flutter 在垂直页面视图中调整图像大小而不影响每个元素之间的空间?,flutter,spacing,sizing,flutter-pageview,animatedcontainer,Flutter,Spacing,Sizing,Flutter Pageview,Animatedcontainer,您好,我在调整页面视图中动画容器的大小时遇到问题。如果我调整图像大小,我会损失图像之间的空间量,如果我纠正了一个条件语句来检查该容器是否为activePage(如果不高于另一个容器),但当我这样做时,我会失去页面视图的平滑度,那么如何在不影响卡片之间空间的情况下使卡片达到正确的大小? 链接到照片以显示所需的间距,链接到视频以显示所需的效果。 容器/图像的高度需要为499。 如果需要更多信息,请在评论中标记我 import 'package:flutter/material.dart'; impo

您好,我在调整页面视图中动画容器的大小时遇到问题。如果我调整图像大小,我会损失图像之间的空间量,如果我纠正了一个条件语句来检查该容器是否为activePage(如果不高于另一个容器),但当我这样做时,我会失去页面视图的平滑度,那么如何在不影响卡片之间空间的情况下使卡片达到正确的大小?
链接到照片以显示所需的间距,链接到视频以显示所需的效果。 容器/图像的高度需要为499。 如果需要更多信息,请在评论中标记我

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'GroupHome.dart';
import 'size_config.dart';
import 'CardTile.dart';

class GroupFeed extends StatefulWidget {
  GroupFeed({Key key}) : super(key: key);

  @override
  _GroupFeedState createState() => _GroupFeedState();
}

class _GroupFeedState extends State<GroupFeed> {
  final PageController _pageController = PageController(viewportFraction: 0.8);
  int _currentPage = 0;

  var _listSlide = [
    {
      'id': 0,
      'image': 'assets/highImg/food_image4.jpg',
      'text1': 'Old fashioned pancakes w/ farm fresh maple syrup',
      'profilePic': 'assets/highImg/sam.png',

    },
    {
      'id': 1,
      'image': 'assets/highImg/food_image3.jpg',
      'text1': 'Bittersweet chunky red berry popsicles',
      'profilePic': 'assets/highImg/sam.png',
    },
    {
      'id': 2,
      'image': 'assets/highImg/food_image5.jpg',
      'text1': 'Homemade honey granola topped with fresh berries',
      'profilePic': 'assets/highImg/sam.png',
      
    },
    {
      'id': 3,
      'image': 'assets/highImg/food_image7.jpg',
      'text1': 'Mint Oreo Cookie Parfait ',
      'profilePic': 'assets/highImg/sam.png',
  
    }
  ];

  @override
  void initState() {
    _pageController.addListener(() {
      int next = _pageController.page.round();
      if (_currentPage != next) {
        setState(() {
          _currentPage = next;
        });
      }
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    var data = MediaQuery.of(context);
    var screenHeight = data.size.height;
    var screenWidth = data.size.width;
    
    return Scaffold(
      body: SafeArea(
        bottom: false,
        top: false,
        child: 
            Stack(
          children: <Widget>[
            Padding(
                padding: EdgeInsets.only(top:43.5),
                          child: 
                          Container(
                            margin: EdgeInsets.only(top:56.5,),
                            height: 712,
                            decoration: BoxDecoration(
                    //color: Color(0x00000000),
                    borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(27.5),
                      topRight: Radius.circular(27.5),
                    ),
                  ),
                            child: ClipRRect(
                          
                    //color: Color(0x00000000),
                    borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(27.5),
                      topRight: Radius.circular(27.5),
                    ),
                  
                                                          child: Stack(
                                                            children: [
                                                              PageView.builder(
                scrollDirection: Axis.vertical,
                controller: _pageController,
                itemCount: _listSlide.length,
                itemBuilder: (_, currentIndex) {
                  bool activePage = currentIndex == _currentPage;
                  return Stack(
                      children: <Widget>[
                        CardTile(
                              activePage: activePage,
                              image: _listSlide[currentIndex]['image'],
                        ),
                },
              
              ),
                                                            ],
                                                          ),
                            ),
                          ),
            ),
           GestureDetector(
                    onTap: () {
                    Navigator.push(
            context,
                        MaterialPageRoute(
                            builder: (context) => GroupHome (),fullscreenDialog: true),
                    );
                    },
                    child:
                     Stack(
                      children: <Widget>[
                        Stack(
                          children: <Widget>[
                            ///25,56
                            Padding(
                              padding:
                                   EdgeInsets.fromLTRB(25, 52, 0, 0),
                              child: Container(
                                width: 30.0,
                                height: 30.0,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.all(
                                      Radius.elliptical(9999.0, 9999.0)),
                                  color: const Color(0xffffffff),
                                ),
                              ),
                            ),
                            Padding(
                              padding: EdgeInsets.fromLTRB(36, 60, 0, 0),
                              child: Container(
                                width: 8.5,
                                height: 14.9,
                                decoration: BoxDecoration(
                              image: DecorationImage(
                                image: const AssetImage(
                                    'assets/highImg/back.png'),
                                fit: BoxFit.fill,
                              ),
                                ),
                              ),
                            ),
                          ],
                        ),
                      ],
                    ),
                 ),
          ],
        ),
        //   ],
        //),
      ),
    );
  }
}

class CardTile extends StatelessWidget {

  final String image;
  final bool activePage;


  const CardTile({Key key, this.image, this.activePage}) : super(key: key);
  
  @override
  Widget build(BuildContext context) {
    var data = MediaQuery.of(context);
    var screenHeight = data.size.height;
    var screenWidth = data.size.width;
    final double top =  /*this.activePage ?*/ (0/812)*screenHeight /*:(0/812)*screenHeight*/;///(185/812)*screenHeight : (235/812)*screenHeight; //50 ///
    final double bottom = /*this.activePage ? */(10/812)*screenHeight/*: *(25/812)*screenHeight*/ ; //(125/812)*screenHeight : (175/812)*screenHeight;
    final double blur =  5; //30
    final double offset = (2.5/375)*screenWidth; //20
    final double sides = 23;//30:2;
    double space =0;

    return  Transform.translate(
          offset:Offset(0,space),
          child: Padding(
        padding: EdgeInsets.only(bottom:0),
        child: Transform.translate(
          offset: Offset(0,-45),
                child: AnimatedContainer(
            //height: 509,
            //height: this.activePage ?  499: 399,
            duration: Duration(milliseconds: 00),
            curve:  Curves.easeOutQuint,
            //padding: EdgeInsets.only(bottom:25),
            margin: EdgeInsets.only(top: top, bottom: bottom, right: sides,left:sides), //right: 15,left:15
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(27.5),
                image: DecorationImage(
                    image: AssetImage(this.image), fit: BoxFit.cover),
                boxShadow: [
                  BoxShadow(
                    color: Color(0x80000000),
                    blurRadius: blur,
                    offset: Offset(offset, offset)
                  )
                ]),
          ),
        ),
      ),
    );
}
} 
导入“包装:颤振/材料.省道”;
导入“package:flatter/rendering.dart”;
导入“package:flatter_svg/flatter_svg.dart”;
导入“GroupHome.dart”;
导入'size_config.dart';
导入“carddile.dart”;
类GroupFeed扩展StatefulWidget{
GroupFeed({Key}):超级(Key:Key);
@凌驾
_GroupFeedState createState()=>\u GroupFeedState();
}
类_GroupFeedState扩展状态{
final PageController _PageController=PageController(viewportFraction:0.8);
int _currentPage=0;
变量_列表幻灯片=[
{
“id”:0,
“image”:“assets/highImg/food_image4.jpg”,
“文本1”:带有农场新鲜枫树糖浆的老式煎饼,
“profilePic”:“assets/highImg/sam.png”,
},
{
“id”:1,
“image”:“assets/highImg/food_image3.jpg”,
“text1”:“苦乐参半的大块红莓冰棒”,
“profilePic”:“assets/highImg/sam.png”,
},
{
“id”:2,
“image”:“assets/highImg/food_image5.jpg”,
“text1”:“自制蜂蜜格兰诺拉麦片配新鲜浆果”,
“profilePic”:“assets/highImg/sam.png”,
},
{
"id":3,,
“image”:“assets/highImg/food_image7.jpg”,
“text1”:“薄荷奥利奥饼干冻糕”,
“profilePic”:“assets/highImg/sam.png”,
}
];
@凌驾
void initState(){
_pageController.addListener((){
int next=_pageController.page.round();
如果(_currentPage!=下一步){
设置状态(){
_当前页面=下一页;
});
}
});
super.initState();
}
@凌驾
小部件构建(构建上下文){
var data=MediaQuery.of(上下文);
var screenHeight=data.size.height;
var screenWidth=data.size.width;
返回脚手架(
正文:安全区(
底部:错误,
上图:错,
儿童:
堆叠(
儿童:[
填充物(
填充:仅限边缘设置(顶部:43.5),
儿童:
容器(
页边空白:仅限边集(顶部:56.5,),
身高:712,
装饰:盒子装饰(
//颜色:颜色(0x00000000),
borderRadius:仅限borderRadius(
左上:半径。圆形(27.5),
右上角:半径。圆形(27.5),
),
),
孩子:ClipRRect(
//颜色:颜色(0x00000000),
borderRadius:仅限borderRadius(
左上:半径。圆形(27.5),
右上角:半径。圆形(27.5),
),
子:堆栈(
儿童:[
PageView.builder(
滚动方向:轴垂直,
控制器:_pageController,
itemCount:\u listSlide.length,
itemBuilder:(\ux,currentIndex){
bool activePage=currentIndex==\u currentPage;
返回堆栈(
儿童:[
卡地瓦(
activePage:activePage,
图像:_listSlide[currentIndex]['image'],
),
},
),
],
),
),
),
),
手势检测器(
onTap:(){
导航器。推(
上下文
材料路线(
生成器:(context)=>GroupHome(),fullscreenDialog:true),
);
},
儿童:
堆叠(
儿童:[
堆叠(
儿童:[
///25,56
填充物(
衬垫:
来自LTRB(25,52,0,0)的边集,
子:容器(
宽度:30.0,
身高:30.0,
装饰:盒子装饰(
borderRadius:borderRadius.all(
椭圆半径(9999.0,9999.0)),
颜色:常量颜色(0xFFFFFF),
),
),
),
填充物(
填充:从LTRB(36,60,0,0)开始的边缘设置,
子:容器(
宽度:8.5,
身高:14.9,
装饰:盒子装饰(
图像:装饰图像(
图片:const AssetImage(