Flutter-未为“ MyApp”类定义字幕

时间:2019-10-14 18:07:28

标签: android ios flutter dart marquee

我想在体内使用Marquee,但它显示的错误是类MyApp中未定义的错误

  body: Center(
          child: Row (
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget> [
              Marquee (
                child: Text('hello world!',           
          style: TextStyle (
            color: Colors.blueAccent, 
                   fontWeight: FontWeight.w500,
                   fontSize: 40)
                  )
              ),
            ],
        ),
        ),

如何在体内使用Marquee

1 个答案:

答案 0 :(得分:0)

在pubspec.yaml文件中依赖添加marque lib并保存。 marquee

dependencies:
  flutter:
    sdk: flutter
  marquee: ^1.3.1

导入后:

import 'package:marquee/marquee.dart';

您可以使用

 body: Center(
          child: Row (
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget> [
              Marquee (
                child: Text('hello world!',           
          style: TextStyle (
            color: Colors.blueAccent, 
                   fontWeight: FontWeight.w500,
                   fontSize: 40)
                  )
              ),
            ],
        ),
        ),