The method 'Style' isn't defined for the type 'Style' in flutter

Viewed 21

I want to use Style in html in flutter. My imports are :

import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_html/style.dart'; 

But when I use Style in the code, it shows an error that says

 Style' isn't a function. (Documentation)  Try correcting the name to match an existing function, or define a method or function named 'Style'.
The name 'Style' is defined in the libraries 'package:flutter_html/style.dart' and 'package:path/src/style.dart (via package:path/path.dart)'  

My code :

subtitle: Html(
                      data: user.bangla_trans.replaceAll("\\n", "<br>"),
                      style: {
                        "body": Style(
                          color: Colors.green,
                          fontSize: FontSize(18.0),
                          // fontWeight: FontWeight.bold,
                        ),
                      },
                    ),
1 Answers

I have to use the import as follows :

import 'package:flutter_html/style.dart' as style;

and use that style as follows :

subtitle: Html(
                      data: user.bangla_trans.replaceAll("\\n", "<br>"),
                      style: {
                        "body": style.Style(
                          color: Colors.green,
                          fontSize: FontSize(18.0),
                          // fontWeight: FontWeight.bold,
                        ),
                      },
                    ),
Related