这是我的时间戳=“2020-05-29T17:43:39.622832+05:30”。我如何将它传递给函数 readTimeStamp (它会给我不是 int 类型的错误)?
date = DateTime.parse(bookDetails.timestamp);
print(readTimestamp(date));
String readTimestamp(int timestamp) {
var now = DateTime.now();
var date = DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
var diff = now.difference(date);
String time = '';
if (diff.inSeconds <= 0 ||
diff.inSeconds > 0 && diff.inMinutes == 0 ||
diff.inMinutes > 0 && diff.inHours == 0 ||
diff.inHours > 0 && diff.inDays == 0) {
} else if (diff.inDays > 0 && diff.inDays < 7) {
if (diff.inDays == 1) {
time = diff.inDays.toString() + …Run Code Online (Sandbox Code Playgroud) 我正在尝试编译https://github.com/dart-lang/protobuf/tree/master/protoc_plugin
根据自述文件,我应该运行pub install. 我有 flutter SDK,应该包含 Dart SDK。
我试过:
flutter pub install
Could not find a subcommand named "install" for "flutter pub".
Run Code Online (Sandbox Code Playgroud)
和
dart pub install
Error: Error when reading 'pub': No such file or directory
Run Code Online (Sandbox Code Playgroud)
和
pub install
/bin/sh: 1: pub: not found
Run Code Online (Sandbox Code Playgroud)
如何使用flutter SDK编译它?
当我尝试在 iOS 模拟器上启动我的 flutter 应用程序时,我看到一个白色的空白屏幕,如下所示:
\n Launching lib/main.dart on iPhone 12 Pro Max in debug mode...\nRunning Xcode build... \n \xe2\x94\x94\xe2\x94\x80Compiling, linking and signing... 13.7s\nXcode build done. 38.0s\n[VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: Invalid argument(s): Object/factory with type Api is already registered inside GetIt. \n#0 throwIf (package:get_it/get_it_impl.dart:7:18)\n#1 _GetItImplementation._register (package:get_it/get_it_impl.dart:729:5)\n#2 _GetItImplementation.registerLazySingleton (package:get_it/get_it_impl.dart:502:5)\n#3 setupLocator (package:r/locator.dart:14:18)\n#4 main (package:r/main.dart:12:3)\n#5 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:140:25)\n#6 _rootRun (dart:async/zone.dart:1354:13)\n#7 _CustomZone.run (dart:async/zone.dart:1258:19)\n#8 _runZoned (dart:async/zone.dart:1788:10)\n#9 runZonedGuarded (dart:async/zone.dart:1776:12)\n#10 _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:133:5)\n#11 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:283:19)\n#12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.<\xe2\x80\xa6>\nSyncing files to device iPhone 12 Pro Max... 137ms\nRun Code Online (Sandbox Code Playgroud)\n integration_test自从我尝试添加package 以来,我一直收到错误get_test,这主要是由于just_audio取决于crypto: ^3.0.0whileintegration_test取决于crypto: ^2.1.5。
我尝试在网上查看是否可以只安装没有 dev_dependency 的依赖项,但是基于此问题, flutter pub cli 工具似乎还不支持这一点。
这是我的pubspec.yaml
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
share: ^2.0.1
get:
get_storage:
shared_preferences: ^2.0.5
audio_service: 0.17.0-nullsafety.0
just_audio: ^0.7.4
dev_dependencies:
flutter_test:
sdk: flutter
get_test: ^3.13.3
integration_test: ^1.0.2+1
test: ^1.14.4
Run Code Online (Sandbox Code Playgroud)
这是我收到的错误。
Because every version of integration_test depends on flutter_driver any from sdk which depends on crypto 2.1.5, every version of integration_test requires crypto 2.1.5.
And …Run Code Online (Sandbox Code Playgroud) 每当我尝试进行注册并点击注册按钮时,我都会遇到这种类型的问题,即对空值使用空检查运算符。\n我收到此错误消息
\n\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90 手势捕获异常 \xe2\x95\x90\xe2\x95 \x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90 \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2 \x95\x90\xe2\x95\x90
\n处理手势时引发以下 _CastError:\n对 null 值使用 Null 检查运算符
\n当异常抛出时,这是堆栈
\n#0 _AuthorizationState.build。\npackage:gr_space/screens/profile_screen.dart:244
\n#1 _InkResponseState._handleTap\npackage:flutter/\xe2\x80\xa6/material/ink_well.dart:989
\n#2 GestureRecognizer.invokeCallback\npackage:flutter/\xe2\x80\xa6/gestures/recognizer.dart:182
\n#3 TapGestureRecognizer.handleTapUp
\n包:flutter/\xe2\x80\xa6/gestures/tap.dart:607
\n#4 BaseTapGestureRecognizer._checkUp\npackage:flutter/\xe2\x80\xa6/gestures/tap.dart:296
\n...\n处理程序:“onTap”\n识别器:TapGestureRecognizer#f8d29\ndebugOwner:GestureDetector\n状态:就绪\nwon arena\nfinalPosition:偏移(215.0,716.5)\nfinalLocalPosition:偏移(199.0,16.0)\n按钮:1\nsent向下点击\n\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95 \x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90 \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2 \x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95 \x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90 \xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2 \x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90
\n这是我的身份验证屏幕。飞镖文件
\nimport 'package:flutter/material.dart';\n\nenum AuthMode { Signup, Login }\n\nclass ProfileScreen extends StatelessWidget {\n static const routeName = '/profile';\n @override\n Widget build(BuildContext context) {\n return AnimatedContainer(\n duration: Duration(milliseconds: 300),\n child: Authorization(),\n );\n }\n}\n\nclass Authorization extends StatefulWidget {\n …Run Code Online (Sandbox Code Playgroud) 我手动删除了外部库/dart包中的包。现在我再次尝试跑步packages get。包(tesseract_ocr)没有出现在外部库/dart包中。我尝试在 pubspec.yaml 中删除它并重新添加它,但没有再次出现。我尝试删除.pub-cache并packages get再次运行。我尝试了flutter clean很多次,但都没有使tessarect_ocrflutter pub cache repair包重新出现在外部库/dart 包中。请帮忙。提前致谢!flutter pub cache add tessarect_ocrpackages get
最近,我的调试控制台显示了以前未显示的内容。当我使用包时会发生这种情况flutter_typeahead。我不知道这是错误还是警告。下面是我的调试控制台:
Launching lib\main.dart on Chrome in debug mode...
: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Documents/flutter/packages/flutter/lib/src/widgets/binding.dart').
WidgetsBinding.instance!.removeObserver(this);
^
: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Documents/flutter/packages/flutter/lib/src/widgets/binding.dart').
WidgetsBinding.instance!.addObserver(this);
^
: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Documents/flutter/packages/flutter/lib/src/widgets/binding.dart').
WidgetsBinding.instance!.addPostFrameCallback((duration) {
^
: Warning: Operand of null-aware operation …Run Code Online (Sandbox Code Playgroud) [信息] 预编译构建脚本...... [警告] ../../flutter/.pub-cache/hosted/pub.dartlang.org/gql_code_builder-0.2.0/lib/src/ast.dart: 618:12:错误:必须返回非空值,因为返回类型“表达式”不允许为空。
[严重] 无法预编译构建脚本 .dart_tool/build/entrypoint/build.dart。这可能是由错误配置的构建器定义引起的。
我一直在尝试为我的代码生成 dart 图,但出现以下错误:
C:\Users\Foldername\AppData\Local\Pub\Cache\bin>dart pub global run dcdg
C:\Users\Foldername\AppData\Local\Pub\Cache\bin\lib
Unhandled exception:
Bad state: Unable to find the context to C:\Users\Foldername\AppData\Local\Pub\Cache\bin\lib\.env.dart
#0 AnalysisContextCollectionImpl.contextFor (package:analyzer/src/dart/analysis/analysis_context_collection.dart:106:5)
#1 findClassElements (package:dcdg/src/find_class_elements.dart:46:39)
#2 main (file:///C:/Users/Foldername/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/dcdg-4.0.1/bin/dcdg.dart:35:25)
#3 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:32)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
Run Code Online (Sandbox Code Playgroud)
1-我已激活该软件包。
2-我已经更新到最新了。
3-环境变量设置正确。
我仍然不明白为什么它不允许我为我的代码创建类图。有人有答案吗?
我正在尝试实现一个温度滑块,它可以从负值变为正值。
我发现了许多滑块从左到右的示例,但我还没有找到从中间开始向左(负)和右(正)的滑块。
附图显示了我想要实现的目标。是否有一个小部件或库(我不确定它是否称为 Slider)可以实现所需的小部件?
dart-pub ×10
dart ×9
flutter ×9
flutter-test ×2
flutter-3.0 ×1
flutter-pub ×1
seekbar ×1
slider ×1
xcode ×1