Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.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 添加两个容器,一个用于文本,另一个用于viewgrid_Flutter - Fatal编程技术网

Flutter 添加两个容器,一个用于文本,另一个用于viewgrid

Flutter 添加两个容器,一个用于文本,另一个用于viewgrid,flutter,Flutter,我从昨天开始就尝试过了,我对颤振非常陌生,所以我试图了解颤振小部件是如何协同工作的。我想要两个容器;一个用于带文本的类似介绍,第二个用于viewgrid 到目前为止我所做的: import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context

我从昨天开始就尝试过了,我对颤振非常陌生,所以我试图了解颤振小部件是如何协同工作的。我想要两个容器;一个用于带文本的类似介绍,第二个用于viewgrid

到目前为止我所做的:

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: 
              Container(
alignment: Alignment.centerLeft,
        height: 200,
        width: double.infinity,
        decoration: BoxDecoration(  
           borderRadius: BorderRadius.only(
              bottomLeft: Radius.circular(40.0),
              bottomRight: Radius.circular(40.0)
            ) ,
          gradient: LinearGradient(  
            begin: Alignment.topRight,
            end: Alignment.bottomLeft,
            colors: [
              Color(0xFF3383CD),
              Color(0xFF11249F)
            ]
          )
        ),

child: Column(children: <Widget>[

    Text('Deliver features faster', style: TextStyle(fontWeight: FontWeight.bold),
    ),
    Text('Craft beautiful UIs', style: TextStyle(fontWeight: FontWeight.bold),
    ),

],


),

      ),
      Container (  

      )

      ),
    );
  }
}
导入“包装:颤振/材料.省道”;
void main()=>runApp(MyApp());
类MyApp扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回材料PP(
标题:“欢迎来到弗利特”,
家:脚手架(
appBar:appBar(
标题:文本(“欢迎光临颤振”),
),
正文:
容器(
对齐:alignment.centerLeft,
身高:200,
宽度:double.infinity,
装饰:盒子装饰(
borderRadius:仅限borderRadius(
左下角:半径。圆形(40.0),
右下角:半径。圆形(40.0)
) ,
梯度:线性梯度(
开始:Alignment.topRight,
结束:对齐。左下角,
颜色:[
颜色(0xFF3383CD),
颜色(0xFF11249F)
]
)
),
子项:列(子项:[
Text('Deliver features faster',style:TextStyle(fontwweight:fontwweight.bold),
),
Text('Craft Beauty UI',样式:TextStyle(fontWeight:fontWeight.bold),
),
],
),
),
货柜(
)
),
);
}
}

它给了我以下消息:
位置参数太多:应为0,但找到1。
尝试删除额外的位置参数,或指定命名参数的名称。

您的语法不正确。最后一个
容器
不在
小部件内。

容器只能有一个子项,因此您遇到的问题是,您必须向其子项添加两个小部件,请尝试在列内添加最后一个容器

您还可以使用以下代码在列中设置2个容器:

Container(
child: Column(
  children: <Widget>[
    Container(
      // For text
    ),
    Container(
      // For Viewgrid
    )
  ]
)
容器(
子:列(
儿童:[
容器(
//用于文本
),
容器(
//用于Viewgrid
)
]
)

)脚手架的
主体
属性接受单个小部件。您可能会搜索一个可以接受多个子项的小部件,这样您就可以布置两个容器,最常见的是列,它允许您垂直布局小部件,以及行,它允许您水平布局小部件。我建议阅读,以便更好地理解总体布局。

这是否回答了您的问题?如何设置每个容器的高度?@Anabe只需添加“高度”属性即可