Flutter 颤振卡内容未显示

Flutter 颤振卡内容未显示,flutter,frontend,flutter-layout,flutter-card,Flutter,Frontend,Flutter Layout,Flutter Card,你好! 所以我对flatter还比较陌生,所以我有点甚至不知道如何布局几个小部件,更不用说在一张卡片中布局几个小部件了 所以我想得出这种输出[1]: 但当我试图运行我的代码时,它返回为空白(参考图片) [2] : 这是我的代码: import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:scrollable_positioned_list/scrollable_positioned

你好! 所以我对flatter还比较陌生,所以我有点甚至不知道如何布局几个小部件,更不用说在一张卡片中布局几个小部件了

所以我想得出这种输出[1]:

但当我试图运行我的代码时,它返回为空白(参考图片) [2] :

这是我的代码:

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import 'package:flutter/cupertino.dart';

class SetAppointmentPage extends StatefulWidget {
static const String routeName = '/setappointment';

@override
_SetAppointmentPageState createState() => new _SetAppointmentPageState();
}

class _SetAppointmentPageState extends State<SetAppointmentPage> {
bool isSelected = false;
double height = Get.height;
double width = Get.width;
final itemPositionsListener = ItemPositionsListener.create();
int topItem = 0;
@override
void initState() {
super.initState();
itemPositionsListener.itemPositions.addListener(() {
  final positions = itemPositionsListener.itemPositions.value;
  setState(() {
    topItem = positions.isNotEmpty ? positions.first.index : null;
  });
});
}

Widget buildhomePageAppBar() {
double profileDimension = 35;
 return AppBar(
  backgroundColor: Colors.white,
  titleSpacing: 0,
  title: Padding(
    padding: EdgeInsets.only(
      left: 20,
     ),
    child: Row(
      children: [
        Padding(
          padding: EdgeInsets.only(
            top: 5,
            bottom: 5,
          ),
          child: Image(
            image: AssetImage('assets/images/plain_logo.png'),
            height: 30,
          ),
        ),
        SizedBox(width: 5),
        Text(
          'Virtex',
          style: TextStyle(
            color: Colors.black87,
            fontFamily: 'Poppins',
            fontSize: 16,
            fontWeight: FontWeight.bold,
          ),
        )
      ],
    ),
   ),
   actions: [
    Padding(
      padding: EdgeInsets.only(
        top: 10,
        bottom: 10,
      ),
      child: Container(
        height: profileDimension,
        width: profileDimension,
        alignment: Alignment.center,
        decoration: BoxDecoration(
          color: Colors.white,
          border: Border.all(
            color: Colors.black54,
            width: 2,
          ),
          borderRadius: BorderRadius.circular(50),
        ),
        child: ClipRRect(
          borderRadius: BorderRadius.circular(50),
          child: Image(
            width: profileDimension,
            height: profileDimension,
            image: AssetImage(
              'assets/images/profile-image.jpeg',
            ),
            fit: BoxFit.cover,
          ),
        ),
      ),
    ),
    SizedBox(width: 20),
   ],
   );
    }

   Widget buildAppointmentText =
   Row(mainAxisAlignment: MainAxisAlignment.start, children: [
   Container(
   padding: EdgeInsets.all(10.0),
   child: Text(
    "AVAILABLE APPOINTMENT SLOTS",
    style: TextStyle(
      fontSize: 15.0,
      color: Colors.white,
      fontWeight: FontWeight.bold,
    ),
    textAlign: TextAlign.center,
   ),
   ),
   ]);

   Widget buildDateText = Padding(
   padding: EdgeInsets.only(
   top: 5,
   bottom: 5,
   ),
   child: Text(
   'May 18, 2021',
   style: TextStyle(
    color: Colors.grey,
    fontSize: 20,
    fontWeight: FontWeight.w500,
    ),
    ),
    );

