Flutter - Marquee isn't defined for class 'MyApp'

Viewed 396

I want to use the Marquee inside the body but it is showing an error it is not defined in the class 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)
                  )
              ),
            ],
        ),
        ),

How to use Marquee inside the body?

1 Answers

Add marque lib in dependency at pubspec.yaml file And save. marquee

dependencies:
  flutter:
    sdk: flutter
  marquee: ^1.3.1

After import:

import 'package:marquee/marquee.dart';

You can use

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