我注意到我的项目中出现了新的 lint 问题。
长话短说:
我需要在我的自定义类中使用 BuildContext
flutter lint 工具与 aysnc 方法一起使用时并不满意。
例子:
MyCustomClass{
final buildContext context;
const MyCustomClass({required this.context});
myAsyncMethod() async {
await someFuture();
# if (!mounted) return; << has no effect even if i pass state to constructor
Navigator.of(context).pop(); # << example
}
}
Run Code Online (Sandbox Code Playgroud) dart flutter flutter-dependencies flutter-state flutter-build
我收到此错误:
未找到成员:“FirebaseAppPlatform.verifyExtends”。FirebaseAppPlatform.verifyExtends(_delegate);
flutter clean
flutter pub get
pod install
Run Code Online (Sandbox Code Playgroud) 当我运行应用程序时,它卡住了
Launching lib\main.dart on Lenovo A319 in debug mode...
Running Gradle task 'assembleDebug'...
(This is taking an unexpectedly long time.)
Run Code Online (Sandbox Code Playgroud)
它从不初始化 Gradle 和依赖项
在尝试在 Android Studio 上运行任何 flutter 项目时,我收到以下特定错误:
[+11147 ms] [+13655 ms] ../../flutter/.pub-cache/hosted/pub.dartlang.org/platform-3.0.2/lib/src/interface/local_platform.dart:46:19: Error: Member not found: 'packageRoot'.
[ ] [ +1 ms] io.Platform.packageRoot; // ignore: deprecated_member_use
[ ] [ ] ^^^^^^^^^^^
Run Code Online (Sandbox Code Playgroud)
在网上查了好久,没有找到可行的解决方案。任何人都可以帮忙修复吗?
一旦我将 flutter 更新到 1.12.13 版,我就发现了这个问题并且无法修复它。我按照firebase_messaging教程发送的,得到以下错误:“错误:类型不兼容:PluginRegistry无法转换为FlutterEngine GeneratedPluginRegistrant.registerWith(registry);”我的代码如下:
package io.flutter.plugins;
import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.os.Build;
public class Application extends FlutterApplication implements PluginRegistrantCallback {
@Override
public void onCreate() {
super.onCreate();
FlutterFirebaseMessagingService.setPluginRegistrant(this);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
NotificationChannel channel = new NotificationChannel("messages","Messages", NotificationManager.IMPORTANCE_LOW);
NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(channel);
}
}
@Override
public void registerWith(PluginRegistry registry) {
GeneratedPluginRegistrant.registerWith(registry);
}
}
Run Code Online (Sandbox Code Playgroud) firebase flutter firebase-cloud-messaging flutter-dependencies
我在我的 android flutter 应用程序中使用了 google maps api 和 location pub,dev 包,并尝试使用 api 中的 url 调出图像。这是带有一些代码的网址:
class LocationHelper{
static String mapviewpointer({double latitude, double longitude}){
return "https://maps.googleapis.com/maps/api/staticmap?center=$latitude,$longitude&zoom=13&size=600x300&maptype=roadmap&markers=color:pink%7Clabel:C%7C$latitude,$longitude&key=$GOOGLE_API_KEY";
}
}
Run Code Online (Sandbox Code Playgroud)
它抛出以下错误消息:
Plugin project :location_web not found. Please update settings.gradle;
我不知道如何解决这个错误。
这是我在终端中收到的另一个错误:
I/flutter (21880): Invalid argument(s): No host specified in URI file:///Instance%20of%20'Future%3CString%3E'
Run Code Online (Sandbox Code Playgroud)
我收到上述错误消息的区域在我的代码中:
Future <String> _getUserLocation() async{
final locData = await Location().getLocation();
final staticMapUrl = LocationHelper.mapviewpointer(
latitude: locData.latitude,
longitude: locData.longitude,
);
return staticMapUrl;
}
final mapview = _getUserLocation();
class NearbyScreen extends StatelessWidget {
@override …Run Code Online (Sandbox Code Playgroud) google-maps-api-3 dart flutter flutter-dependencies flutter-web
我正在使用最新版本的Android Studio IDE来创建flutter应用程序。但是当我从 Mojave 升级到 Catalina 并尝试flutter在 IDE 上打开我的代码时,它给了我一个错误:
由于无法验证开发者,因此无法打开 Dart
错误背后的原因是什么,我该如何解决这个问题?
我是否必须再次从头开始安装 flutter 和相关开发工具,或者有其他方法可以解决问题吗?
dart android-studio flutter flutter-dependencies macos-catalina
我无法修复这个错误
RenderBox 未布局:RenderPointerListener#2b92a relayoutBoundary=up9 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 'package:flutter/src/rendering/box.dart':断言失败:第 1940 行 pos 12:'hasSize'。相关的导致错误的小部件是 ->ListView
这是我的所有产品部分。
import 'package:flutter/material.dart';
import 'package:hospital/Drawer/drawercontent.dart';
import 'package:hospital/Product/AllProducts/ProductList/product_list.dart';
import 'package:hospital/Product/AllProducts/carousel.dart';
import 'package:hospital/Product/AllProducts/category.dart';
class AllProducts extends StatefulWidget {
@override
_AllProductsState createState() => _AllProductsState();
}
class _AllProductsState extends State<AllProducts> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.green,
title: Text(
"Product",
style: TextStyle(fontStyle: FontStyle.italic),
),
actions: [
IconButton(
icon: Icon(Icons.person),
onPressed: () => print("open cart"),
),
],
),
drawer: Drawer(
child: DrawerContent(),
),
body: ListView(
children: [
Carousel(), …Run Code Online (Sandbox Code Playgroud) flutter flutter-test flutter-dependencies flutter-layout flutter-animation
我试图使用 pub get 来获取我的依赖项,但我不断收到一堆错误。我陷入了这些错误。
我已经尝试过 flutter clean, flutter upgrade and flutter doctor没有任何问题。然后我尝试了 flutter pub cache repair女巫给了我这个错误Failed to reactivate 1 package: - intl_utils pub finished with exit code 69
完全错误
The plugins `facebook_audience_network, flutter_statusbarcolor_ns, flutter_webview_plugin,
notification_permissions, onesignal_flutter, sms_autofill` use a deprecated version of the
Android embedding. To avoid unexpected runtime failures or future build failures, try to
see if these plugins support the Android V2 embedding. Otherwise, consider removing them
since a future release of Flutter will remove …Run Code Online (Sandbox Code Playgroud) 运行flutter build appbundle命令时,我收到以下错误:
../../.pub-cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart:13:17:
Error: Field 'wLanguage' cannot be nullable or have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`.
external int? wLanguage;
^
../../.pub-cache/hosted/pub.dev/package_info_plus_windows-2.1.0/lib/src/file_version_info.dart:16:17:
Error: Field 'wCodePage' cannot be nullable or have type 'Null', it must be `int`, `double`, `Pointer`, or a subtype of `Struct` or `Union`.
external int? wCodePage;
^
Target kernel_snapshot failed: Exception
FAILURE: Build failed with an exception.
Run Code Online (Sandbox Code Playgroud)
我使用的是颤振3.10.0。在我更新flutter版本之前,项目运行得很好。
flutter ×10
dart ×5
firebase ×2
android ×1
deprecated ×1
flutter-test ×1
flutter-web ×1
flutter3.x ×1
gradle ×1
ios ×1
xcode ×1
yaml ×1