@freezed
abstract class Person extends HiveObject with _$Person {
@HiveType(typeId: 0)
factory Person({@HiveField(0) String name, @HiveField(1) int age}) = _Person;
}
Run Code Online (Sandbox Code Playgroud)
我知道这是不可能的,但我想你知道我想要实现什么。用蜂巢冻结的最佳方法是什么?
我目前能想到的唯一解决方案是存储在 hive 中冻结生成的 json-String。但我希望有更好的解决方案。
我想在我的应用程序中有一个底部导航栏,其行为如下:
我能够实现 1 和 2,但我坚持第 3 点。这是我的构造:
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Bottom NavBar Demo',
home: BottomNavigationBarController(),
);
}
}
class BottomNavigationBarController extends StatefulWidget {
BottomNavigationBarController({Key key}) : super(key: key);
@override
_BottomNavigationBarControllerState createState() =>
_BottomNavigationBarControllerState();
}
class _BottomNavigationBarControllerState
extends State<BottomNavigationBarController> {
int _selectedIndex = 0;
List<int> _history = [0];
GlobalKey<NavigatorState> _navigatorKey = GlobalKey<NavigatorState>();
final List<BottomNavigationBarRootItem> bottomNavigationBarRootItems = [
BottomNavigationBarRootItem( …Run Code Online (Sandbox Code Playgroud)