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(); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter