title: Bool with json in flutter
body: <p>Hello I am trying to put the variable 'select' to fetch the bool value from a Json file I am not able to do anyone can help me (there is no code all I can get text but I can’t get bool). Thank you.</p>
  
  <pre><code>final _toDoController = TextEditingController();
    Map&lt;String, dynamic&gt; _toDoList = Map(); //change this.
    void initState() {
      super.initState();
      _readData().then((data) {
        setState(() {
          _toDoList = json.decode(data);
        });
      });
    }
    void _addToDo() {
      setState(() {
        Map&lt;String, dynamic&gt; newToDo = Map();
        newToDo['verificar'] = true;
        _toDoList.addAll(newToDo);
        _saveData();
      });
    }
    Widget build(BuildContext context) {
      bool selected = _toDoList['verificar'];
      return Scaffold(
  ...
        ),
        body: Container(
  color: selected ? Colors.green.withOpacity(0.90) : Colors.deepOrangeAccent.withOpacity(0.90),
  ...
  ),
      );
    }
    Future&lt;File&gt; _getFile() async {
      final directory = await getApplicationDocumentsDirectory();
      return File("${directory.path}/data.json");
    }
    Future&lt;File&gt; _saveData() async {
      String data = json.encode(_toDoList);
  
      final file = await _getFile();
      return file.writeAsString(data);
    }
    Future&lt;String&gt; _readData() async {
      try {
        final file = await _getFile();
  
        return file.readAsString();
      } catch (e) {
        return null;
      }}}
  </code></pre>