4inka / flutter_easy_search_bar

Other
13 stars 22 forks source link

Deprecated titleTextStyle theme #27

Closed esaiaswestberg closed 4 months ago

esaiaswestberg commented 4 months ago

The Issue

In a recent update of the Flutter framework, older TextTheme styles, such as headline6, became deprecated and are replaced by new names for the styles.

When trying to build a flutter project which uses _easy_searchbar one now encounters the following error message:

easy_search_bar-2.5.0/lib/easy_search_bar.dart:377:25: Error: The getter 'headline6' isn't defined for the class 'TextTheme'.
 - 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/usr/bin/flutter/packages/flutter/lib/src/material/text_theme.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'headline6'.
        theme.textTheme.headline6!.copyWith(color: foregroundColor);
                        ^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/easy_search_bar-2.5.0/lib/easy_search_bar.dart:491:60: Error: The argument type 'TextStyle?' can't be assigned to the parameter type 'TextStyle' because 'TextStyle?' is nullable and 'TextStyle' isn't.
 - 'TextStyle' is from 'package:flutter/src/painting/text_style.dart' ('/usr/bin/flutter/packages/flutter/lib/src/painting/text_style.dart').
                                                    style: titleTextStyle,
                                                           ^

This indicated that the default titleTextStyle does not work as it is null as of the new version of the framework.

Proposed solution

Using one of the new TextTheme styles. My proposal would be to use titleLarge as it matches the old headline6.

Property headline6 (old) titleLarge (new)
Size 20 20
Weight Medium Medium
Spacing 0.15 0.15

As you can see, they are identical and therefor it will not cause any issues for any future users or any existing users.

esaiaswestberg commented 4 months ago

Source for old theme values: https://web.archive.org/web/20210625133010/https://api.flutter.dev/flutter/material/TextTheme-class.html

wantroba commented 4 months ago

When will this change go live? I am unable to use the lib because of this error.