The method 'delete' isn't defined for the class 'AppJsImpl' - flutter

I develop the flutter app connected with Firebase.
The app work well on mobile devices, but when i try to build web i get this error:
/D:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_database_web-0.1.2/lib/src/interop/app.dart:35:59: Error: The method 'delete' isn't defined for the class 'AppJsImpl'.
- 'AppJsImpl' is from 'package:firebase_database_web/src/interop/app_interop.dart' ('/D:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_database_web-0.1.2/lib/src/interop/app_interop.dart').
package:firebase_database_web/…/interop/app_interop.dart:1
Try correcting the name to the name of an existing method, or defining a method named 'delete'.
Future delete() => core_interop.handleThenable(jsObject.delete());
I tried to put firebase_database_web: ^0.1.2+1 in pubspec.yaml, but error is still here.
Did someone have the same problem, and how are you fixed?
Thanks

I have tackled the issue by adding a row in the "app_interop.dart" file.
Before:
#JS('App')
abstract class AppJsImpl extends core_interop.AppJsImpl {
external DatabaseJsImpl database(String? databaseURL);
}
After:
#JS('App')
abstract class AppJsImpl extends core_interop.AppJsImpl {
external DatabaseJsImpl database(String? databaseURL);
external dynamic delete();
}

Add the latest version of firebase_database_web to your pubspec.yaml
Fixed it for me.

Related

Custom mail driver in Laravel 8

