我正在尝试使布局看起来像这样:
现在,我得到的结果就是这个:
https://i.gyazo.com/af20c9fc17b14e3afaf1207691569f72.png
我无法发布图片,因为我没有10个声誉,对于链接:(
应用程序的代码是这样的:
import 'dart:ui';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.transparent,
body:Column(
children: <Widget>[
Expanded(
flex: 1,
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/steph.jpg'),
fit: BoxFit.fitHeight,
),
),
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 275),
child: Container(
margin: EdgeInsets.all(24),
height: 325,
width: 336,
decoration: BoxDecoration(
image:DecorationImage(
image: AssetImage('assets/images/whitebox.jpg'),
fit: BoxFit.fitHeight,
),
borderRadius: BorderRadius.all(Radius.circular(40.0)),
),
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.all(0),
child:Center(
child: Container(
margin: EdgeInsets.only(left:18,bottom: 160),
height: 80,
width: 300,
decoration: BoxDecoration(
image:DecorationImage(
image: AssetImage('assets/images/blackbox.jpg'),
fit: BoxFit.fitWidth,
),
borderRadius: BorderRadius.all(Radius.circular(30.0)),
),
child: Center(
child: Text(
"#30 | STEPHEN CURRY",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white, fontSize: 26,fontWeight: FontWeight.bold),
),
),
),
),
),
Expanded(
child: Container(
padding: EdgeInsets.only(top: 120),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Center(
child: Text(
"36",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
),
),
),
],
),
),
Expanded(
child: Column(
children: <Widget>[
Expanded(
flex: 1,
child: Center(
child: Text(
"Points",
textAlign: TextAlign.center,
),
),
),
Expanded(
flex: 1,
child: Center(
child: Text(
"36",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
),
),
),
],
),
),
Expanded(
child: Column(
children: <Widget>[
Expanded(
flex: 1,
child: Center(
child: Text(
"Points",
textAlign: TextAlign.center,
),
),
),
Expanded(
flex: 1,
child: Center(
child: Text(
"36",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
),
),
),
],
),
),
],
)
),
),
],
),
),
),
],
),
),
),
],
),
),
);
}
}
我尝试更改Expanded小部件中的padding和Containers,但没有帮助。抱歉,这个愚蠢的问题让我有些陌生,但是您知道如何调整列的大小以使其与第一个图像相似吗?
答案 0 :(得分:0)
我创建了与您期望的类似的东西。我希望这段代码可以帮助您实现确切的用户界面。
import 'dart:ui';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
),
backgroundColor: Colors.transparent,
body:Column(
children: <Widget>[
Expanded(
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/bg.jpg'),
fit: BoxFit.fitHeight,
),
),
),
),
Container(
height: 100.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/bg.jpg'),
fit: BoxFit.fitHeight,
),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 20.0,
),
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text("2",style: TextStyle(color: Colors.white,fontSize: 20),),
Text("abc",style: TextStyle(color: Colors.white,fontSize: 20),)
],
),
SizedBox(
width: 20.0,
),
Container(
width: 4.0,
height: 60.0,
decoration: BoxDecoration(
color: Colors.white,
)
),
SizedBox(
width: 20.0,
),
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text("2",style: TextStyle(color: Colors.white,fontSize: 20),),
Text("abc",style: TextStyle(color: Colors.white,fontSize: 20),)
],
),
],
),
),
Container(
height: 200.0,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/bg.jpg'),
fit: BoxFit.fitHeight,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text("2",style: TextStyle(color: Colors.white,fontSize: 20),),
Text("abc",style: TextStyle(color: Colors.white,fontSize: 20),),
SizedBox(height: 30.0,),
Text("2",style: TextStyle(color: Colors.white,fontSize: 20),),
Text("abc",style: TextStyle(color: Colors.white,fontSize: 20),)
],
),
Padding(
padding: const EdgeInsets.all(20.0),
child: Container(
width: 4.0,
height: 150.0,
decoration: BoxDecoration(
color: Colors.white,
)
),
),
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text("2",style: TextStyle(color: Colors.white,fontSize: 20),),
Text("abc",style: TextStyle(color: Colors.white,fontSize: 20),),
SizedBox(height: 30.0,),
Text("2",style: TextStyle(color: Colors.white,fontSize: 20),),
Text("abc",style: TextStyle(color: Colors.white,fontSize: 20),)
],
),
Padding(
padding: const EdgeInsets.all(20.0),
child: Container(
width: 4.0,
height: 150.0,
decoration: BoxDecoration(
color: Colors.white,
)
),
),
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text("2",style: TextStyle(color: Colors.white,fontSize: 20),),
Text("abc",style: TextStyle(color: Colors.white,fontSize: 20),),
SizedBox(height: 30.0,),
Text("2",style: TextStyle(color: Colors.white,fontSize: 20),),
Text("abc",style: TextStyle(color: Colors.white,fontSize: 20),)
],
),
],
),
)
],
),
),
);
}
}