    Widget buildShowCalendar = Padding(
  padding: EdgeInsets.only(
  top: 5,
  bottom: 5,
),
child: Text(
  'Show Calendar',
  style: TextStyle(
    color: Colors.blue,
    fontSize: 20,
    fontWeight: FontWeight.w500,
  ),
),
);

Widget buildTimeButton = Padding(
padding: EdgeInsets.only(left: 20, top: 90, right: 40),
child: new Row(
  mainAxisAlignment: MainAxisAlignment.spaceBetween,
  children: <Widget>[
    Container(
      child: SizedBox(
        height: 50.0,
        width: 150.0,
        child: RaisedButton(
          onPressed: () {},
          child: Text("11 AM"),
          shape: RoundedRectangleBorder(
              side: BorderSide(color: Colors.black, width: 1)),
          color: Colors.white,
          textColor: Colors.blue,
        ),
      ),
    ),
    Container(
      child: SizedBox(
        height: 50.0,
        width: 150.0,
        child: RaisedButton(
          onPressed: () {},
          child: Text("2 PM"),
          shape: RoundedRectangleBorder(
              side: BorderSide(color: Colors.black, width: 1)),
          color: Colors.white,
          textColor: Colors.blue,
        ),
      ),
    ),
    Container(
      child: SizedBox(
        height: 50.0,
        width: 150.0,
        child: RaisedButton(
          onPressed: () {},
          child: Text("3 PM"),
          shape: RoundedRectangleBorder(
              side: BorderSide(color: Colors.black, width: 1)),
          color: Colors.white,
          textColor: Colors.black,
        ),
      ),
    ),
  ],
   ),
  );

  Widget buildAppointmentEndText = Padding(
  padding: EdgeInsets.only(
    top: 5,
    bottom: 5,
  ),
  child: Text(
      '*Lorem Ipsum Dolor Lorem Ipsum Dolor Lorem Ipsum Dolor Lorem Ipsum' +
          'Dolor Lorem Ipsum  Lorem Ipsum Dolor Lorem Ipsum Dolor Lorem Ipsum Dolor'));

Widget buildGoButton = Padding(
padding: EdgeInsets.only(left: 20, top: 90, right: 40),
child: new Row(
  mainAxisAlignment: MainAxisAlignment.spaceBetween,
  children: <Widget>[
    Container(
      child: SizedBox(
        height: 50.0,
        width: 150.0,
        child: RaisedButton(
          onPressed: () {},
          child: Text("Cancel"),
          shape: RoundedRectangleBorder(
              side: BorderSide(color: Colors.blue, width: 1)),
          color: Colors.white,
          textColor: Colors.blue,
        ),
      ),
    ),
    Container(
      child: SizedBox(
        height: 50.0,
        width: 150.0,
        child: RaisedButton(
          onPressed: () {},
          child: Text("Next"),
          color: Colors.blue,
          textColor: Colors.white,
        ),
      ),
    ),
   ],
   ),
   );

