简体   繁体   English

Flutter:堆栈重叠小部件与第二个小部件

[英]Flutter: Stack Overlap widget with second widget

Image link图片链接

How can I push the child widget outside the stack's bound.如何将子小部件推到堆栈边界之外。

I want to overlap the search bar at AppBar widget.我想在 AppBar 小部件上重叠搜索栏。

Stack's overflow property not working what we use instead of it. Stack 的溢出属性不能正常工作,而不是我们使用的。

I am using the positioned widget to move on child widget to outside the stack's boundary, but it remains same I am getting issue I need solution for this.我正在使用定位的小部件将子小部件移动到堆栈边界之外,但它保持不变我遇到了我需要解决此问题的问题。

This is my code这是我的代码


 PreferredSize _buildAppBar() {
return PreferredSize(
  preferredSize: const Size.fromHeight(100),
  child: AppBar(
    centerTitle: true,
    elevation: 0,
    backgroundColor: Colors.transparent,
    flexibleSpace: Stack(
      clipBehavior: Clip.none,
      fit: StackFit.loose,
      // alignment: AlignmentDirectional.bottomEnd,
      children: [
        Expanded(
          child: Container(
            decoration: const BoxDecoration(
              image: DecorationImage(
                  image: AssetImage('images/gym.jpg'), fit: BoxFit.cover),
            ),
          ),
        ),
        Positioned(
          bottom: 0,
          left: 0,
          right: 0,
          // top: 90,
          child: Container(
            margin: const EdgeInsets.symmetric(horizontal: 10),
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(30),
                // ignore: prefer_const_constructors
                boxShadow: const [
                  BoxShadow(color: Colors.black12, blurRadius: 5)
                ]),
            child: TextFormField(
              // controller: controller,
              decoration: InputDecoration(
                  border: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(30),
                    borderSide: BorderSide.none,
                  ),
                  hintText: 'Search Your Product',
                  hintStyle: TextStyle(color: Colors.grey[400]),
                  contentPadding:
                      const EdgeInsets.only(left: 22, right: 12),
                  fillColor: Colors.white,
                  filled: true,
                  suffixIcon: IconButton(
                      onPressed: () {},
                      icon: const Icon(
                        Icons.search,
                        size: 30,
                      ))),
              // obscureText: obscureText,
            ),
          ),
        ),
      ],
    ),
    title: const Text(
      'Home',
      style: TextStyle(
        color: Colors.white,
      ),
    ),
  ),
);

} }

One of possilbe ways is to use CustomScrollView with SliverAppBar and Stack一种可能的方法是将 CustomScrollView 与 SliverAppBar 和 Stack 一起使用

Here is the link to one of the solutions这是解决方案之一的链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM