Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/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_User Interface_Containers_Flutter Layout_Flutter Dependencies - Fatal编程技术网

Flutter 如何在颤振中将一个容器夹在另一个容器上?

Flutter 如何在颤振中将一个容器夹在另一个容器上?,flutter,user-interface,containers,flutter-layout,flutter-dependencies,Flutter,User Interface,Containers,Flutter Layout,Flutter Dependencies,我想建立一个可重用的卡片小部件,它将有一些自定义设计布局的图像和文本。我尽了我所能,但没能达到预期的效果。任何帮助都将不胜感激。 使用ClipRRect执行此操作: ClipRRect( borderRadius: BorderRadius.circular(50.0), //clipping the whole widget child: Container( height: MediaQuery.of(context).size.height * 0.4, //I adj

我想建立一个可重用的卡片小部件,它将有一些自定义设计布局的图像和文本。我尽了我所能,但没能达到预期的效果。任何帮助都将不胜感激。


使用
ClipRRect
执行此操作:

ClipRRect(
  borderRadius: BorderRadius.circular(50.0), //clipping the whole widget
  child: Container(
    height: MediaQuery.of(context).size.height * 0.4, //I adjusted here for responsiveness problems on my device
    width: MediaQuery.of(context).size.width * 0.5,
    color: Colors.white,
    child: LayoutBuilder(
      builder: (context, constraint) {
        return Stack(
          children: [
            Center(
              child: Icon(
                Icons.trip_origin,
                size: constraint.biggest.width,
                color: Colors.grey[300],
              ),
            ),
            Positioned(
              right: 0,
              left: 0,
              top: 20.0,
              child: Icon(
                Icons.sports_volleyball_rounded, //just to represent the ball
                size: constraint.biggest.width * 0.5,
              ),
            ),
            Positioned(
              bottom: 0.0,
              child: Container(
                alignment: Alignment.center,
                height: MediaQuery.of(context).size.height * 0.1,
                width: constraint.biggest.width,
                color: Colors.yellow[700],
                child: Text(
                  'Sports',
                  style: Theme.of(context)
                      .textTheme
                      .headline3
                      .copyWith(color: Colors.white),
                ),
              ),
            ),
          ],
        );
      },
    ),
  ),
);

使用
ClipRRect
执行此操作:

ClipRRect(
  borderRadius: BorderRadius.circular(50.0), //clipping the whole widget
  child: Container(
    height: MediaQuery.of(context).size.height * 0.4, //I adjusted here for responsiveness problems on my device
    width: MediaQuery.of(context).size.width * 0.5,
    color: Colors.white,
    child: LayoutBuilder(
      builder: (context, constraint) {
        return Stack(
          children: [
            Center(
              child: Icon(
                Icons.trip_origin,
                size: constraint.biggest.width,
                color: Colors.grey[300],
              ),
            ),
            Positioned(
              right: 0,
              left: 0,
              top: 20.0,
              child: Icon(
                Icons.sports_volleyball_rounded, //just to represent the ball
                size: constraint.biggest.width * 0.5,
              ),
            ),
            Positioned(
              bottom: 0.0,
              child: Container(
                alignment: Alignment.center,
                height: MediaQuery.of(context).size.height * 0.1,
                width: constraint.biggest.width,
                color: Colors.yellow[700],
                child: Text(
                  'Sports',
                  style: Theme.of(context)
                      .textTheme
                      .headline3
                      .copyWith(color: Colors.white),
                ),
              ),
            ),
          ],
        );
      },
    ),
  ),
);

很高兴我能帮忙!很高兴我能帮忙!