Skip to content

Commit

Permalink
Fix null error when switching languages
Browse files Browse the repository at this point in the history
  • Loading branch information
dhzdhd committed Aug 26, 2022
1 parent ad1be15 commit c14321a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/src/home/providers/editor_provider.dart
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down
6 changes: 3 additions & 3 deletions lib/src/home/widgets/app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c14321a

Please sign in to comment.