草庐IT

dart-polymer

全部标签

dart - setter 'msg=' 在 null 上被调用

我正在使用flutter向api发送请求,并将响应值保存在我的一个模型的实例中。但我收到一些奇怪的错误。您可以在下面看到我的代码和错误。我正在使用scoped_model进行状态管理。import'dart:convert';import'dart:async';import'dart:io';import'package:shared_preferences/shared_preferences.dart';import'package:scoped_model/scoped_model.dart';import'package:http/http.dart'ashttp;impor

dart - setter 'msg=' 在 null 上被调用

我正在使用flutter向api发送请求,并将响应值保存在我的一个模型的实例中。但我收到一些奇怪的错误。您可以在下面看到我的代码和错误。我正在使用scoped_model进行状态管理。import'dart:convert';import'dart:async';import'dart:io';import'package:shared_preferences/shared_preferences.dart';import'package:scoped_model/scoped_model.dart';import'package:http/http.dart'ashttp;impor

dart - 使用 Targetplatform 导致布局问题

我正在尝试检查用户使用的是Iphone还是Android我正在关注这个帖子以查看HowdoyoudetectthehostplatformfromDartcode?在我的initState中,我添加了以下检查typeOfDevice=Theme.of(context).platform==TargetPlatform.iOS?"1":"2";但每当我尝试使用它时,我都会收到以下错误I/flutter(22330):══╡EXCEPTIONCAUGHTBYWIDGETSLIBRARY╞════════════════════════════════════════════════════

dart - 使用 Targetplatform 导致布局问题

我正在尝试检查用户使用的是Iphone还是Android我正在关注这个帖子以查看HowdoyoudetectthehostplatformfromDartcode?在我的initState中,我添加了以下检查typeOfDevice=Theme.of(context).platform==TargetPlatform.iOS?"1":"2";但每当我尝试使用它时,我都会收到以下错误I/flutter(22330):══╡EXCEPTIONCAUGHTBYWIDGETSLIBRARY╞════════════════════════════════════════════════════

dart - 导入的库 'package:geolocator/model/position.dart' 不能有 part-of 指令

在我的flutter应用程序中,我一直在使用以下插件permission_handler,geolocator和google_api_availibility.我本可以从flutter包frompubspec.yml添加这个插件,但是,在我的应用程序中,我使用的是google_map_flutter一直在使用AndroidX支持库的插件。由于这个原因,我在本地添加了这些库,并进行了一些更改以与AndroidX一起使用。所以我的应用程序结构和pubspecs看起来像这样。所以在我的应用程序pubspecs.yml中dev_dependencies:flutter_test:sdk:flu

dart - 导入的库 'package:geolocator/model/position.dart' 不能有 part-of 指令

在我的flutter应用程序中,我一直在使用以下插件permission_handler,geolocator和google_api_availibility.我本可以从flutter包frompubspec.yml添加这个插件,但是,在我的应用程序中,我使用的是google_map_flutter一直在使用AndroidX支持库的插件。由于这个原因,我在本地添加了这些库,并进行了一些更改以与AndroidX一起使用。所以我的应用程序结构和pubspecs看起来像这样。所以在我的应用程序pubspecs.yml中dev_dependencies:flutter_test:sdk:flu

dart - flutter : Get AlertDialog From Another Dart File

我需要帮助伙计们。我有2个Dart文件:main.dart和alertform.dart。有些情况需要在我的应用程序中使用此方法。我想尝试通过main.dart上的按钮从alertform.dart访问alerdialog。那可能吗?这是我的代码:主.dartimport'package:flutter/material.dart';import'alertform.dart';classMainPageextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnScaffold(appBar:AppBa

dart - flutter : Get AlertDialog From Another Dart File

我需要帮助伙计们。我有2个Dart文件:main.dart和alertform.dart。有些情况需要在我的应用程序中使用此方法。我想尝试通过main.dart上的按钮从alertform.dart访问alerdialog。那可能吗?这是我的代码:主.dartimport'package:flutter/material.dart';import'alertform.dart';classMainPageextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnScaffold(appBar:AppBa

dart - 如何从 Future 对象 (Future<int>) 中获取原始值?

我正在获取Future实例,同时获取sharedPreference值,如下所示FuturegetCounterValue()async{SharedPreferencespreferences=awaitSharedPreferences.getInstance();returnpreferences.getInt("counter");}然后我想从Future实例中获取int值。请提前致谢。 最佳答案 无法从异步执行返回到同步执行。只能通过await或.then((param){print(param);})获取值您需要提供更多

dart - 如何从 Future 对象 (Future<int>) 中获取原始值?

我正在获取Future实例,同时获取sharedPreference值,如下所示FuturegetCounterValue()async{SharedPreferencespreferences=awaitSharedPreferences.getInstance();returnpreferences.getInt("counter");}然后我想从Future实例中获取int值。请提前致谢。 最佳答案 无法从异步执行返回到同步执行。只能通过await或.then((param){print(param);})获取值您需要提供更多