颤振奇数文字显示

时间:2019-05-08 05:43:03

标签: flutter

我昨天(5月7日)更新了颤动,并得到了一些奇怪的行为。在下面的两节课中,我希望得到一个带有白色背景的简单屏幕,并垂直列出4个单词。我也希望文本没有格式/样式,所以很小的黑色字母。相反,我得到下面的图像...

import 'package:flutter/material.dart';
import 'package:my_caddie/ui/OverlayWidget.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Base',
      home: OverlayWidget(),
    );
  }
}

这是我的OverlayWidget:

import 'package:flutter/material.dart';

class OverlayWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
        color: Colors.white,
        child: BottomScrollingList(BottomScrollingList.getDataList()));
  }
}

class BottomScrollingList extends StatelessWidget {
  List<Data> dataList;

  BottomScrollingList(this.dataList);

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
        itemCount: dataList.length,
        itemBuilder: (context, index) {
          return Text("${dataList[index].name}");
        });
  }

  static List<Data> getDataList() {
    List<Data> dataList = List();
    dataList.add(Data("CEO"));
    dataList.add(Data("Manager"));
    dataList.add(Data("Supervisor"));
    dataList.add(Data("Peon"));
    return dataList;
  }
}

class Data {
  Data(this.name);

  String name;
}

enter image description here

2 个答案:

答案 0 :(得分:0)

您需要将Container包装在Scaffold小部件中。

答案 1 :(得分:-1)

您需要添加一个Scaffold小部件。 代码:-


...

class MyApp extends StatelessWidget {

  ...

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Base',
      home: Scaffold(
        body: OverlayWidget(),
      ),
    );
  }

  ...

}

...