如何在Flutter中进行此UI设计
我正在制作一个简单的颤振应用程序,它有一堆圆形图标按钮,显示在一行中,直到没有更多的空间,其余的按钮则显示在下一行中,直到没有更多的空间,依此类推 然而,我找不到一个合适的方法来构造小部件。(仍然是新的颤振) 下面是我想要的结果:(应该支持两种设备方向) 一个真实的例子: 标题不是很好,但我不知道该怎么称呼这个设计。您可以使用如何在Flutter中进行此UI设计,flutter,user-interface,dart,Flutter,User Interface,Dart,我正在制作一个简单的颤振应用程序,它有一堆圆形图标按钮,显示在一行中,直到没有更多的空间,其余的按钮则显示在下一行中,直到没有更多的空间,依此类推 然而,我找不到一个合适的方法来构造小部件。(仍然是新的颤振) 下面是我想要的结果:(应该支持两种设备方向) 一个真实的例子: 标题不是很好,但我不知道该怎么称呼这个设计。您可以使用Gridview() 请看- 我为你制作了一个演示 您也可以复制我的代码 这是我的密码- import 'package:flutter/material.dart'
Gridview()
请看-
我为你制作了一个演示
您也可以复制我的代码
这是我的密码-
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
MyHomePage({
Key key,
}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Help from Abir"),
),
body: Center(
child: OrientationBuilder(builder: (context, orientation) {
return GridView.count(
padding: EdgeInsets.all(10.0),
crossAxisCount: orientation == Orientation.portrait ? 3 : 5,
children: <Widget>[
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
],
);
}),
),
);
}
}
导入“包装:颤振/材料.省道”;
类MyHomePage扩展StatefulWidget{
我的主页({
关键点,
}):super(key:key);
@凌驾
_MyHomePageState createState()=>\u MyHomePageState();
}
类_MyHomePageState扩展状态{
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(
标题:文本(“来自Abir的帮助”),
),
正文:中(
子:方向生成器(生成器:(上下文,方向){
返回GridView.count(
填充:所有边缘设置(10.0),
crossAxisCount:orientation==orientation.portrait?3:5,
儿童:[
纵队(
儿童:[
容器(
装饰:盒子装饰(
形状:BoxShape.circle,
颜色:颜色。琥珀色,
),
孩子:我的钮扣(
iconSize:60,
图标:图标(图标。空调单元),
按下:(){},
),
),
文本(“项目”)
],
),
纵队(
儿童:[
容器(
装饰:盒子装饰(
形状:BoxShape.circle,
颜色:颜色。琥珀色,
),
孩子:我的钮扣(
iconSize:60,
图标:图标(图标。空调单元),
按下:(){},
),
),
文本(“项目”)
],
),
纵队(
儿童:[
容器(
装饰:盒子装饰(
形状:BoxShape.circle,
颜色:颜色。琥珀色,
),
孩子:我的钮扣(
iconSize:60,
图标:图标(图标。空调单元),
按下:(){},
),
),
文本(“项目”)
],
),
纵队(
儿童:[
容器(
装饰:盒子装饰(
形状:BoxShape.circle,
颜色:颜色。琥珀色,
),
孩子:我的钮扣(
iconSize:60,
图标:图标(图标。空调单元),
按下:(){},
),
),
文本(“项目”)
],
),
纵队(
儿童:[
容器(
装饰:盒子装饰(
形状:BoxShape.circle,
颜色:颜色。琥珀色,
),
孩子:我的钮扣(
iconSize:60,
图标:图标(图标。空调单元),
按下:(){},
),
),
文本(“项目”)
],
),
纵队(
儿童:[
容器(
装饰:盒子装饰(
形状:BoxShape.circle,
颜色:颜色。琥珀色,
),
孩子:我的钮扣(
iconSize:60,
图标:图标(图标。空调单元),
按下:(){},
),
),
文本(“项目”)
],
),
纵队(
儿童:[
容器(
装饰:盒子装饰(
形状:BoxShape.circle,
颜色:颜色。琥珀色,
),
孩子:我的钮扣(
iconSize:60,
图标:图标(图标。空调单元),
按下:(){},
),
),
文本(“项目”)
],
),
纵队(
儿童:[
容器(
装饰:盒子装饰(
形状:BoxShape.circle,
颜色:颜色。琥珀色,
),
孩子:我的钮扣(
iconSize:60,
图标:图标(图标。空调单元),
按下:(){},
),
),
文本(“项目”)
],
),
纵队(
儿童:[
容器(
装饰:盒子装饰(
形状:BoxShape.circle,
颜色:颜色。琥珀色,
),
孩子:我的钮扣(
iconSize:60,
图标:图标(图标。空调单元),
按下:(){},
),
),
文本(“项目”)
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
MyHomePage({
Key key,
}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Help from Abir"),
),
body: Center(
child: OrientationBuilder(builder: (context, orientation) {
return GridView.count(
padding: EdgeInsets.all(10.0),
crossAxisCount: orientation == Orientation.portrait ? 3 : 5,
children: <Widget>[
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: IconButton(
iconSize: 60,
icon: Icon(Icons.ac_unit),
onPressed: () {},
),
),
Text("Item")
],
),
],
);
}),
),
);
}
}