   @override
Widget build(BuildContext context) {
return Scaffold(
  appBar: buildhomePageAppBar(),
  body: Container(
    margin: EdgeInsets.only(top: 0),
    width: MediaQuery.of(context).size.width,
    child: Column(
      children: [
        Card(
          elevation: 1.0,
          color: Colors.white,
          child: Padding(
            padding: EdgeInsets.all(5.0),
            child: Column(
              children: <Widget>[
                buildAppointmentText,
                Expanded(
                    child: Column(
                  children: <Widget>[
                    buildDateText,
                    buildTimeButton,
                    buildShowCalendar,
                  ],
                ))
              ],
            ),
          ),
        ),
        Column(
          children: [
            buildGoButton,
          ],
        )
      ],
    ),
  ),
);
导入“包装:颤振/材料.省道”;
导入“package:get/get.dart”;
导入“package:scrollable_positioned_list/scrollable_positioned_list.dart”;
进口“包装:颤振/cupertino.dart”;
类SetAppointPage扩展StatefulWidget{
静态常量字符串routeName='/setappointment';
@凌驾
_SetAppointPageState createState()=>new_SetAppointPageState();
}
类_setAppointPageState扩展状态{
bool-isSelected=false;
双倍高度=Get.height;
双宽度=Get.width;
final itemPositionsListener=itemPositionsListener.create();
int topItem=0;
@凌驾
void initState(){
super.initState();
itemPositionsListener.itemPositions.addListener((){
最终位置=itemPositionsListener.itemPositions.value;
设置状态(){
topItem=positions.isNotEmpty?positions.first.index:null;
});
});
}
小部件buildhomePageAppBar(){
双轮廓尺寸=35;
返回AppBar(
背景颜色:Colors.white,
标题间距:0,
标题:填充(
填充:仅限边缘设置(
左:20,,
),
孩子:排(
儿童:[
填充物(
填充:仅限边缘设置(
前五名,
底部:5,
),
孩子:图像(
图片:AssetImage('assets/images/plain_logo.png'),
身高:30,
),
),
尺寸箱(宽度:5),
正文(
“Virtex”,
样式:TextStyle(
颜色:颜色。黑色87,
fontFamily:“罂粟花”,
尺寸:16,
fontWeight:fontWeight.bold,
),
)
],
),
),
行动:[
填充物(
填充:仅限边缘设置(
前10名,
底部:10,
),
子:容器(
高度:外形尺寸,
宽度:外形尺寸,
对齐:对齐.center,
装饰:盒子装饰(
颜色:颜色,白色,
边界:边界(
颜色:颜色。黑色54,
宽度:2,
),
边界半径:边界半径。圆形(50),
),
孩子:ClipRRect(
边界半径:边界半径。圆形(50),
孩子:图像(
宽度:外形尺寸,
高度:外形尺寸,
图片:资产评估(
“assets/images/profile image.jpeg”,
),
适合:BoxFit.cover,
),
),
),
),
尺寸箱(宽度:20),
],
);
}
小部件BuildAppointText=
行(mainAxisAlignment:mainAxisAlignment.start,子项:[
容器(
填充:所有边缘设置(10.0),
子:文本(
“可用预约时段”,
样式:TextStyle(
字体大小:15.0,
颜色:颜色,白色,
fontWeight:fontWeight.bold,
),
textAlign:textAlign.center,
),
),
]);
Widget buildDateText=填充(
填充:仅限边缘设置(
前五名,
底部:5,
),
子:文本(
“2021年5月18日”,
样式:TextStyle(
颜色:颜色。灰色,
尺寸:20,
fontWeight:fontWeight.w500,
),
),
);
Widget buildShowCalendar=填充(
填充:仅限边缘设置(
前五名,
底部:5,
),
子:文本(
“显示日历”,
样式:TextStyle(
颜色:颜色,蓝色,
尺寸:20,
fontWeight:fontWeight.w500,
),
),
);
Widget buildTimeButton=填充(
填充:仅限边缘设置(左:20,上:90,右:40),
孩子:新的一排(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
容器(
孩子:大小盒子(
身高:50.0,
宽度:150.0,
孩子:升起按钮(
按下:(){},
儿童:文本(上午十一时),,
形状:圆形矩形边框(
边:边框边(颜色:Colors.black,宽度:1)),
颜色:颜色,白色,
textColor:Colors.blue,
),
),
),
容器(
孩子:大小盒子(
身高:50.0,
宽度:150.0,
孩子:升起按钮(
按下:(){},
儿童:文本(下午二时),,
形状:圆形矩形边框(
边:边框边(颜色:Colors.black,宽度:1)),
颜色:颜色,白色,
textColor:Colors.blue,
),
),
),
容器(
孩子:大小盒子(
身高:50.0,
宽度:150.0,
孩子:升起按钮(
按下:(){},
儿童:文本(下午三时),,
形状:圆形矩形边框(
边:边框边(颜色:Colors.black,宽度:1)),
颜色:颜色,白色,
textColor:Colors.black,
),
),
),
],
),
);
Widget BuildAppointEndText=填充(
填充:仅限边缘设置(
前五名,
底部:5,
),
子:文本(
“*Lorem Ipsum Dolor Lorem Ipsum Dolor Lorem Ipsum Dolor Lorem Ipsum Dolor Lorem Ipsum”+
“多洛-洛雷姆-伊普苏姆-洛雷姆-伊普苏姆-多洛-洛雷姆-伊普苏姆-多洛”);
Widget buildGoButton=填充(
填充:仅限边缘设置(左:20,上:90,右:40),
孩子:新的一排(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
容器(
孩子:大小盒子(
身高:50.0,
宽度:150.0,
孩子:升起按钮(
按下:(){},
子项:文本(“取消”),
形状:圆形矩形边框(
边:边框边(颜色:Colors.blue,宽度:1)),
颜色:颜色,白色,
textColor:Colors.blue,
),
),
),
容器(
孩子:大小盒子(
身高:50.0,
宽度:150.0,
孩子:升起按钮(
按下:(){},
子项:文本(“下一个”),
颜色:颜色,蓝色,
textColor:Colors.white,
Card(
              elevation: 1.0,
              color: Colors.white,
              child: Padding(
                padding: EdgeInsets.all(5.0),
                child: Container(
                  width: Get.width,
                  height: 500,
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: <Widget>[
                      buildAppointmentText,
                      Expanded(
                          child: Column(
                            children: <Widget>[
                              buildDateText,
                              buildTimeButton,
                              buildShowCalendar,
                            ],
                          ))
                    ],
                  ),
                ),
              ),
            )
class SetAppointmentPage extends StatefulWidget {
  static const String routeName = '/setappointment';

  @override
  _SetAppointmentPageState createState() => new _SetAppointmentPageState();
}

class _SetAppointmentPageState extends State<SetAppointmentPage> {
  List time = [
    {
      "Day": "May 18, 2021",
      "times": ["11 AM", "1 PM", "3 PM", "4 PM", "11 PM"]
    },
    {
      "Day": "May 19, 2021",
      "times": ["10 AM", "11 AM"]
    },
    {
      "Day": "May 20, 2021",
      "times": ["9 AM", "11 PM", "1 PM"]
    }
  ];
  bool isSelected = false;
  double height = Get.height;
  double width = Get.width;
  int topItem = 0;

  @override
  void initState() {
    super.initState();
  }

  Widget buildhomePageAppBar() {
    double profileDimension = 35;
    return AppBar(
      backgroundColor: Colors.white,
      titleSpacing: 0,
      title: Padding(
        padding: EdgeInsets.only(
          left: 20,
        ),
        child: Row(
          children: [
            Padding(
              padding: EdgeInsets.only(
                top: 5,
                bottom: 5,
              ),
              child: Image(
                image: AssetImage('assets/images/plain_logo.png'),
                height: 30,
              ),
            ),
            SizedBox(width: 5),
            Text(
              'Virtex',
              style: TextStyle(
                color: Colors.black87,
                fontFamily: 'Poppins',
                fontSize: 16,
                fontWeight: FontWeight.bold,
              ),
            )
          ],
        ),
      ),
      actions: [
        Padding(
          padding: EdgeInsets.only(
            top: 10,
            bottom: 10,
          ),
          child: Container(
            height: profileDimension,
            width: profileDimension,
            alignment: Alignment.center,
            decoration: BoxDecoration(
              color: Colors.white,
              border: Border.all(
                color: Colors.black54,
                width: 2,
              ),
              borderRadius: BorderRadius.circular(50),
            ),
            child: ClipRRect(
              borderRadius: BorderRadius.circular(50),
              child: Image(
                width: profileDimension,
                height: profileDimension,
                image: AssetImage(
                  'assets/images/profile-image.jpeg',
                ),
                fit: BoxFit.cover,
              ),
            ),
          ),
        ),
        SizedBox(width: 20),
      ],
    );
  }

  Widget buildAppointmentText =
      Row(mainAxisAlignment: MainAxisAlignment.start, children: [
    Container(
      padding: EdgeInsets.all(10.0),
      child: Text(
        "AVAILABLE APPOINTMENT SLOTS",
        style: TextStyle(
          fontSize: 15.0,
          color: Colors.white,
          fontWeight: FontWeight.bold,
        ),
        textAlign: TextAlign.center,
      ),
    ),
  ]);

  Widget buildShowCalendar = Padding(
    padding: EdgeInsets.only(
      top: 5,
      bottom: 5,
    ),
    child: Text(
      'Show Calendar',
      style: TextStyle(
        color: Colors.blue,
        fontSize: 20,
        fontWeight: FontWeight.w500,
      ),
    ),
  );

  Widget buildAppointmentEndText = Padding(
      padding: EdgeInsets.only(
        top: 5,
        bottom: 5,
      ),
      child: Text(
          '*Lorem Ipsum Dolor Lorem Ipsum Dolor Lorem Ipsum Dolor Lorem Ipsum' +
              'Dolor Lorem Ipsum  Lorem Ipsum Dolor Lorem Ipsum Dolor Lorem Ipsum Dolor'));

  Widget buildGoButton = Padding(
    padding: EdgeInsets.only(left: 20, top: 90, right: 40),
    child: new Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: <Widget>[
        Container(
          child: SizedBox(
            height: 50.0,
            width: 150.0,
            child: RaisedButton(
              onPressed: () {},
              child: Text("Cancel"),
              shape: RoundedRectangleBorder(
                  side: BorderSide(color: Colors.blue, width: 1)),
              color: Colors.white,
              textColor: Colors.blue,
            ),
          ),
        ),
        Container(
          child: SizedBox(
            height: 50.0,
            width: 150.0,
            child: RaisedButton(
              onPressed: () {},
              child: Text("Next"),
              color: Colors.blue,
              textColor: Colors.white,
            ),
          ),
        ),
      ],
    ),
  );

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: buildhomePageAppBar(),
      body: Container(
        margin: EdgeInsets.only(top: 0),
        width: MediaQuery.of(context).size.width,
        child: Column(
          children: [
            Card(
              elevation: 1.0,
              color: Colors.white,
              child: Padding(
                padding: EdgeInsets.all(5.0),
                child: Column(
                  children: [
                    Text(
                      "AVAILABLE APPOINTMENT SLOTS",
                      style: TextStyle(
                        fontSize: 15.0,
                        color: Colors.black26,
                        fontWeight: FontWeight.bold,
                      ),
                      textAlign: TextAlign.center,
                    ),
                    Container(
                      width: width / 1.2,
                      height: height / 1.8,
                      child: ListView.builder(
                        itemCount: time.length,
                        itemBuilder: (context, slots){
                          return Column(
                            children: [
                              buildAppointmentText,
                              Padding(
                                padding: EdgeInsets.only(
                                  top: 5,
                                  bottom: 5,
                                ),
                                child: Text(
                                  '${time[slots]['Day']}',
                                  style: TextStyle(
                                    color: Colors.grey,
                                    fontSize: 20,
                                    fontWeight: FontWeight.w500,
                                  ),
                                ),
                              ),
                              Container(
                                width: width / 1.2,
                                height: time[slots]['times'].length > 3 ? 120: 60,
                                child: GridView.builder(
                                    gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                                        crossAxisCount: 3, childAspectRatio: 2.0),
                                    itemCount: time[slots]['times'].length,
                                    itemBuilder: (context, index) {
                                      return Padding(
                                        padding: const EdgeInsets.all(8.0),
                                        child: RaisedButton(
                                          onPressed: () {},
                                          child: Text(time[slots]['times'][index], textAlign: TextAlign.start,),
                                          shape: RoundedRectangleBorder(
                                              borderRadius: BorderRadius.circular(10.0),
                                              side: BorderSide(
                                                  color: Colors.black26, width: 1)),
                                          color: Colors.white,
                                          textColor: Colors.blue,
                                        ),
                                      );
                                    }),
                              )
                            ],
                          );
                        },
                      ),
                    ),
                    buildShowCalendar,
                  ],
                ),
              ),
            ),
            Column(
              children: [
                buildGoButton,
              ],
            )
          ],
        ),
      ),
    );
  }
}