Hive: The method 'initFlutter' isn't defined for the class 'HiveInterface'

Created on 24 Feb 2020  路  6Comments  路  Source: hivedb/hive

Hi,

iam trying to init Hive in Main Function with Hive.initFlutter(); as described in your documents. Unfortunately my VS Code shows "The method 'initFlutter' isn't defined for the class 'HiveInterface'."

Maybe i missed a additional step to make it work.

  • Platform: Android, Windows
  • Flutter version: 1.14.6
    hive: ^1.4.1
    hive_flutter: ^0.3.0+2
    dev_dependencies:
    hive_generator: ^0.7.0+2
    build_runner: ^1.7.4
question

Most helpful comment

Hi @Rayv1 ,
have you tried to import package:hive_flutter/hive_flutter.dart?

All 6 comments

Hi @Rayv1 ,
have you tried to import package:hive_flutter/hive_flutter.dart?

yep, just forgot to import the second package

i am getting the same issue, I have imported the hive_flutter package.

hive: ^1.4.1+1
hive_flutter: ^0.3.0+2

You need to import both hive and hive_flutter.

Just add import 'package:hive_flutter/hive_flutter.dart';

Little explanation: initFlutter() is extension and Android Studio currently doesn't support importing extensions for Dart, that's why we have to setup import manually

IDE issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yaymalaga picture yaymalaga  路  4Comments

kthecoder picture kthecoder  路  3Comments

yannickvg picture yannickvg  路  4Comments

rupamking1 picture rupamking1  路  3Comments

MyoLinOo picture MyoLinOo  路  3Comments