无法通过软件包sembast 2.0.1 + 2创建数据库(flutter web)

时间:2019-09-17 15:43:03

标签: flutter dart

代码: 我无法在网络中创建数据库

  var dbPath = p.current;
  var dir = await Directory(dbPath).create(recursive: true);
  var pa = p.join(dir.path, 'my_database.db');
  DatabaseFactory dbFactory = databaseFactoryIo;
  Database db = await dbFactory.openDatabase(pa);
  var store = StoreRef.main();
  await store.record('title').put(db, 'Simple application');
  var title = await store.record('title').get(db) as String;

错误:

扑灭报告;请在https://github.com/flutter/flutter/issues提交。

命令

flutter运行--machine --target lib \ main.dart -d chrome --track-widget-creation --start-paused

例外

NoSuchMethodError:NoSuchMethodError:方法“ toJson”在null上调用。 接收者:null 尝试调用:toJson()

#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      SourceLocation.toJson (package:vm_service/vm_service.dart:5024:24)
#2      Frame.toJson (package:vm_service/vm_service.dart:3296:47)
#3      Event.toJson (package:vm_service/vm_service.dart:3022:47)
#4      VmServerConnection._delegateRequest.<anonymous closure> (package:vm_service/vm_service.dart:1141:28)
#5      _rootRunUnary (dart:async/zone.dart:1132:38)
#6      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#7      _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
#8      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)
#9      _DelayedData.perform (dart:async/stream_impl.dart:591:14)
#10     _StreamImplEvents.handleNext (dart:async/stream_impl.dart:707:11)
#11     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:667:7)
#12     _rootRun (dart:async/zone.dart:1120:38)
#13     _CustomZone.run (dart:async/zone.dart:1021:19)
#14     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#15     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#16     _rootRun (dart:async/zone.dart:1124:13)
#17     _CustomZone.run (dart:async/zone.dart:1021:19)
#18     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#19     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#20     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#21     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#22     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:116:13)
#23     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:173:5)

颤抖的医生

[✓] Flutter (Channel unknown, v1.10.2-pre.40, on Microsoft Windows [Version 10.0.17134.1006], locale en-US)
    • Flutter version 1.10.2-pre.40 at C:\flutter\flutter
    • Framework revision b4ab5cfe79 (22 hours ago), 2019-09-16 20:34:25 -0700
    • Engine revision 7ea9884ab0
    • Dart version 2.5.0 (build 2.5.0-dev.4.0 be66176534)

[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:\flutter\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = C:\flutter\sdk
    • Java binary at: C:\flutter\android-studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b01)
    ✗ Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed instructions.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[✓] Android Studio (version 3.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 34.0.1
    • Dart plugin version 182.5215
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[✓] Android Studio (version 3.5)
    • Android Studio at C:\flutter\android-studio
    • Flutter plugin version 34.0.4
    • Dart plugin version 191.6183.88
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b01)

[✓] VS Code (version 1.38.1)
    • VS Code at C:\Users\Mahmoud salah eldin\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.4.1

[✓] Connected device (2 available)
    • Chrome • chrome • web-javascript • Google Chrome 76.0.3809.132
    • Server • web    • web-javascript • Flutter Tools

! Doctor found issues in 1 category.

1 个答案:

答案 0 :(得分:1)

您不能在flutter_web中使用'Beverage'中的任何一个。 Sembast基于for i, v in drinks2['Beverage'].iteritems(): if v in drinks['Beverage']: print(v) ,因此不会在flutter_web中工作(除非您在内存中使用它)。 Indexed DB是一种解决方案。