Closed 1694439208 closed 2 months ago
log和你堆栈信息不吻合,log是说dispose被重复调用,感觉是你哪里状态异常了。
刚创建了一个demo测试 使用的版本是re_editor: ^0.3.1 ,一模一样的问题 ,大佬看看代码对不对
class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
int _counter = 0;
TabController? _tabController;
var tabsfile = [1, 2, 3, 4, 5, 6, 7, 8, 9];
void _incrementCounter() {
setState(() {
_tabController?.animateTo((_tabController?.index ?? 0) + 1);
});
}
@override
void initState() {
// TODO: implement initState
super.initState();
_tabController = TabController(
initialIndex: 0,
length: tabsfile.length,
vsync: this,
animationDuration: const Duration(milliseconds: 0),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: TabBarView(
controller: _tabController,
children: tabsfile
.map(
(tab) => CodeEditor(
key: GlobalKey(),
//controller: widget.data.codeController, // widget.data.codeController,
indicatorBuilder: (context, editingController, chunkController, notifier) {
return Row(
children: [
DefaultCodeLineNumber(
controller: editingController,
notifier: notifier,
),
DefaultCodeChunkIndicator(width: 20, controller: chunkController, notifier: notifier)
],
);
},
style: CodeEditorStyle(
fontFamily: "FiraCode",
fontSize: 16,
codeTheme: CodeHighlightTheme(
languages: {'python': CodeHighlightThemeMode(mode: langPython)},
theme: builtThemes["vs"]!,
),
),
),
)
.toList()),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
ok已经修复,确实是bug
如果我创建多个CodeEditor,设置到
每个都有独立的CodeLineEditingController 然后 交换value的索引位置重新刷新 会导致组件释放了但是 _IsolateTasker持有的方法引用并没有释放,
从报错的变量栈查看_isStarting 和_queues是已经调用释放了