I'm using a custom mail driver with Laravel 8. It's good to work with direct mailing. But after using it should queue, an issue was found.
"Target class [mail.manager] does not exist."
I have already registered at config/app.php for customMailServiceProvider. The problem is only for when using shouldqueue at Notifications with mail. Any ideas or any suggestions? I was following the instruction for the following article.
https://www.delenamalan.co.za/2020/laravel-custom-mail-driver.html#create-a-custom-mail-transport-class
Add This code line at app/bootstrap.php
$app->alias('mail.manager', Illuminate\Mail\MailManager::class);
This is worked for me. Laravel Queue don't know the facades name "mail.manager".
Don't forget to run compose dump after code update.
In Providers/CustomMailServiceProvider.php change from:
class CustomMailServiceProvider extends ServiceProvider
{
to
class CustomMailServiceProvider extends MailServiceProvider
{

Flutter upgradation causing The getter 'fullObstruction' isn't defined for the class 'ObstructingPreferredSizeWidget'. error

My project was working fine with version 1.10.0, I have upgraded flutter to new version 1.12 and I am getting the below error
Compiler message:
../../../AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_platform_widgets-0.20.2/lib/src/platform_scaffold.dart:229:38: Error: The getter 'fullObstruction' isn't defined for the class 'ObstructingPreferredSizeWidget'.
- 'ObstructingPreferredSizeWidget' is from 'package:flutter/src/cupertino/page_scaffold.dart' ('/C:/src/flutter/packages/flutter/lib/src/cupertino/page_scaffold.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'fullObstruction'.
final obstruct = navigationBar.fullObstruction == null ||
^^^^^^^^^^^^^^^
../../../AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_platform_widgets-0.20.2/lib/src/platform_scaffold.dart:230:25: Error: The getter 'fullObstruction' isn't defined for the class 'ObstructingPreferredSizeWidget'.
- 'ObstructingPreferredSizeWidget' is from 'package:flutter/src/cupertino/page_scaffold.dart' ('/C:/src/flutter/packages/flutter/lib/src/cupertino/page_scaffold.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'fullObstruction'.
navigationBar.fullObstruction;
^^^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.
Degrading the flutter to 1.10 again the project is working fine, but I need to upgrade to this 1.12 version for webrtc library. Can somebody help to solve this issue?
For those who come across this issue, I am here with a solution. This issue took my 2 days and I was banging my head, why flutter package showing error eventhough I upgraded to the stable version of flutter v1.12.13+hotfix.5-stable.zip
Solution:
The issue above saying that fullObstruction is not defined for the class ObstructingPreferredSizeWidget which is in the file CupertinoPageScaffold.dart. So I took the file in the notepad which is in the flutter package. The original path is C:\src2\flutter\packages\flutter\lib\src\cupertino , src2 is the folder where my flutter package resides.
In that file I saw a variable is changed in the newer versions, instead of below variable earlier it was fullObstruction, they changed to bool shouldFullyObstruct(BuildContext context); in newer versions.
abstract class ObstructingPreferredSizeWidget extends PreferredSizeWidget {
/// If true, this widget fully obstructs widgets behind it by the specified
/// size.
///
/// If false, this widget partially obstructs.
bool shouldFullyObstruct(BuildContext context);
}
Then I check which file this error is occuring,
C:\src2\flutter.pub-cache\hosted\pub.dartlang.org\flutter_platform_widgets-0.20.2\lib\src\platform-scaffold.dart
earlier this line is using the deprecated variable fullObstruction, I replaced with the new variable and issue solved and my project is working as fine as earlier.
final obstruct = navigationBar.shouldFullyObstruct(context) == null ||
navigationBar.shouldFullyObstruct(context);
Hope this helps somebody.

How to get DPI device to PCL in Xamarin. Forms? - Followup

Using Xamarin Forms Visual Studio 2019.
I need to get the DPI of the device.
This post has a solution:
How to get DPI device to PCL in Xamarin. Forms?
Implementing the solution gave problems:
When applying the answer above I get this error message:
The type or namespace name 'DependencyAttribute' could not be found
(are you missing a using directive or an assembly reference?)
In your android implementation, add a new class:
[assembly: Dependency(typeof(DisplayInfo))]
namespace .....
--I solved this compiler problem by replacing with:
using Xamarin.Essentials;
[assembly: Xamarin.Forms.Dependency(typeof(DisplayInfo))]
However when I compile and run the code, it falls over when I try consume this in the Xamarin Core Code:
int dpi = DependencyService.Get<IDisplayInfo>().GetDisplayDpi();
I get this runtime error on the above line:
System.NullReferenceException: Object reference not set to an instance
of an object
Any ideas? I would have added this question as a comment on the original, but as a new user do not have the points to do this... If someone could drop a comment on the original question's solution pointing it to this URL that would be helpful too.
So the answer to my own question:
The solution original offered said do this:
In your android implementation, add a new class:
[assembly: Dependency(typeof(DisplayInfo))]
namespace YourAppNamespace.Droid
{
public class DisplayInfo : IDisplayInfo
{
public int GetDisplayWidth()
{
(int)Android.App.Application.Context.Resources.DisplayMetrics.WidthPixels;
}
public int GetDisplayHeight()
{
(int)Android.App.Application.Context.Resources.DisplayMetrics.HeightPixels;
}
public int GetDisplayDpi()
{
(int)Android.App.Application.Context.Resources.DisplayMetrics.DensityDpi;
}
}
}
The problem I did not see anywhere in the Android code that initialised this class, and I was unsure how best to do this really.
So I followed guidance for implementing the interface directly in the Android MainActivity.cs file, and this worked.. The video I watched to help me on that is here:
https://www.youtube.com/watch?v=lgcnYDb6cRQ&t=19s

Flutter - Error: The getter X isn't defined for the class

I have a class TripController that contains a private field _updatedAccount. I created a getter in order to get from outside.
class TripController {
final String _accountId;
final BuildContext _context;
Account _updatedAccount;
Account updatedAccount() => _updatedAccount;
TripController(this._accountId, this._context);
...
}
In another class, where I perfectly have access to the TripController class, I have the code :
onTap: () {
TripController _tripController =
new TripController(_account.id, context);
_tripController.add(context);
_account.trips = _tripController.updatedAccount.trips;
_account.notifyListeners();
},
And here, updatedAccount from _tripController.updatedAccount.trips is underlined in red with the message : The getter 'updatedAccount' isn't defined for the class 'TripController'
Did I misdeclared the getter ?
Okay, I finally fixed it. I don't know why, but I had to delete the code related to TripController, and ther re-write it again. I don't know why, maybe it was an Editor problem, I'm using VScode.
You have declared updatAccount() as a method, not as a getter. Use _tripController.updatedAccount().trips; or change the method to a getter Account get updatedAccount => _updatedAccount;
I faced this error and the problem was my IDE, not my code.
This solution worked for me in Android Studio :
File -> Invalidate Catches... -> Invalidate And Restart
You are using the classic method syntax declaration, in Dart language, prefer using this kind of syntax for getters:
Account get updatedAccount => _updatedAccount;
And call it the way you did.
Else you should call it like a classic method:
_tripController.updatedAccount().trips
Please follow this link for further information:
https://dart.dev/guides/language/language-tour#getters-and-setters
If you want to use import 'package:flutter_svg/svg.dart'; package then you need to follow these steps.
step 1. -> Open the termial in the IDE and run this command -> flutter pub add flutter_svg
step 2. -> Then run this command -> flutter pub get
step 3. -> Now import this package -> import 'package:flutter_svg/flutter_svg.dart';
Try to check the model class name you use might the same with existing name of Widget or Plugin
Check your imported libraries on the top of your file where the problem is. In my case, Android Studio auto-imported an object from the core Flutter library with the same name as the model I've defined on my own.
I just deleted the import and then imported my own object from my_models.dart file.

having problems with Zend framework validators

I'm having problem with custom builded validator that does not returns any error. I copied a file NotEmpty.php form folder library/Zend/Validate, rename class Zend_Validate_NotEmpty to My_Validate_EmailConfirmation and put it into folder My/Validate.
If I call this class like
->setRequired(true)->addValidator('NotEmpty',true,array('messages' => array('isEmpty' => "bla")));
I get the correct error, but if i call it like
->setRequired(true)->addValidator('EmailConfirmation',true,array('mess ages' => array('isEmpty' => "bla")))->addPrefixPath('My_Validate','My/Validate/','validate');
i get nothing...
What am i doing wrong?
Thanks is advanced for your answers...
Have you tried to set in your bootstrap file your new namespace?
Zend_Loader_Autoloader::getInstance()->registerNamespace('My');
Also, why not you just extends the NotEmpty validator instead of duplicate the class?