title: The box "name" is already open and of type Box<dynamic>
body: <p>The error is The box &quot;todo_box&quot; is already open and of type Box.</p>
  <p>The relevant error-causing widget was:  MyHomePage MyHomePage:file:///D:/Flutter_app/alimi_final/lib/schedule.dart:27:13
  When the exception was thrown, this was the stack:</p>
  <p>I have no idea about this error.</p>
  <p>my code</p>
  <p>main.dart</p>
  <pre><code>import 'package:hive/hive.dart';
  import 'dart:io';
  import 'package:path_provider/path_provider.dart';
  
  import 'package:work_a/map.dart';
  import 'package:work_a/schedule.dart';
  
  import 'package:flutter/material.dart';
  import 'package:hive/hive.dart';
  import 'package:work_a/boxes.dart';
  import 'package:work_a/model/todo.dart';
  import 'package:work_a/screens/list_screen.dart';
  import 'package:hive_flutter/hive_flutter.dart';
  
  //const bool kIsWeb = identical(0, 0.0);
  
  //Future&lt;Box&gt; openHiveBox(todo_box) async {
    //if (!kIsWeb &amp;&amp; !Hive.isBoxOpen(todo_box))
      //Hive.init((await getApplicationDocumentsDirectory()).path);
  
    //return await Hive.openBox(todo_box);
  //}
  
  Future&lt;void&gt; main() async{
  
    WidgetsFlutterBinding.ensureInitialized();
    final appDocumentDirectory = await getApplicationDocumentsDirectory();
    Hive.init(appDocumentDirectory.path);
  
    await Hive.initFlutter();
    Hive.registerAdapter(TodoAdapter());
  
    await Hive.openBox('todo_box');
  
    runApp(MyApp());
  }
  
  class MyApp extends StatefulWidget {
    const MyApp({Key? key}) : super(key: key);
  
    @override
    State&lt;MyApp&gt; createState() =&gt; _alimihomeState();
  }
  
  class _alimihomeState extends State&lt;MyApp&gt; {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        title: 'allimi',
        theme: ThemeData(primaryColor: Colors.blue),
        home: MyAppBar(),
        debugShowCheckedModeBanner: false,
      );
    }
  }
  
  class MyAppBar extends StatelessWidget {
    const MyAppBar({Key? key}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text('알리미'),
          backgroundColor: Color.fromRGBO(31, 39, 76, 1.0),
          centerTitle: true,
          elevation: 0.0,
        ),
        drawer: Drawer(
          child: ListView(
            children: [
              UserAccountsDrawerHeader(
                currentAccountPicture: CircleAvatar(
                  backgroundImage: AssetImage('images/userimage.jpg'),
                ),
                accountName: Text('한동대생'),
                accountEmail: Text('00000000@handong.ac.kr'),
                decoration: BoxDecoration(
                  color: Color.fromRGBO(31, 39, 76, 1.0),
                  borderRadius: BorderRadius.only(
                    bottomLeft: Radius.circular(30.0),
                    bottomRight: Radius.circular(30.0),
                  ),
                ),
              ),
              ListTile(
                leading: Icon(
                  Icons.circle,
                  color: Colors.black,
                  size: 10.0,
                ),
                visualDensity: VisualDensity(vertical: -3),
                horizontalTitleGap: 1.0,
                title: Text('내 스케줄'),
                onTap: (){
                  Navigator.push(
                    context,
                    MaterialPageRoute(builder: (context) =&gt; schedule()),
                  );
                },
              ),
              SizedBox(
                height: 5.0,
              ),
              ListTile(
                leading: Icon(
                  Icons.circle,
                  color: Colors.black,
                  size: 10.0,
                ),
                visualDensity: VisualDensity(vertical: -3),
                horizontalTitleGap: 1.0,
                title: Text('지도 보기'),
                onTap: (){
                  Navigator.push(
                    context,
                    MaterialPageRoute(builder: (context) =&gt; MyMap()),
                  );
                },
              ),
              SizedBox(
                height: 5.0,
              ),
              ListTile(
                leading: Icon(
                  Icons.circle,
                  color: Colors.black,
                  size: 10.0,
                ),
                visualDensity: VisualDensity(vertical: -3),
                horizontalTitleGap: 1.0,
                title: Text('설정'),
                onTap: (){},
              ),
              SizedBox(
                height: 295.0,
              ),
            ],
          ),
        ),
        body: Center(
          child: Column(
            children: [
              SizedBox(
                height: 70.0,
              ),
              CircleAvatar(
                radius: 90.0,
                backgroundColor: Colors.white,
                backgroundImage: AssetImage('images/logoimage.jpg'),
              ),
              SizedBox(
                height: 30.0,
              ),
              Text(
                '한동 알리미',
                style: TextStyle(
                  fontSize: 30.0,
                  fontWeight: FontWeight.bold,
                ),
              ),
              SizedBox(
                height: 210.0,
              ),
              Text(
                'DADAEGEEDEUL',
                style: TextStyle(
                  fontSize: 10.0,
                ),
              ),
            ],
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>schedule.dart</p>
  <pre><code>import 'package:hive/hive.dart';
  import 'package:work_a/boxes.dart';
  import 'package:work_a/model/todo.dart';
  import 'package:work_a/screens/list_screen.dart';
  import 'package:hive_flutter/hive_flutter.dart';
  
  // void main() =&gt; runApp(MyApp());
  //void main() async {
    ////   hive initialization
    //await Hive.initFlutter();
    //Hive.registerAdapter(TodoAdapter());
    ////await Hive.openBox&lt;Todo&gt;(HiveBoxes.todo);
  //}
  
  class schedule extends StatelessWidget {
    const schedule({Key? key}) : super(key: key);
    static final String title = 'Hive Tutorial';
  
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
            primarySwatch: Colors.blue
        ),
        home: MyHomePage(
          title: '스케줄',
        ),
      );
    }
  }
  </code></pre>
  <p>list_screen.dart</p>
  <pre><code>import 'package:hive/hive.dart';
  import 'package:work_a/boxes.dart';
  import 'package:work_a/model/todo.dart';
  import 'package:work_a/screens/add_todo_Screen.dart';
  import 'package:hive_flutter/hive_flutter.dart';
  
  class MyApp extends StatefulWidget {
    @override
    _MyAppState createState() =&gt; _MyAppState();
  }
  
  class _MyAppState extends State&lt;MyApp&gt; {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: MyHomePage(title: 'Todo Hive Example'),
      );
    }
  }
  
  class MyHomePage extends StatefulWidget {
    MyHomePage({Key? key, required this.title}) : super(key: key);
  
    final String title;
  
    @override
    _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
  
    @override
    void dispose() async {
      Hive.close();
      super.dispose();
      //await Hive.openBox&lt;Todo&gt;(HiveBoxes.todo);
      //await Hive.openBox&lt;dynamic&gt;('todo_box');
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          backgroundColor: Color.fromRGBO(31, 39, 76, 1.0),
          title: Text(widget.title),
        ),
        body: ValueListenableBuilder(
            valueListenable: Hive.box&lt;Todo&gt;(HiveBoxes.todo).listenable(),
            builder: (context, Box&lt;Todo&gt; box, _) {
              if (box.values.isEmpty)
                return Center(
                  child: Text(&quot;리스트가 비었습니다&quot;),
                );
  
              return ListView.builder(
                itemCount: box.values.length,
                itemBuilder: (context, index) {
                  Todo? res = box.getAt(index);
                  return Dismissible(
                    background: Container(color: Colors.red),
                    key: UniqueKey(),
                    onDismissed: (direction) {
                      res!.delete();
                    },
                    child: ListTile(
                        title: Text(res!.title),
                        subtitle: Text(res.description),
                        onTap: () {}),
                  );
                },
              );
            }),
        floatingActionButton: FloatingActionButton(
          tooltip: 'Add todo',
          child: Icon(Icons.add),
          backgroundColor: Color.fromRGBO(31, 39, 76, 1.0),
          onPressed: () =&gt; Navigator.of(context).push(
            MaterialPageRoute(
              builder: (context) =&gt; AddTodoScreen(),
            ),
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>add_todo_screen.dart</p>
  <pre><code>import 'package:hive/hive.dart';
  import 'package:work_a/boxes.dart';
  import 'package:work_a/model/todo.dart';
  
  class AddTodoScreen extends StatefulWidget {
    AddTodoScreen({Key? key}) : super(key: key);
  
    @override
    _AddTodoScreenState createState() =&gt; _AddTodoScreenState();
  }
  
  class _AddTodoScreenState extends State&lt;AddTodoScreen&gt; {
    //void main() async {
    //  await Hive.openBox&lt;Todo&gt;(HiveBoxes.todo);
    //}
    final GlobalKey&lt;FormState&gt; _formKey = GlobalKey&lt;FormState&gt;();
    late String title;
    late String description;
    validated() {
      if (_formKey.currentState != null &amp;&amp; _formKey.currentState!.validate()) {
        _onFormSubmit();
        print(&quot;Form Validated&quot;);
      } else {
        print(&quot;Form Not Validated&quot;);
        return;
      }
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          backgroundColor: Color.fromRGBO(31, 39, 76, 1.0),
          title: Text('스케줄 추가'),
        ),
        body: SafeArea(
          child: Form(
            key: _formKey,
            child: Padding(
              padding: EdgeInsets.all(8.0),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  TextFormField(
                    autofocus: true,
                    initialValue: '',
                    decoration: InputDecoration(
                        labelText: '스케줄'
                    ),
                    onChanged: (value) {
                      setState(() {
                        title = value;
                      });
                    },
                    validator: (String? value) {
                      if (value == null || value.trim().length == 0) {
                        return &quot;required&quot;;
                      }
                      return null;
                    },
                  ),
                  TextFormField(
                    initialValue: '',
                    decoration: const InputDecoration(
                      labelText: '메모',
                    ),
                    onChanged: (value) {
                      setState(() {
                        description = value;
                      });
                    },
                    validator: (String? value) {
                      if (value == null || value.trim().length == 0) {
                        return &quot;required&quot;;
                      }
                      return null;
                    },
                  ),
                  ElevatedButton(
                    style: ElevatedButton.styleFrom(
                      primary:Color.fromRGBO(31, 39, 76, 1.0),
                    ),
                    onPressed: () {
                      validated();
                    },
                    child: Text('추가'),
                  )
                ],
              ),
            ),
          ),
        ),
      );
    }
  
    void _onFormSubmit() {
      Box&lt;Todo&gt; contactsBox = Hive.box&lt;Todo&gt;(HiveBoxes.todo);
      contactsBox.add(Todo(title: title, description: description));
      Navigator.of(context).pop();
    }
  }
  </code></pre>
  <p>ui_test.dart</p>
  <pre><code>import 'package:work_a/screens/add_todo_Screen.dart';
  
  class MyApp extends StatefulWidget {
    @override
    _MyAppState createState() =&gt; _MyAppState();
  }
  
  class _MyAppState extends State&lt;MyApp&gt; {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: MyHomePage(title: 'Todo Hive Example'),
      );
    }
  }
  
  class MyHomePage extends StatefulWidget {
    MyHomePage({Key? key, required this.title}) : super(key: key);
  
    final String title;
  
    @override
    _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          backgroundColor: Color.fromRGBO(31, 39, 76, 1.0),
          centerTitle: true,
          title: Text(widget.title),
        ),
        body: Container(
          child: ListView.builder(
            itemBuilder: (context, index) {
              return Dismissible(
                background: Container(color: Colors.red),
                key: UniqueKey(),
                onDismissed: (direction) {},
                child: ListTile(
                    title: Text('Title'),
                    subtitle: Text('Description'),
                    onTap: () {}),
              );
            },
          ),
        ),
        floatingActionButton: FloatingActionButton(
          tooltip: 'Add todo',
          child: Icon(Icons.add),
          onPressed: () =&gt; Navigator.of(context).push(
            MaterialPageRoute(
              builder: (context) =&gt; AddTodoScreen(),
            ),
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>boxs.dart</p>
  <pre><code>class HiveBoxes {
    static String todo = 'todo_box';
  } 
  </code></pre>
  <p>todo.dart</p>
  <pre><code>import 'package:hive/hive.dart';
  part 'todo.g.dart';
  
  @HiveType(typeId: 0)
  class Todo extends HiveObject {
    @HiveField(0)
    String? id;
  
    @HiveField(1)
    String title;
  
    @HiveField(2)
    String description;
  
    Todo({required this.title, required this.description});
  }
  </code></pre>
  <p>and</p>
  <p>todo.g.dart</p>