【问题标题】:create custom intro screen slider in flutter在颤振中创建自定义介绍屏幕滑块
【发布时间】:2020-04-15 11:25:28
【问题描述】:

我需要创建这样的东西

我正在使用来自 Flutter 的介绍滑块插件,但它不支持 2 张图片 我试过了

 slides.add(
      new Slide(
        pathImage: 'assets/logo_1.png',
        description:
            "Find trusted help for everything on your to-do-list.",
        styleDescription: TextStyle(
          color: Colors.black,
          fontSize: 18.0,
        ),
        marginDescription: EdgeInsets.only(top: 10.0),
        backgroundImage: "assets/ss4.jpg",
        backgroundOpacity: 0.0,
      ),
    );

 IntroSlider(
              slides: this.slides,
              colorActiveDot: Color(0xFF17b01b),
              sizeDot: 10.0,
              isShowSkipBtn: false,
              styleNameDoneBtn: TextStyle(
                color: Color(0xFF17b01b),
                fontSize: 15.0,
                fontWeight: FontWeight.bold,
              ),
              nameDoneBtn: 'Got it >',
              nameNextBtn: 'Got it >',
                  onDonePress:this.onDonePress ,
            )),

介绍滑块支持两张图片,但第二张用于背景图片,所以我的图片在介绍滑块中占据屏幕的完整背景,我如何将第二张图片设置在中心,就像我附加的图片一样? 或者如何在介绍滑块中为背景图像提供高度宽度??

【问题讨论】:

  • 能否为滑块添加两张图片。
  • 请注意,backgroundOpacity 设置为 0,因此它不会显示背景图片。

标签: flutter flutter-layout


【解决方案1】:

正如插件文档https://pub.dev/packages/intro_slider 中所述,您可以像这样设置图像的高度和宽度:

new Slide(
        pathImage: 'assets/logo_1.png',
        // Added the next 3 lines
        heightImage: 500,
        widthImage: 300,
        foregroundImageFit: BoxFit.contain,
        description:
            "Find trusted help for everything on your to-do-list.",
        styleDescription: TextStyle(
          color: Colors.black,
          fontSize: 18.0,
        ),
        marginDescription: EdgeInsets.only(top: 10.0),
        backgroundImage: "assets/ss4.jpg",
        backgroundOpacity: 0.0,
      ),

编辑

对不起,我误解了这个问题。

您可以将任何自定义小部件放入 centerWidget 属性中,如下所示:

new Slide(
        centerWidget: Column(
            shrinkWrap: true,
            children: <Widget>[
                Text("image1 placeholder"),
                Text("some text"),
                Text("image2 placeholder"),
            ],
        ),
        backgroundImage: "assets/ss4.jpg",
        backgroundOpacity: 0.0,
      ),

【讨论】:

  • 无法在上传的图片@Zvi Karp 中设置我想要的图片
  • @urvashi 对不起,我误解了这个问题,已经更新了答案。
猜你喜欢
  • 2021-10-25
  • 2020-04-13
  • 1970-01-01
  • 2018-12-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多