Я новичок во Flutter и во всей мобильной разработке, но у меня большой опыт веб-разработки.
Я пытаюсь создать приложение Flutter, которое будет использовать Firestore в качестве бэкэнд-сервиса.
Моя цель - сохранить некоторые данные в новом документе по нажатию кнопки.
Вот код моей кнопки:
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