Могу ли я добавить кнопку радиуса в режиме прокрутки для одного ребенка? - PullRequest
0 голосов
/ 28 мая 2020

Я использую виджет Stack, в котором у меня есть 2 виджета, один - это просто изображение, а другой - Singlechildscrollview.

Мне нужно добавить кнопку в нижнем колонтитуле экрана и исправить это (не подвижный). Необходимо исправить на экране при прокрутке Singlechildscrollview или нет. Мне нужно исправить эту кнопку. Я не уверен, как я могу это сделать, потому что, если я отключу кнопку в Singlechildscrollview, она будет отображаться только при прокрутке. Мне нужно исправить, когда я прокручиваю или не должна появляться кнопка.

Вот мой код:

Stack(
      children: <Widget>[
        Container(
          padding: EdgeInsets.only(top: statusBarHeight * 0.8),
          height: height * 0.4,
          decoration: BoxDecoration(
            image: DecorationImage(
              image: AssetImage(
                'assets/images/place2.jpg',
              ),
              fit: BoxFit.fill,
            ),
          ),
        ),
        SingleChildScrollView(
          child: Padding(
            padding: EdgeInsets.only(top: height * 0.3),
            child: SingleChildScrollView(
              child: ClipRRect(
                borderRadius: BorderRadius.only(
                    topRight: Radius.circular(30),
                    topLeft: Radius.circular(30)),
                child: Container(
                  decoration: BoxDecoration(
                    color: Colors.white,
                  ),
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      SizedBox(
                        height: height * 0.05,
                      ),
                      Container(
                        width: width,
                        margin: EdgeInsets.only(left: width * 0.03),
                        child: Text(
                          'NYC Food Festival',
                          textAlign: TextAlign.left,
                          style: TextStyle(fontSize: 30),
                        ),
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Container(
                        margin: EdgeInsets.only(left: width * 0.03),
                        child: Row(
                          children: <Widget>[
                            Icon(
                              Icons.calendar_today,
                              size: 20,
                              color: Color(0xff808080),
                            ),
                            SizedBox(width: width * 0.02), // give it width
                            Column(
                              children: <Widget>[
                                Text(
                                  'Sat, May 25, 2020',
                                  style: TextStyle(
                                      color: Color(0xff000000),
                                      fontWeight: FontWeight.bold,
                                      fontSize: 15),
                                ),
                              ],
                            )
                          ],
                        ),
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Container(
                        margin: EdgeInsets.only(left: width * 0.03),
                        child: Row(
                          children: <Widget>[
                            Icon(
                              Icons.attach_money,
                              size: 20,
                              color: Color(0xff808080),
                            ),
                            SizedBox(width: width * 0.02), // give it width
                            Column(
                              children: <Widget>[
                                Text(
                                  '25,000 PKR',
                                  style: TextStyle(
                                      color: Color(0xff000000),
                                      fontWeight: FontWeight.bold,
                                      fontSize: 15),
                                ),
                              ],
                            )
                          ],
                        ),
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Container(
                        width: width,
                        margin: EdgeInsets.only(left: width * 0.03),
                        child: Text(
                          'Snaps',
                          textAlign: TextAlign.left,
                          style: TextStyle(fontSize: 25),
                        ),
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Container(
                          child: Column(
                            children: <Widget>[
                              CarouselSlider(
                                options: CarouselOptions(
                                  autoPlay: true,
                                  aspectRatio: 2.0,
                                  enlargeCenterPage: true,
                                ),
                                items: imageSliders,
                              ),
                            ],
                          )),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Container(
                        width: width,
                        margin: EdgeInsets.only(left: width * 0.03),
                        child: Text(
                          'About',
                          textAlign: TextAlign.left,
                          style: TextStyle(fontSize: 25),
                        ),
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Container(
                          padding: EdgeInsets.only(
                              right: width * 0.03, left: width * 0.03),
                          child: DescriptionTextWidget(
                              text:
                                  "Flutter is Google’s mobile UI framework for crafting high-quality native interfaces on iOS and Android in record time. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source.")
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Container(
                        width: width,
                        margin: EdgeInsets.only(left: width * 0.03),
                        child: Text(
                          'Included',
                          textAlign: TextAlign.left,
                          style: TextStyle(fontSize: 25),
                        ),
                      ),
                      SizedBox(
                        height: height * 0.02,
                      ),
                      Included(),
                      SizedBox(
                        height: height * 0.01,
                      ),
                      Included(),
                      SizedBox(
                        height: height * 0.01,
                      ),
                      Included(),
                      SizedBox(
                        height: height * 0.01,
                      ),




                    ],
                  ),
                ),
              ),
            ),
          ),
        )
      ],
    )

Вот результат текущего просмотра:

enter image description here

Вот что я хочу:

enter image description here

Ответы [ 2 ]

1 голос
/ 28 мая 2020

Вы можете сравнительно легко получить такой вид.

Вот пример:


class BottomFadeButton extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.transparent,
        appBar: AppBar(
          title: Text("Bottom Fade Button"),
        ),
        body: Container(
          // height: 500,
          color: Colors.amberAccent,
          child: Stack(
            children: <Widget>[
              Container(
                child: ListView.builder(
                    itemCount: 100,
                    itemBuilder: (context, index) {
                      return ListTile(
                        title: Text("Hello "),
                      );
                    }),
              ),

             // Bottom Button
              Positioned(
                bottom: 0,
                left: 0,
                right: 0,
                child: Container(
                  height: 100,
                  decoration: BoxDecoration(
                    // color: Color.fromARGB(110, 255, 255, 255),
                    borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(20),
                      topRight: Radius.circular(20),
                    ),
                    gradient: LinearGradient(
                      colors: [
                        Color.fromARGB(30, 255, 255, 255),
                        Color.fromARGB(255, 255, 255, 255),
                      ],
                      begin: Alignment.topCenter,
                      end: Alignment.bottomCenter,
                    ),
                  ),
                  child: Center(
                    child: InkWell(
                      child: Container(
                        padding: EdgeInsets.symmetric(
                          horizontal: 100,
                          vertical: 20,
                        ),
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(30),
                          color: Colors.blueAccent,
                        ),
                        child: Text(
                          "BUY TICKETS",
                          style: TextStyle(
                              fontWeight: FontWeight.bold,
                              fontSize: 20,
                              color: Colors.white),
                        ),
                      ),
                      onTap: () {
                        return print("Tap");
                      },
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Вывод:

0 голосов
/ 28 мая 2020

да, вы можете добавить кнопку в стек, а затем обернуть виджет выравнивания с помощью alignment.bottom_center

...