我有一个运行没有问题的项目,自从我更新到Android Studio 3.5.3和 后Flutter 1.13.1-pre.99 • channel master,同一个项目在尝试在真实设备上运行时出现了巨大的错误。
我在这里提到 Android Studio 和 Flutter 更新,因为我不确定它们中的哪一个(如果有)导致了问题。
在我看来,flutter_web这是我前段时间安装的一个问题……但我仍然不确定如何卸载 flutter_web 本身。
注意:当前项目不是 flutter web 项目
这里是完整的错误......(对不起,大文本):
Invalid depfile: /Users/user458395/Desktop/flutterProjects/testProjectX/.dart_tool/flutter_build/0732b8ad26463ce096dc3cab1564707e/kernel_snapshot.d
Invalid depfile: /Users/user458395/Desktop/flutterProjects/testProjectX/.dart_tool/flutter_build/0732b8ad26463ce096dc3cab1564707e/kernel_snapshot.d
Compiler message:
lib/routes/search_results_route.dart:1:8: Error: Not found: 'dart:html'
import 'dart:html';
^
../../../Downloads/flutterSdk/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+2/lib/src/browser_client.dart:6:8: Error: Not found: 'dart:html'
import 'dart:html';
^
../../../Downloads/flutterSdk/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+2/lib/src/browser_client.dart:97:25: Error: Type 'HttpRequest' not found.
void _openHttpRequest(HttpRequest request, String method, String url,
^^^^^^^^^^^
../../../Downloads/flutterSdk/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+2/lib/src/browser_client.dart:32:25: Error: 'HttpRequest' isn't a type.
final _xhrs = new Set<HttpRequest>();
^^^^^^^^^^^
../../../Downloads/flutterSdk/flutter/packages/flutter/lib/src/painting/_network_image_web.dart:64:12: Error: …Run Code Online (Sandbox Code Playgroud) 我已经更新到最新的 flutter 更新了。当我想启动项目时,它返回一个错误。该项目依赖于几个存储库,我不知道这是否是原因。我尝试了多种解决方案,但都没有解决该错误。希望可以有人帮帮我。谢谢。
\n\n编译器消息:
\n\n/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/mvvm-0.1.7/lib/view_context_helpers/logical.dart:151:25: Error: The function expression type 'Widget Function(BuildContext, Null, Widget) Function(TValue)' isn't of expected type 'Widget Function(BuildContext, TValue, Widget) Function(TValue)'.\n\n - 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/framework.dart').\n - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/framework.dart').\nChange the type of the function expression or the context in which it is used.\n selector: (TValue value) =>\n ^\nTarget kernel_snapshot failed: Exception: Errors during snapshot creation: null\nbuild failed.\n\nFAILURE: Build failed with an exception.\n\n* Where:\nScript 'C:\\src\\flutter\\packages\\flutter_tools\\gradle\\flutter.gradle' line: 780\n\n* What went wrong:\nExecution failed for …Run Code Online (Sandbox Code Playgroud) 我想SliverAppBar在ScrollablePositionedList.builder滚动时隐藏。这是我在此处包含的相关代码段。
NestedScrollView(
headerSliverBuilder: (context, innerBoxIsScrolled) => [
SliverAppBar(
backgroundColor: Colors.blue,
expandedHeight: 112,
snap: true,
pinned: false,
floating: true,
forceElevated: true,
actions: <Widget>[
IconButton(
icon: Icon(Icons.event),
)
],
flexibleSpace: SafeArea(
child: Column(
children: <Widget>[
Container(
height: kToolbarHeight,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Title',
style: Theme.of(context)
.textTheme
.title
.copyWith(
fontSize: 16, color: Colors.white),
),
SizedBox(
height: 2,
),
Text(
'Date',
style: Theme.of(context)
.textTheme
.caption
.copyWith(
fontSize: 10, color: Colors.white),
), …Run Code Online (Sandbox Code Playgroud) scroll-position nestedscrollview flutter flutter-layout sliverappbar
对于移动应用程序,连接插件工作正常。
import 'package:connectivity/connectivity.dart';
var connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.mobile) {
// I am connected to a mobile network.
} else if (connectivityResult == ConnectivityResult.wifi) {
// I am connected to a wifi network.
}
Run Code Online (Sandbox Code Playgroud)
但是有什么方法可以检测onPressedFlutter Web 中按钮的互联网连接情况吗?
我试图在工具栏操作 [] 中设置固定大小的 CircularProgressIndicator,但它给了我不合适的大小,我正在使用的代码,
Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(Lang.postDetails),
actions: <Widget>[
Container(
width: 16,
height: 16,
child: CircularProgressIndicator(),
)
Run Code Online (Sandbox Code Playgroud)
和我得到的输出,
我正在post使用Dio创建一个请求,这是我的FormData参数,
FormData formData = FormData.fromMap({
'wallet_id': '${dropdownValue.walletId}',
'member_id': '${_loginModel.memberId}',
'draw_amount': withdrawalAmountContoller.text,
'login_password': passwordController.text,
});
Run Code Online (Sandbox Code Playgroud)
然后我传递params这样的,
Response response = await dio.post(url, data: params);
Run Code Online (Sandbox Code Playgroud)
但我收到请求时出错,
错误[DioError [DioErrorType.RESPONSE]:Http 状态错误[405]] => 路径:https ://vertoindiapay.com/pay/api/withdraw
E/flutter (6703): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] 未处理的异常:DioError [DioErrorType.RESPONSE]: Http 状态错误 [405]
E/flutter(6703):#0 DioMixin._request._errorInterceptorWrapper。(包:dio/src/dio.dart:848:13)
请帮我解决这个问题。我的网址是=> https://vertoindiapay.com/pay/api/withdraw
虽然这在邮递员中工作正常,
在编写 Flutter 小部件测试时,我遇到了一个错误,其中在 showModalBottomSheet() 期间创建的 Ticker 未被处理。
\n\n我想我明白,如果我正在实现自己的 Flutter 动画,我应该制作一个 AnimationController,并且我会AnimationController.dispose()在小部件期间调用dispose方法期间调用。
然而,由于(我相信)AnimationController 被抽象出来以提供一些便利,我不确定在哪里或如何确保测试完成后处理该小部件。
\n\n注意:代码有效,当我在模拟器/仿真器上测试时,模式底部表单很棒。我只是想能够在一个testWidgets测试中测试它。
我查看了 showModalBottomSheet 文档https://api.flutter.dev/flutter/material/showModalBottomSheet.html但仅显示了如何使用该函数。我没有找到任何方法来控制何时可以处理动画。
\n\n(额外的pump()在出现异步问题时额外提供,但似乎没有帮助)
testWidgets(\'Taping edit score button brings up bottom sheet to edit\',\n (WidgetTester tester) async {\n setUp();\n await tester.pumpWidget(MaterialApp(\n home: GameList(\n game: Game(players: players),\n ),\n ));\n await tester.tap(find.byKey(Key(\'p1-edit-score\')));\n await tester.pump();\n await tester.pump();\n expect(find.byKey(Key(\'test\')), findsOneWidget);\n await tester.tap(find.byKey(Key(\'tap-me\')));\n await tester.pump();\n await tester.pump();\n tearDown();\n });\nRun Code Online (Sandbox Code Playgroud)\n\n\nclass …Run Code Online (Sandbox Code Playgroud) 我想在我的应用程序中播放 srt 字幕。 到目前为止我已经集成了srt_parser 。另外,我可以通过这段代码获取玩家的当前位置
inMilliseconds = _videoPlayerController.value.position.inMilliseconds;
Run Code Online (Sandbox Code Playgroud)
这是srt解析代码。
String data = '''1
00:00:01,600 --> 00:00:04,200
English (US)
2
00:00:05,900 --> 00:00:07,999
This is a subtitle in American English
3
00:00:10,000 --> 00:00:14,000
Adding subtitles is very easy to do''';
srtParser() {
List<Subtitle> subtitles = parseSrt(data);
for (Subtitle item in subtitles) {
print(
'inMilliseconds ${inMilliseconds} Begin is: ${item.range.begin} and End is:
${item.range.end}');
if (inMilliseconds > item.range.begin &&
inMilliseconds < item.range.end) {
for (var line in item.parsedLines) {
for …Run Code Online (Sandbox Code Playgroud) 我在里面有“下一个”和“上一个”按钮flexibleSpace,如下所示,“下一个”和“上一个”按钮的文本在滚动时隐藏,但向前和向后箭头不隐藏。我希望它们在滚动时隐藏。
这是我的代码
SliverAppBar(
backgroundColor: selectedColor ?? Colors.blue,
expandedHeight: 112,
snap: true,
pinned: false,
floating: true,
forceElevated: true,
actions: <Widget>[
IconButton(
icon: Icon(Icons.event),
onPressed: () {
DateTime now = DateTime.now();
_selectDate(context, now);
})
],
flexibleSpace: selectedTitle != null ? SafeArea(
child: Column(
children: <Widget>[
Container(
height: kToolbarHeight,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
selectedTitle?.toUpperCase() ?? '',
style: Theme
.of(context)
.textTheme
.title
.copyWith(fontSize: 16, color: Colors.white),
),
SizedBox(
height: 2,
),
isWeekly
? SizedBox(
height: 0,
width: …Run Code Online (Sandbox Code Playgroud) 我想将 inputDecoration errorText 与 TextField 的右下角对齐。默认模式是左下角。我想将其设置为
这是我的文本字段代码:
TextField authTextFiled(
String hint, ValidationBloc bloc, AsyncSnapshot<String> snapshot) {
return TextField(
textAlign: TextAlign.right,
onChanged: (String text) => bloc.updateText(text),
decoration: InputDecoration(
hintStyle: AppStyle.textFieldHintTextStyle,
errorStyle: AppStyle.textFieldErrorTextStyle,
errorText: snapshot.hasError ? snapshot.error : null,
border: OutlineInputBorder(borderRadius: AppStyle.borderRadius),
disabledBorder: OutlineInputBorder(
borderRadius: AppStyle.borderRadius,
borderSide: BorderSide(width: 1, color: AppColors.pinkDarkDisableColor)
),
focusedBorder: OutlineInputBorder(
borderRadius: AppStyle.borderRadius,
borderSide: BorderSide(width: 1, color: AppColors.bluePrimaryColor),
),
errorBorder: OutlineInputBorder(
borderRadius: AppStyle.borderRadius,
borderSide: BorderSide(width: 1, color: AppColors.pinkDarkHotColor)
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: AppStyle.borderRadius,
borderSide: BorderSide(width: 1, color: AppColors.pinkDarkHotColor)),
hintText: …Run Code Online (Sandbox Code Playgroud) 所以我使用一个名为timebuilder 的包来重建我的小部件。对于 DateFormat 类,我使用了这个包。
final String currentTime = getSystemTime();
static String getSystemTime() {
var now = new DateTime.now();
return new DateFormat("H:m:s").format(now);
}
@override
Widget build(BuildContext context) {
return TimerBuilder.periodic(Duration(seconds: 1), builder: (context) {
print("$currentTime");
return Text(
"$currentTime",
style: TextStyle(
color: Color(0xff2d386b),
fontSize: 30,
fontWeight: FontWeight.w700),
);
});
}
}
Run Code Online (Sandbox Code Playgroud)
然后我将显示 ClockWidget。我的小部件重建得很好。但 currentTime 的值仍然是我构建项目时最初的值。关于为什么 currentTime 不更新的任何线索?
flutter ×11
dart ×4
sliverappbar ×2
clock ×1
dio ×1
flutter-test ×1
flutter-web ×1
http ×1
srt ×1
subtitle ×1
textfield ×1
video-player ×1
vtt ×1