使用颤振,我尝试在地理定位器中使用 StreamSubscription 和 getPositionStream 检索当前位置。但我不断收到错误消息:错误:未为类“Geolocator”定义方法“getPostionStream”。
这是我的功能:
void getLocationUpdates(){
StreamSubscription<Position> homeTabPostionStream;
homeTabPostionStream = geoLocator.getPositionStream(locationOptions).listen((Position position){
currentPosition = position;
});
Run Code Online (Sandbox Code Playgroud)
在这里我创建了变量:
var geoLocator = Geolocator();
var locationOptions = LocationOptions(accuracy: LocationAccuracy.bestForNavigation, distanceFilter: 4);
Run Code Online (Sandbox Code Playgroud)
根据您的要求,我编写了整个代码以供参考。
这是整个代码:
class HomeTab extends StatefulWidget {
@override
_HomeTabState createState() => _HomeTabState();
}
class _HomeTabState extends State<HomeTab> {
GoogleMapController mapController;
Completer<GoogleMapController> _controller = Completer();
Position currentPosition;
DatabaseReference tripRequestRef;
var geoLocator = Geolocator();
var locationOptions = LocationOptions(accuracy: LocationAccuracy.bestForNavigation, distanceFilter: 4);
void getCurrentPosition() async{
Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.bestForNavigation);
currentPosition = …Run Code Online (Sandbox Code Playgroud) 我刚刚在 Flutter 应用程序中更新了 Google Firebase Auth,因为我遇到了一些错误的 SDK 错误,但现在我得到了:
错误:“currentUser”不是函数或方法,无法调用。用户 currentFirebaseUser = await FirebaseAuth.instance.currentUser();
我查看了迁移指南并了解到 currentUser() 现在通过 currentUser getter 同步。但我不确定我现在应该如何更改我的代码来解决这个问题。
static void getCurrentUserInfo() async{
User currentFirebaseUser = await FirebaseAuth.instance.currentUser();
String userid = currentFirebaseUser.uid;
DatabaseReference userRef = FirebaseDatabase.instance.reference().child('users/$userid');
userRef.once().then((DataSnapshot snapshot){
if(snapshot.value != null){
}
});
Run Code Online (Sandbox Code Playgroud)
}
当我尝试为虚幻引擎 4.26 构建 cpp 代码时出现错误。我正在尝试添加到我的游戏功能中,以确定我玩游戏时的表面类型。这就是我添加 UDeterminSurfaceType 函数的原因。部分代码如下所示:
SurfaceType = UPhysicalMaterial::DetermineSurfaceType(Hit.PhysMaterial.Get());
UParticleSystem* SelectedEffect = nullptr;
switch (SurfaceType)
{
case SurfaceType1:
SelectedEffect = FleshImpactEffect;
break;
case SurfaceType2:
SelectedEffect = FleshImpactEffect;
break;
default:
SelectedEffect = DefaultImpactEffect;
break;
}
if (SelectedEffect)
{
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), SelectedEffect, Hit.ImpactPoint,
Hit.ImpactNormal.Rotation());
}
Run Code Online (Sandbox Code Playgroud)
我知道事实尚未完善,我稍后会这样做。添加此行并构建项目后,出现 LNK2019 错误。
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: static enum
EPhysicalSurface __cdecl UPhysicalMaterial::DetermineSurfaceType(class UPhysicalMaterial const *)"
(__imp_?DetermineSurfaceType@UPhysicalMaterial@@SA?AW4EPhysicalSurface@@PEBV1@@Z) referenced in
function "public: virtual void __cdecl ASWeapon::Fire(void)" (?Fire@ASWeapon@@UEAAXXZ)
Run Code Online (Sandbox Code Playgroud)
此错误意味着,我的 ASWeapon 类头文件中有一个名为“Fire”的方法,但它在您的 SWeapon.CPP 文件中不存在。因此,链接器为您的武器类创建了一个 OBJ 文件,然后当它尝试将声明与实现相匹配时,它找不到实现并且您会收到这个可爱的链接器错误。但是我已经在 CPP 和头文件中都有方法“Fire”。它是在这里创建的: …
firebase ×2
flutter ×2
c++ ×1
dart ×1
dart-pub ×1
flutter-web ×1
game-engine ×1
geolocation ×1
visual-c++ ×1