【发布时间】:2019-05-07 16:41:31
【问题描述】:
下面的屏幕截图是我设计和自定义的 UI,我想在 Flutter 中制作它
在下面用颤振实现的代码中,我无法为圆圈Container 生成center_horizontal,即在Card 屏幕顶部的左侧
import 'package:flutter/material.dart';
void main() => runApp(LoginApp());
class LoginApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
brightness: Brightness.dark,
primaryColor: Colors.indigo,
accentColor: Colors.indigoAccent),
home: MaterialApp(
title: 'instaCheeta',
home: Scaffold(
body: Login(),
),
),
);
}
}
class Login extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Stack(
overflow: Overflow.visible,
children: <Widget>[
Container(
height: 200.0,
color: Colors.indigo,
),
Positioned(
child: Card(
margin: new EdgeInsets.fromLTRB(20, 90, 20, 70),
elevation: 2.0,
color: Colors.white,
child: Container(
decoration: BoxDecoration(color: Colors.white12),
),
)),
Positioned(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin: new EdgeInsets.only(top: 50),
height: 100.0,
width: 100.0,
decoration: new BoxDecoration(
color: Colors.white,
shape: BoxShape.rectangle,
borderRadius: new BorderRadius.circular(50.0),
boxShadow: [
BoxShadow(
color: Colors.grey,
blurRadius: 2.0,
// has the effect of softening the shadow
spreadRadius: 1.0,
// has the effect of extending the shadow
offset: Offset(
0.0, // horizontal, move right 10
0.0, // vertical, move down 10
),
)
],
),
)
],
)),
],
);
}
}
【问题讨论】: