Error: Member not found: 'Scrollable.maybeOf'. final scrollableState = Scrollable.maybeOf(context); - flutter

Hello, good day everyone i encountered this error in my Android Studio Can someone help me about this i am on Flutter 3.3.8 Thank you so much
#override
void didChangeDependencies() {
super.didChangeDependencies();
final scrollableState = Scrollable.maybeOf(context);
if (scrollableState != null) {
// The TypeAheadField is inside a scrollable widget
_scrollPosition = scrollableState.position;
_scrollPosition!.removeListener(_scrollResizeListener);
_scrollPosition!.isScrollingNotifier.addListener(_scrollResizeListener);
}
}
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_typeahead-4.3.1/lib/src/flutter_typeahead.dart:898:40: Error: Member not found: 'Scrollable.maybeOf'.
final scrollableState = Scrollable.maybeOf(context);
^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_typeahead-4.3.1/lib/src/cupertino_flutter_typeahead.dart:649:40: Error: Member not found: 'Scrollable.maybeOf'.
final scrollableState = Scrollable.maybeOf(context);
^^^^^^^
I am expecting someone could help me about this flutter and my project, Ill promise after i learn coding i will payback all the help to the one in needs.!!!!

goto path by ctrl+click on path provided in console. change maybeOf to of. Run flutter pub get in terminal and error is gone.

First upgrade your flutter version to latest stable running flutter upgrade
Then, update your flutter_typeahead dependency version to at least 4.3.1 on your pubspec.yaml file.
By the widget change log it states that this has been fixed on 28-January-2023
PR #447 - fix: Use maybeOf for scrollable to not throw an exception in
flutter …
See change log: https://pub.dev/packages/flutter_typeahead/changelog#431---28-january-2023

Related

'dfg throw' isn't a type.foundation/changenotifier.dart:125 in flutter

