Flutter Firestore不会正确添加新文档

时间:2019-05-13 18:50:34

标签: flutter google-cloud-firestore

我是Flutter和整个移动开发的新手,但是我在Web开发方面拥有丰富的经验。

我正在尝试创建一个将Firestore用作后端服务的Flutter应用程序。

我的目标是在单击按钮时将一些数据存储到新文档中。

这是我的按钮的代码:

Padding(
          padding: const EdgeInsets.all(8.0),
          child: RaisedButton(
            onPressed: () async {
              Map data = {
                "createdAt": new Timestamp.now(),
                "createdBy": 'users/rucFpMF6OXawxUlbJ7Oj',
                "address": address,
              };
              var _result = await reference.add(data);
            },
            color: Colors.black54,
            splashColor: Colors.red,
            child: Text(
              "DO something",
              style: TextStyle(color: Colors.white),
            ),
          ),
        ),

数据正确,调用了函数并触发了代码,但未保存文档。

这是单击按钮后调试控制台的输出。

Launching lib/main.dart on VTR L29 in debug mode...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Built build/app/outputs/apk/debug/app-debug.apk.
D/AwareBitmapCacher(25362): handleInit switch not opened pid=25362
I/ViewRootImpl(25362): jank_removeInvalidNode all the node in jank list is out of time
I/t.easytaxi_use(25362): Starting profile saver IsSaveProfileNow end.
D/ZrHung.AppEyeUiProbe(25362): stop checker.
W/libEGL  (25362): EGLNativeWindowType 0x7802029010 disconnect failed
D/ViewRootImpl[MainActivity](25362): surface should not be released
W/libEGL  (25362): EGLNativeWindowType 0x7802028010 disconnect failed
D/ZrHung.AppEyeUiProbe(25362): Current Activity:false
D/ZrHung.AppEyeUiProbe(25362): not watching, wait.
D/ZrHung.AppEyeUiProbe(25362): notify runnable to start.
D/ZrHung.AppEyeUiProbe(25362): restart watching
D/mali_winsys(25362): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/mali_winsys(25362): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
E/BpSurfaceComposerClient(25362): Failed to transact (-1)
E/BpSurfaceComposerClient(25362): Failed to transact (-1)
W/InputMethodManager(25362): startInputReason = 1
E/        (25362): [ZeroHung]zrhung_get_config: Get config failed for wp[0x0008]
V/AudioManager(25362): playSoundEffect   effectType: 0
V/AudioManager(25362): querySoundEffectsEnabled...
I/flutter (25362): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter (25362): The following assertion was thrown while handling a gesture:
I/flutter (25362): type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>'
I/flutter (25362):
I/flutter (25362): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (25362): more information in this error message to help you determine and fix the underlying cause.
I/flutter (25362): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (25362):   https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter (25362):
I/flutter (25362): When the exception was thrown, this was the stack:
I/flutter (25362): #0      _MyHomePageState.build.<anonymous closure> (package:easytaxi_user/main.dart:129:39)
I/flutter (25362): #1      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:511:14)
I/flutter (25362): #2      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:566:30)
I/flutter (25362): #3      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:166:24)
I/flutter (25362): #4      TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:240:9)
I/flutter (25362): #5      TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:177:9)
I/flutter (25362): #6      PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:435:9)
I/flutter (25362): #7      PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
I/flutter (25362): #8      PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:100:11)
I/flutter (25362): #9      _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
I/flutter (25362): #10     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
I/flutter (25362): #11     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
I/flutter (25362): #12     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
I/flutter (25362): #13     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
I/flutter (25362): #17     _invoke1 (dart:ui/hooks.dart:234:10)
I/flutter (25362): #18     _dispatchPointerDataPacket (dart:ui/hooks.dart:154:5)
I/flutter (25362): (elided 3 frames from package dart:async)
I/flutter (25362):
I/flutter (25362): Handler: "onTap"
I/flutter (25362): Recognizer:
I/flutter (25362):   TapGestureRecognizer#af5c7
I/flutter (25362): ════════════════════════════════════════════════════════════════════════════════════════════════════
V/AudioManager(25362): playSoundEffect   effectType: 0
V/AudioManager(25362): querySoundEffectsEnabled...
I/flutter (25362): Another exception was thrown: type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>'

我在项目根目录中也有build.yaml,内容如下:

targets:
  $default:
    builders:
      json_serializable:
        options:
          any_map: true

0 个答案:

没有答案