class _MyAppState extends State<MyApp> { @override Widget build(BuildContext context) { return MaterialApp( title: 'Hive Tutorial', home: FutureBuilder( future: Hive.openBox('contacts'), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.done) { if (snapshot.hasError) return Text(snapshot.error.toString()); else return ContactPage(); } // Although opening a Box takes a very short time, // we still need to return something before the Future completes. else return Scaffold(); }, ), ); } @override void dispose() { Hive.close(); super.dispose(); } }