小编Den*_*ski的帖子

结合冷冻和蜂巢

我正在寻找一种结合冷冻蜂巢包装的解决方案。例如像这样:

@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。但我希望有更好的解决方案。

dart flutter flutter-hive

11
推荐指数
1
解决办法
1280
查看次数

底部导航栏,每个选项卡都有子导航器

我想在我的应用程序中有一个底部导航栏,其行为如下:

  1. 每个选项卡都应该有自己的嵌套导航器,这样我就可以在保留底部导航栏的同时切换到子路由
  2. 切换到另一个选项卡时,我希望能够使用后退按钮返回上一个选项卡
  3. 当我再次点击选项卡 1 时,我不想再次实例化子路由,但我想回到它的最后状态 .. 例如,如果我在路由 '/tab1/subRoute1' 我想登陆这个视图再次

我能够实现 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)

flutter

1
推荐指数
1
解决办法
3913
查看次数

标签 统计

flutter ×2

dart ×1

flutter-hive ×1