'When I Navigate through Nav Bar sometimes the page is all White

When I Navigate through Nav Bar sometimes the page is Blank, i'm using Persistent bottom nav bar v2 as plugin, i don't know if it's a bug of the plugin but basically you can navigate through 3 pages, when you click on the Bottom Nav Bar: Diary of my app, and then you click on a bottom that redirects to another page ( using Navigator.push ) that page will return a ListTile . If you click on another bottom of nav bar and back to Diary, it's all white! That's just sometimes that it happens, but happens. i don't know if it's a Route Problem or idk. the code is:

import 'dart:async';
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:mood3/telas/RecebeDados.dart';
import 'package:mood3/telas/escrita.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:path_provider/path_provider.dart';
import'dart:io';

class Diary extends StatefulWidget {


List teste;
Diary({this.teste = const []});


  @override
  State<Diary> createState() => _DiaryState();
}

class _DiaryState extends State<Diary> {



  Future<File>_getFile()async{
    final diretorio = await getApplicationDocumentsDirectory();
    return File("${diretorio.path}/dados.json");
  }


  _ler() async {

    try{
      final arquivo = await _getFile();
      return arquivo.readAsString();
    }catch(e){
      return null;
    }
  }



  @override
  void initState() {
    super.initState();
    _ler().then((dados){
      setState(() {
        widget.teste = json.decode(dados);
      });
    });
  }






  @override
  Widget build(BuildContext context) {

;



    Escrita teste7 = Escrita(lista2: widget.teste);
    widget.teste = teste7.lista2;

    print(widget.teste);

    return Scaffold(
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [

          GestureDetector(
            onTap: (){
              Navigator.push(context,MaterialPageRoute(builder: (context) => RecebeDados(teste7.lista2)));
            }, child:
          Container(
              padding: EdgeInsets.only(bottom: 3),
              height: 230,
              decoration: BoxDecoration(
                color: Colors.black54,
              ),
              child: Image.asset("icones/personal.png")
          ),),
          GestureDetector(
            onTap: (){
              Navigator.push(context,MaterialPageRoute(builder: (context) => RecebeDados(teste7.lista2)));
            }, child:
          Container(
            height: 230,
            color: Colors.black54,
            child: Image.asset("icones/read.png"),
          ),),
        ]
    ));
  }
}




Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source