diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..0d29021 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/lib/Components/translation_input_and_resource_container.dart b/lib/Components/translation_input_and_resource_container.dart index f09e3fe..a07a797 100644 --- a/lib/Components/translation_input_and_resource_container.dart +++ b/lib/Components/translation_input_and_resource_container.dart @@ -13,13 +13,25 @@ class _TranslationInputAndResourceContainerState extends State? currentLanguage; + bool isInit = false; @override void initState() { super.initState(); _tabController = new TabController(length: widget.newValues.length, vsync: this); currentLanguage = ValueNotifier(widget.newValues.first.language!); - controllerQuill.insertText(widget.newValues[_tabController!.index].value!); + + controllerQuill.onEditorLoaded(() { + print("onEditorLoaded"); + isInit = true; + }); + + Future.delayed(Duration(milliseconds: 500), () { + print("Future.delayed"); + controllerQuill.clear(); + controllerQuill.insertText(widget.newValues[_tabController!.index].value!); + isInit = true; + }); controllerQuill.onTextChanged((p0) async { var plainText = await controllerQuill.getPlainText(); @@ -41,6 +53,8 @@ class _TranslationInputAndResourceContainerState extends State debugPrint('has focus $hasFocus'), //onTextChanged: (text) => debugPrint('widget text change $text'), onTextChanged: (value) { - newValues.where((element) => element.language! == currentLanguage.value).first.value = value; + if(isInit) { + newValues.where((element) => element.language! == currentLanguage.value).first.value = value; + } }, onEditorCreated: () => debugPrint('Editor has been loaded'), onEditorResized: (height) => diff --git a/lib/Components/translation_input_container.dart b/lib/Components/translation_input_container.dart index 539e4a9..bcbcf3e 100644 --- a/lib/Components/translation_input_container.dart +++ b/lib/Components/translation_input_container.dart @@ -12,13 +12,25 @@ class _TranslationInputContainerState extends State w TabController? _tabController; QuillEditorController controllerQuill = QuillEditorController(); ValueNotifier? currentLanguage; + bool isInit = false; @override void initState() { super.initState(); _tabController = new TabController(length: widget.newValues.length, vsync: this); currentLanguage = ValueNotifier(widget.newValues.first.language!); - controllerQuill.insertText(widget.newValues[_tabController!.index].value!); + + controllerQuill.onEditorLoaded(() { + print("onEditorLoaded"); + isInit = true; + }); + + Future.delayed(Duration(milliseconds: 500), () { + print("Future.delayed"); + controllerQuill.clear(); + controllerQuill.insertText(widget.newValues[_tabController!.index].value!); + isInit = true; + }); controllerQuill.onTextChanged((p0) async { var plainText = await controllerQuill.getPlainText(); @@ -40,6 +52,8 @@ class _TranslationInputContainerState extends State w setState(() { currentLanguage!.value = widget.newValues[_tabController!.index].language; if(!widget.isAudio) { + print("insert try without ress"); + print(widget.newValues[_tabController!.index].value!); controllerQuill.clear(); controllerQuill.insertText(widget.newValues[_tabController!.index].value!); } @@ -82,7 +96,7 @@ class _TranslationInputContainerState extends State w child: Container( height: widget.isTitle ? MediaQuery.of(context).size.height *0.13 : MediaQuery.of(context).size.height *0.35, child: QuillHtmlEditor( - text: newValues.where((element) => element.language! == currentLanguage.value).first.value!, + //text: newValues.where((element) => element.language! == currentLanguage.value).first.value!, hintText: '', controller: controllerQuill, minHeight: widget.isTitle ? 80 : 240, @@ -97,7 +111,9 @@ class _TranslationInputContainerState extends State w //onFocusChanged: (hasFocus) => debugPrint('has focus $hasFocus'), //onTextChanged: (text) => debugPrint('widget text change $text'), onTextChanged: (value) { - newValues.where((element) => element.language! == currentLanguage.value).first.value = value; + if(isInit) { + newValues.where((element) => element.language! == currentLanguage.value).first.value = value; + } }, onEditorCreated: () => debugPrint('Editor has been loaded'), onEditorResized: (height) =>