From c14321a694fc4c0099611243069f6a171dcf173d Mon Sep 17 00:00:00 2001 From: dhzdhd Date: Fri, 26 Aug 2022 13:39:15 +0530 Subject: [PATCH] Fix null error when switching languages --- lib/src/home/providers/editor_provider.dart | 2 +- lib/src/home/widgets/app_bar.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/home/providers/editor_provider.dart b/lib/src/home/providers/editor_provider.dart index 38c858e..f840a16 100644 --- a/lib/src/home/providers/editor_provider.dart +++ b/lib/src/home/providers/editor_provider.dart @@ -1,6 +1,6 @@ import 'package:excode/src/factory.dart'; import 'package:excode/src/home/services/language.dart'; -import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; final editorLanguageStateProvider = diff --git a/lib/src/home/widgets/app_bar.dart b/lib/src/home/widgets/app_bar.dart index 79857a2..b28aa4c 100644 --- a/lib/src/home/widgets/app_bar.dart +++ b/lib/src/home/widgets/app_bar.dart @@ -33,9 +33,9 @@ class AppBarWidget extends HookConsumerWidget with PreferredSizeWidget { onChanged: (val) { String lang = ApiHandler.getNameFromLang(val!); ref.watch(editorLanguageStateProvider.notifier).setLanguage(lang); - ref - .watch(editorContentStateProvider.notifier) - .setContent(box.get('${lang}code')); // ! Move to provider + ref.watch(editorContentStateProvider.notifier).setContent( + box.get('${lang}code') ?? + langMap[lang]!.baseCode); // ! Move to provider }, ), automaticallyImplyLeading: false,