MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

[SOLVED] Flutter Error: The getter ‘body1’ isn’t defined for the class ‘TextTheme’ – place_picker.

Error

/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/place_picker-0.9.19-nullsafety/lib/widgets/rich_suggestion.dart:35:89: Error: The getter ‘body1’ isn’t defined for the class ‘TextTheme’.
– ‘TextTheme’ is from ‘package:flutter/src/material/text_theme.dart’ (‘/C:/src/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 ‘body1’.
TextSpan(text: boldText, style: style.copyWith(color: Theme.of(context).textTheme.body1!.color)),
^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/place_picker-0.9.19-nullsafety/lib/widgets/search_input.dart:60:65: Error: The getter ‘body1’ isn’t defined for the class ‘TextTheme’.
– ‘TextTheme’ is from ‘package:flutter/src/material/text_theme.dart’ (‘/C:/src/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 ‘body1’.
Icon(Icons.search, color: Theme.of(context).textTheme.body1!.color),

^^^^^

FAILURE: Build failed with an exception.

* Where:
Script ‘C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle’ line: 1005

* What went wrong:
Execution failed for task ‘:app:compileFlutterBuildDebug’.
> Process ‘command ‘C:\src\flutter\bin\flutter.bat” finished with non-zero exit v alue 1

* Try:
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output. Run with –scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 42s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

SOLUTION

Here is what I found on StackOverflow

StackOverflow answer saying TextTheme body1 is now bodyText1 in the place_picker plugin

Source (Stackoverflow):- https://stackoverflow.com/questions/69312392/how-to-resolve-error-the-getter-body1-isnt-defined-for-the-class-texttheme

To fix this issue you have to make some changes to Two files

  1. C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/place_picker-0.9.19-nullsafety/lib/widgets/rich_suggestion.dart

2. C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/place_picker-0.9.19-nullsafety/lib/widgets/search_input.dart

Changes to Done

GitHub comment replacing body1 with bodyText1 in rich_suggestion.dart and search_input.dart

Edit the lines in the dart package like below and it will work. Of course, the author should do this, but you can edit it yourself as well 🙂

rich_suggestion.dart
Original: TextSpan(text: boldText, style: style.copyWith(color: Theme.of(context).textTheme.body1!.color)),

New: TextSpan(text: boldText, style: style.copyWith(color: Theme.of(context).textTheme.bodyText1!.color)),

search_input.dart
Original: Icon(Icons.search, color: Theme.of(context).textTheme.body1!.color),

New: Icon(Icons.search, color: Theme.of(context).textTheme.bodyText1!.color),

Ticket Source (Github):- https://github.com/blackmann/locationpicker/issues/63

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
With MotoShare.in, you can book a bike instantly, enjoy doorstep delivery, and ride without worries. Perfect for travelers, professionals, and adventure enthusiasts looking for a seamless mobility solution.

Related Posts

What is Flutter and use cases of Flutter?

What is Flutter? Flutter is an open-source UI software development toolkit developed by Google. It is applied for building natively compiled applications for mobile, web, and desktop…

Read More

[Solved] Flutter : Error: The getter ‘subhead’ isn’t defined for the class ‘TextTheme’ from package:flutter/src/material/text_theme.dart’ – searchable_dropdown

ERROR SOLUTION There are Two Solutions for this error Use Alternative Package Do some changes in .pub-cache Use Alternative Package I switched from searchable_dropdown to search_choices and…

Read More

[SOLVED] Flutter : NoSuchMethodError: The getter ‘isEmpty’ was called on null.

Problem I’m Calling An API and getting response in Variable Data ($data). When data is coming then there is no Error but when I’m getting null as…

Read More

[SOLVED] Flutter : Cannot run with sound null safety, because the following dependencies don’t support null safety

Problem I’m using flutter_recaptcha_v2: ^0.1.0. Now, I am trying to run it using flutter run, however, it will not start because of the following error: Solution If you want…

Read More

How to Check if an application is on its first run or One time Intro Screen with Flutter.

If you wish to show the intro screen only for the first time, you will need to save locally that this user has already seen intro. For…

Read More

[SOLVED] Unhandled Exception: Navigator operation requested with a context that does not include a Navigator.

This happens because when you do Navigator.of(context), it will start from the widget associated to the context used. And then go upward in the widget tree until…

Read More