Decrease app boot time

We don't need to wait for all the futures, and some can be re-used.
This commit is contained in:
Vishesh Handa
2019-06-02 17:29:50 +02:00
parent e389829e2c
commit fb2cbbf3ce
2 changed files with 4 additions and 5 deletions

View File

@ -45,13 +45,13 @@ class JournalApp extends StatelessWidget {
localGitRepoConfigured = true;
await pref.setBool("localGitRepoConfigured", localGitRepoConfigured);
await pref.setString("localGitRepoPath", localGitRepoPath);
pref.setBool("localGitRepoConfigured", localGitRepoConfigured);
pref.setString("localGitRepoPath", localGitRepoPath);
}
var dir = await getGitBaseDirectory();
await Settings.instance.load();
Settings.instance.load(pref);
runApp(StateContainer(
localGitRepoConfigured: localGitRepoConfigured,

View File

@ -7,8 +7,7 @@ class Settings {
Settings._internal();
static Settings get instance => _singleton;
Future load() async {
var pref = await SharedPreferences.getInstance();
void load(SharedPreferences pref) {
gitAuthor = pref.getString("gitAuthor") ?? gitAuthor;
gitAuthorEmail = pref.getString("gitAuthorEmail") ?? gitAuthorEmail;
}