сообщение об ошибке после использования плагина notifier 1.0.2 во флаттере - PullRequest
1 голос
/ 05 февраля 2020

Я искал альтернативу для Broadcast receiver во флаттере, после чего я добавил плагин notifier 1.0.2 после добавления к своему pubspec.yaml, получая сообщение об ошибке вроде

Because every version of notifier depends on synchronized ^1.5.3+2 and sqflite 1.2.0 depends on synchronized >=2.0.2 <4.0.0, notifier is incompatible with sqflite 1.2.0.

So, because Bluis depends on both sqflite 1.2.0 and notifier 1.0.2, version solving failed.
pub get failed (1; So, because Bluis depends on both sqflite 1.2.0 and notifier 1.0.2, version solving failed.)
Process finished with exit code 1

вот мой pubspe c .yaml

name: Bluis
description: A new Flutter project.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.2.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  rxdart: ^0.22.3
  http: ^0.12.0+1
  toast: ^0.1.5
  sqflite: 1.2.0
  intl: ^0.16.0
  geolocator: ^5.1.4+2
  flutter_compass: ^0.3.4
  url_launcher: ^5.2.5
  permission_handler: ^4.0.0
  camera: ^0.5.2+1
  video_player: ^0.10.0
  path_provider: ^1.1.0
  path: ^1.6.2
  e2e: ^0.2.0
  esys_flutter_share: ^1.0.2
  shared_preferences: ^0.5.4+5
  connectivity: ^0.4.5+3
  uuid: ^2.0.4
  logger: ^0.6.0
  event_bus: ^1.1.0
  location: ^2.3.4
  dio: ^3.0.8
  recase: ^3.0.0
  flutter_map:
    git:
      url: git://github.com/okaxaki/flutter_map.git
      ref: fix/support-flutter-1.10



dev_dependencies:
  flutter_test:
    sdk: flutter
  notifier: 1.0.2

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/images/
    - assets/locale/localization_en.json
    - assets/locale/localization_hi.json
    - assets/locale/localization_or.json

1 Ответ

0 голосов
/ 27 февраля 2020

Я решил свою задачу, используя шину событий

  1. Создание шины событий EventBus eventBus = EventBus();

  2. Определить события (Создать класс с именем события с помощью конструктора) class UserLoggedInEvent { User user; UserLoggedInEvent(this.user); }

  3. Регистрация слушателей (слушайте ваши события) eventBus.on<UserLoggedInEvent>().listen((event) { // All events are of type UserLoggedInEvent (or subtypes of it). print(event.user); });

  4. Проведите ваше мероприятие User myUser = User('Mickey'); eventBus.fire(UserLoggedInEvent(myUser));

  5. отменить все события eventBus.cancel();

...