我正在与此DropDownItem框错误作斗争,似乎一切正常,但在加载时弹出黄色越界。尝试了几件事,但无法解决。我的Widget.
@override
Widget build(BuildContext context) {
var _children = <Widget>[
!_createNew ? _referrerPractice() : _referrerCreate(),
];
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new Column(
mainAxisSize: MainAxisSize.max,
children: _children,
));
}
Run Code Online (Sandbox Code Playgroud)
然后我将其用作功能之一。
Widget _referrerPractice() {
assert(!_createNew);
return new Form(
key: _formKey2,
child: new Expanded(
child: new ListView(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
children: <Widget>[
new InputDecorator(
decoration: const InputDecoration(
labelText: 'Referrer Practice',
hintText: 'Choose Referrer Practice or choose new',
),
isEmpty: _referPractice == …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用网络调用实现一个简单的新闻提要应用程序,其中屏幕将在 Listview 中显示最新故事。
使用当前代码,我从 API 得到响应(因为我在日志中看到了整个响应主体),但似乎无法在 UI 中显示数据。我收到此错误:
type _InternalLinkedHashMap<String, dynamic> 不是 List 类型的子类型
这是 JSON 结构
{
"response": {
"status": "ok",
"userTier": "developer",
"total": 25095,
"startIndex": 1,
"pageSize": 10,
"currentPage": 1,
"pages": 2510,
"orderBy": "relevance",
"results": [
{
"id": "australia-news/2018/aug/13/turnbulls-energy-policy-hangs-in-the-balance-as-euthanasia-debate-given-precedence",
"type": "article",
"sectionId": "australia-news",
"sectionName": "Australia news",
"webPublicationDate": "2018-08-12T18:00:08Z",
"webTitle": "Energy policy hangs in balance, as Senate debates euthanasia",
"webUrl": "https://www.theguardian.com/australia-news/2018/aug/13/turnbulls-energy-policy-hangs-in-the-balance-as-euthanasia-debate-given-precedence",
"apiUrl": "https://content.guardianapis.com/australia-news/2018/aug/13/turnbulls-energy-policy-hangs-in-the-balance-as-euthanasia-debate-given-precedence",
"isHosted": false,
"pillarId": "pillar/news",
"pillarName": "News"
}, {
"id": "media/2018/jun/13/the-rev-colin-morris-obituary-letter",
"type": "article",
"sectionId": "media",
Run Code Online (Sandbox Code Playgroud)
对于我的理解,我只是想先webTitle …
我正在尝试制作一个 flutter 插件,所以我通过https://flutter.dev/docs/development/packages-and-plugins/developing-packages 上提供的步骤创建了一个插件。当我尝试运行 ios 示例时出现错误。下面是我在运行 ios 示例应用程序时得到的日志。
谁能帮我这个?
Running pod install...
CocoaPods' output:
Analyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
Fetching external sources
-> Fetching podspec for `Flutter` from `.symlinks/flutter/ios`
-> Fetching podspec for `flutter_plugin` from `.symlinks/plugins/flutter_plugin/ios`
Resolving dependencies of `Podfile`
Comparing resolved specification to the sandbox manifest
A Flutter
A flutter_plugin
Downloading dependencies
-> Installing Flutter (1.0.0)
-> Installing flutter_plugin (0.0.1)
- Running pre-install hooks
[!] Unable …Run Code Online (Sandbox Code Playgroud) 我构建了一个函数,用于在共享首选项中存储令牌,然后当我第一次运行我的应用程序出现错误时从服务器获取数据
以下 NoSuchMethodError 被抛出构建 AdminPage(dirty, state: AdminPageState#87bcd): flutter: The method '[]' was called on null. 颤振:接收方:空颤振:尝试调用:
然后应用程序运行良好
PS我的代码是
Future<Map<String, dynamic>> getCards(String userid) async {
BuildContext context;
String jWTtoken = '';
try {
final SharedPreferences prefs = await SharedPreferences.getInstance();
// prefs = await SharedPreferences.getInstance();
jWTtoken = prefs.getString('token');
tokenfoo();
} catch (e) {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (BuildContext context) => AuthPage()),
);
}
final Map<String, dynamic> authData = {
'Userid': '261',
// 'Email':_formData['Email'],
// 'Password':_formData['Password'],
};
final http.Response response = await http.post(
'hurl', …Run Code Online (Sandbox Code Playgroud) 我的 Flutter 应用程序在我的 iOS 设备上无法运行,而在 android 上却运行良好。我遇到了一个错误pod install
这是输出 pod install --verbose
alyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
Using `ARCHS` setting to build architectures of target `Pods-OneSignalNotificationServiceExtension`: (``)
Finding Podfile changes
A contacts_service
A firebase_auth
A flutter_crashlytics
A local_auth
A onesignalflutter
A path_provider
A permission
A sqflite
A url_launcher
- Flutter
- OneSignal
- cloud_functions
- firebase_core
Fetching external sources
-> Fetching podspec for `Flutter` from `.symlinks/flutter/ios`
-> Fetching …Run Code Online (Sandbox Code Playgroud) 我已经发布了带有签名密钥的 apk,但它没有安装在 android 设备上,它显示此消息“ apk 无法安装错误:无法解析错误字符串”但调试模式 apk,该应用程序工作正常。
释放命令
颤振构建 apk --release。
我确实按照这个问题来解决它,希望它可以帮助某人。
我正在尝试向我的应用添加横幅广告。我希望横幅显示在我的应用程序的某些页面上,但是一旦您到达某些页面,我希望横幅消失。所以我让我的横幅出现并且它正在工作。我还发现使用
super.dispose();
myBanner?.dispose();
Run Code Online (Sandbox Code Playgroud)
在我的 onPressed 按钮上将摆脱横幅。但是,当我弹回加载横幅的页面时,出现错误:
I/flutter (7058): 处理手势时抛出以下断言:I/flutter (7058): 'package:firebase_admob/firebase_admob.dart': Failed assertion: line 227 pos 12: '_allAds[id] != I /flutter ( 7058): null': 不是真的。
然后我无法点击任何在 onPressed 上有我处置的按钮。
我试过添加 super.dispose() 因为我只有 myBanner?.dispose(); 之前,但结果是一样的。我无法找到有关 admob 的大量信息。
这是我设置横幅的方法:
BannerAd myBanner = BannerAd(
// Replace the testAdUnitId with an ad unit id from the AdMob dash.
// https://developers.google.com/admob/android/test-ads
// https://developers.google.com/admob/ios/test-ads
adUnitId: adUnitId,
size: AdSize.smartBanner,
targetingInfo: targetingInfo,
listener: (MobileAdEvent event) {
print("BannerAd event is $event");
},
);
Run Code Online (Sandbox Code Playgroud)
然后在我的课上:
class EnMainMenu extends StatefulWidget {
@override …Run Code Online (Sandbox Code Playgroud) 我试图实现一个简单的登录/注销功能。我的场景是这样的:
我有 2 个页面(登录页面和主页),在 中main.dart,我使用 SharedPreferences 检查用户是否已登录,如果用户已登录,我在单击按钮时将布尔值设置为 true。
我遇到的问题是,我创建了一个 routeLogin 函数,用于在主页和登陆页面之间进行选择。我得到这个错误:
I/flutter ( 9026): ??? EXCEPTION CAUGHT BY WIDGETS LIBRARY ????????????????????????????????????????????????????????????
I/flutter ( 9026): The following assertion was thrown building MyApp(dirty):
I/flutter ( 9026): type 'Future<dynamic>' is not a subtype of type 'bool'
I/flutter ( 9026):
I/flutter ( 9026): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter ( 9026): more information in this error message to help you determine and …Run Code Online (Sandbox Code Playgroud) 在我的 flutter 应用程序中,我使用此代码转到我的仪表板页面,但第一次没有这样做,我收到了debugLocked错误消息。
应用程序中的启动页面是一个路由器,它检查共享首选项“sessionid”,如果设置,则将用户直接带到仪表板,否则将他们带到登录。
如果没有下面的代码,我就可以很好地访问我的仪表板,Navigator.pushReplacement()但是随后,appBar 上出现了一个后退箭头。此后退按钮将应用程序带回路由器。
我搜索了有关如何从导航器中删除所有屏幕的答案,以下是我发现的内容。
Navigator.of(context).popUntil(ModalRoute.withName(Dashboard.id));
Run Code Online (Sandbox Code Playgroud)
使用上面的代码给了我debugLocked错误。有没有办法缓解这个问题?或者有没有其他有效的方法可以从上下文中删除屏幕?设置是否automaticallyImplyLeading有false帮助?因为只有在有人登录或注册后才会出现此错误。
我是 flutter 的初学者,我已经创建了我的应用程序,但我想检查用户安装后是否第一次打开应用程序,我看过这篇文章但不知道怎么做?
这是初始屏幕代码,该代码在 3 秒后将用户直接移动到主屏幕,但我想检查用户是否第一次打开应用程序并将用户移动到欢迎屏幕,或者用户是否不是第一次并移动用户到主屏幕。
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:book_pen/main.dart';
import 'package:book_pen/Welcome.dart';
void main() {
runApp(new MaterialApp(
home: new SplashScreen(),
routes: <String, WidgetBuilder>{
'/HomePage': (BuildContext context) => new HomePage(),
'/WelcomePage': (BuildContext context) => new WelcomePage()
},
));
}
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => new _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
startTime() async {
var _duration = new Duration(seconds: 3);
return new Timer(_duration, navigationPageHome);
}
void navigationPageHome() {
Navigator.of(context).pushReplacementNamed('/HomePage');
}
void navigationPageWel() …Run Code Online (Sandbox Code Playgroud)