handleFileInit method
dynamic
handleFileInit()
Implementation
handleFileInit() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String fileContent = widget.defaultValue;
EditorRegionOptions? region = widget.options.regionOptions;
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
handleRegionFields();
if (region != null) {
int regionStart = region.start!;
if (prefs.get(widget.path) != null) {
regionStart = int.parse(
prefs.getString(widget.path)?.split(':')[0] ?? '',
);
}
if (fileContent.split('\n').length > 7) {
Future.delayed(const Duration(milliseconds: 250), () {
if (!mounted) return;
double offset = fileContent
.split('\n')
.sublist(0, regionStart - 1 < 0 ? 0 : regionStart - 1)
.length *
getTextHeight(context);
scrollController.animateTo(
offset,
duration: const Duration(milliseconds: 500),
curve: Curves.easeInOut,
);
});
}
}
if (scrollController.hasClients && linebarController.hasClients) {
linebarController.jumpTo(0);
scrollController.jumpTo(0);
}
isLoading = false;
});
TextEditingControllerIDE.language = widget.defaultLanguage;
}