I got this issues suddenly while debugging on Emulator.
'throw' isn't a type.foundation/changenotifier.dart:125 throw FlutterError( ^^^^^^^^ :
Error: Expected ';' after this. ../…/foundation/changenotifier.dart:125 throw FlutterError( ^^^^^^^^^^^^ : Error:
I had resolved the issues by upgrading to the latest Flutter SDK version 3.3.2.
Actually in Flutter SDK ,If you find the file changenotifier.dart file. at this location /Users/sumitjaiswal/Desktop/flutter/packages/flutter/lib/src/foundation
You will find this code .
static bool debugAssertNotDisposed(ChangeNotifier notifier) {
assert(() {
if (notifier._debugDisposed) {
throw FlutterError(
'A ${notifier.runtimeType} was used after being disposed.\n'
'Once you have called dispose() on a ${notifier.runtimeType}, it '
'can no longer be used.',
);
}
return true;
}());
return true;
}
This has changed from dfg throw to throw. So,I had just upgrade to latest version of Flutter SDK 3.3.2.

flutter - Image picker - need to convert 'List<XFile>' to 'List<File>?'

I'm using image_picker package to get images and show them in a carousel.
postNotifier(true).selectedPostImages != null
? Container(
height: 400,
width: 400,
child: CarouselSlider.builder(
options: CarouselOptions(height: 300),
itemCount: selectedImagesList!.length,
itemBuilder: (BuildContext context, index, realIndex) {
final selectedImage = selectedImagesList[index];
return buildImage(selectedImage, index);
}),
)
: const SizedBox(
height: 0,
),
and I'm getting the images for carousel builder from this buildImage() widget
Widget buildImage(File selectedImage, int index) => Container(
margin: EdgeInsets.symmetric(horizontal: 12),
color: Colors.grey,
child: Image.file(selectedImage),
);
my PostNotifier class in another file
class PostNotifier extends ChangeNotifier {
List<File>? _selectedPostImages;
List<File>? get selectedPostImages => _selectedPostImages;
Future<List?> pickPostImages() async {
final _imageList = await ImagePicker().pickMultiImage(imageQuality: 5);
if (_imageList != null) {
_selectedPostImages = _imageList; //I'm getting the error here.
notifyListeners();
}
}
The error flutter shows is:
A value of type 'List' can't be assigned to a variable of type 'List?'.
Try changing the type of the variable, or casting the right-hand type to 'List?'.
I tried using flutter_absolute_path as suggested in other answers in such a situation to get the path and set it to the array but when I run on emulator I get this error
The plugin `flutter_absolute_path` uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
Launching lib\main.dart on Android SDK built for x86 in debug mode...
lib\main.dart:1
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_absolute_path-1.0.6/lib/flutter_absolute_path.dart:11:23: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
static Future<String?> getAbsolutePath(String uri) async {
^
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
- package:flutter_absolute_path
For solutions, see https://dart.dev/go/unsound-null-safety
: Error: The argument type 'String?' can't be assigned to the parameter type 'String' because 'String?' is nullable and 'String' isn't.
lib/…/notifier/post.notifier.dart:101
File tempFile = File(filePath);
^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_absolute_path-1.0.6/lib/flutter_absolute_path.dart:15:17: Error: Null safety features are disabled for this library.
Try removing the package language version or setting the language version to 2.12 or higher.
final String? path = await _channel.invokeMethod('getAbsolutePath', params);
^
2
FAILURE: Build failed with an exception.
* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1102
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 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 1m 48s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
and the app never opens on emualtor.
What do I do? I want to implement this multi image picker.
XFile is a image_picker package's wrapper for the picked file(s). Hence, you obtain a List<XFile> from await ImagePicker().pickMultiImage() call, but try to assign it to a _selectedPostImages field that expects List<File> which produces the type mismatch error.
So, you can either:
Rewrite the _selectedPostImages to expect List<XFile>, like List<XFile>? _selectedPostImages.
Map the _imageList to a list of File, like _selectedPostImages = _imageList.map<File>((xfile) => File(xfile.path)).toList()

How to create a form with address autocomplete in flutter ? not interested to see points or map - it is only for register page

Hello guys I am new at flutter and building register page for my app. I have the following issue when I try to use below code in form field Someone can help me please ?
The instance member 'kGoogleApiKey' can't be accessed in an initializer.
I am currently using last version of flutter, flutter_google_places: ^0.3.0 and geocoder: ^0.2.1
Move the following line inside the initState() method and declaring the variable as late:
late final GoogleMapsPlaces _places;
late GoogleMapPlaces _places;
#override
void initState(){
super.initState();
_places = GoogleMapPlaces(apiKey: kGoogleApiKey)
}

I'm having an issue when running my build

So I try building my flutter code and get the error:
"H:/src/flutter/.pub-cache/hosted/pub.dartlang.org/chewie-0.9.10/lib/src/chewie_player.dart:277:51: Error: Too many positional
Try removing the extra positional arguments.
context.dependOnInheritedWidgetOfExactType(_ChewieControllerProvider)"
Here is the code snippet in question
static ChewieController of(BuildContext context) {
final chewieControllerProvider =
context.dependOnInheritedWidgetOfExactType(_ChewieControllerProvider)
as _ChewieControllerProvider;
This seems like a version mismatch between Flutter and chewie_player.
In version 0.9.10, the code is as you have used it.
However, in the latest version, it is,
static ChewieController of(BuildContext context) {
final chewieControllerProvider = context.dependOnInheritedWidgetOfExactType<_ChewieControllerProvider>();
return chewieControllerProvider.controller;
}
which should the correct way according to your flutter version since the function context.dependOnInheritedWidgetOfExactType doesn't take any positional parameters.
Just update your dependency to chewie: ^1.0.0.
This should fix it.

Why does Android Studio Dart Analysis throws error for required keyword?

I have a Coordinate Class where both parameters are required.
Both Android Studio and Visual Studio Code do not recognize the required keyword.
Why does Dart Analysis give Undefined class required error?
required isn't a type.
Try correcting the name to match an existing type.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
Coordinate coordinate = Coordinate(lon: 3.4, lat: 2.3);
return Container(
child: Text(coordinate.lat.toString()),
);
}
}
class Coordinate {
double lon;
double lat;
Coordinate({required lon, required lat});
}
Dart SDK version: 2.12.3 (stable)
Is the version of Dart updated to 2.12 on your environment?
The second error says required is not a valid keyword, the required keyword was added in Dart 2.12.
Note: The compiler is parsing the required keyword as a type and as it does not find the type required defined anywhere in the project it interprets it is as dynamic, Hence the error.
This is the answer to the question
Why does Android Studio Dart Analysis throws error for required keyword?
Now, If it is still not working for you, I suggest you open a new issue with the appropriate tags about the sdk install/environment issues you have. As this question has served its purpose