ensure initState is called first

This commit is contained in:
otsmr 2026-04-22 19:58:42 +02:00
parent 5722cb71bb
commit 1cee77cd97
26 changed files with 25 additions and 31 deletions

View file

@ -37,8 +37,8 @@ class _AvatarIconState extends State<AvatarIcon> {
@override @override
void initState() { void initState() {
initAsync();
super.initState(); super.initState();
initAsync();
} }
@override @override

View file

@ -28,8 +28,8 @@ class _FlameCounterWidgetState extends State<FlameCounterWidget> {
@override @override
void initState() { void initState() {
initAsync();
super.initState(); super.initState();
initAsync();
} }
@override @override

View file

@ -38,6 +38,7 @@ class _SelectChatDeletionTimeListTitleState
@override @override
void initState() { void initState() {
super.initState();
groupSub = twonlyDB.groupsDao.watchGroup(widget.groupId).listen((update) { groupSub = twonlyDB.groupsDao.watchGroup(widget.groupId).listen((update) {
if (update == null) return; if (update == null) return;
group = update; group = update;
@ -49,7 +50,6 @@ class _SelectChatDeletionTimeListTitleState
_selectedDeletionTime = selected % _getOptions().length; _selectedDeletionTime = selected % _getOptions().length;
}); });
}); });
super.initState();
} }
@override @override

View file

@ -35,6 +35,7 @@ class _VerificationBadgeCompState extends State<VerificationBadgeComp> {
@override @override
void initState() { void initState() {
super.initState();
if (widget.group != null) { if (widget.group != null) {
_streamAllVerified = twonlyDB.keyVerificationDao _streamAllVerified = twonlyDB.keyVerificationDao
.watchAllGroupMembersVerified(widget.group!.groupId) .watchAllGroupMembersVerified(widget.group!.groupId)
@ -54,8 +55,6 @@ class _VerificationBadgeCompState extends State<VerificationBadgeComp> {
}); });
}); });
} }
super.initState();
} }
@override @override

View file

@ -209,8 +209,7 @@ class MainCameraController {
await cameraController?.setFocusMode(FocusMode.auto); await cameraController?.setFocusMode(FocusMode.auto);
} catch (e) { } catch (e) {
if (e is CameraException && if (e is CameraException &&
(e.code == 'setFocusPointFailed' || (e.code == 'setFocusPointFailed' || e.code == 'setFocusModeFailed')) {
e.code == 'setFocusModeFailed')) {
Log.info('Focus point or mode not supported on this device'); Log.info('Focus point or mode not supported on this device');
} else { } else {
Log.error(e); Log.error(e);
@ -283,10 +282,8 @@ class MainCameraController {
(sensorOrientation - rotationCompensation + 360) % 360; (sensorOrientation - rotationCompensation + 360) % 360;
} }
rotation = InputImageRotationValue.fromRawValue(rotationCompensation); rotation = InputImageRotationValue.fromRawValue(rotationCompensation);
// print('rotationCompensation: $rotationCompensation');
} }
if (rotation == null) return null; if (rotation == null) return null;
// print('final rotation: $rotation');
// get image format // get image format
var format = InputImageFormatValue.fromRawValue(image.format.raw as int); var format = InputImageFormatValue.fromRawValue(image.format.raw as int);

View file

@ -23,10 +23,10 @@ class BackgroundLayer extends StatefulWidget {
class _BackgroundLayerState extends State<BackgroundLayer> { class _BackgroundLayerState extends State<BackgroundLayer> {
@override @override
void initState() { void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
widget.layerData.imageLoaded = true; widget.layerData.imageLoaded = true;
}); });
super.initState();
} }
@override @override

View file

@ -28,6 +28,7 @@ class _DrawLayerState extends State<DrawLayer> {
@override @override
void initState() { void initState() {
super.initState();
widget.layerData.control.addListener(() { widget.layerData.control.addListener(() {
if (widget.layerData.control.hasActivePath) return; if (widget.layerData.control.hasActivePath) return;
@ -40,8 +41,6 @@ class _DrawLayerState extends State<DrawLayer> {
undoList = []; undoList = [];
setState(() {}); setState(() {});
}); });
super.initState();
} }
double _sliderValue = 0.125; double _sliderValue = 0.125;

View file

@ -131,7 +131,6 @@ class _EmojiLayerState extends State<EmojiLayer> {
setState(() { setState(() {
twoPointerWhereDown = details.pointerCount >= 2; twoPointerWhereDown = details.pointerCount >= 2;
widget.layerData.size = initialScale * details.scale; widget.layerData.size = initialScale * details.scale;
// print(widget.layerData.size);
widget.layerData.rotation = widget.layerData.rotation =
initialRotation + details.rotation; initialRotation + details.rotation;

View file

@ -26,8 +26,8 @@ class _LinkPreviewLayerState extends State<LinkPreviewLayer> {
@override @override
void initState() { void initState() {
initAsync();
super.initState(); super.initState();
initAsync();
} }
Future<void> initAsync() async { Future<void> initAsync() async {

View file

@ -19,8 +19,8 @@ class _ArchivedChatsViewState extends State<ArchivedChatsView> {
@override @override
void initState() { void initState() {
initAsync();
super.initState(); super.initState();
initAsync();
} }
Future<void> initAsync() async { Future<void> initAsync() async {

View file

@ -44,11 +44,11 @@ class _ChatListViewState extends State<ChatListView> {
@override @override
void initState() { void initState() {
super.initState();
initAsync(); initAsync();
_userSub = userService.onUserUpdated.listen((_) { _userSub = userService.onUserUpdated.listen((_) {
if (mounted) setState(() {}); if (mounted) setState(() {});
}); });
super.initState();
} }
Future<void> initAsync() async { Future<void> initAsync() async {

View file

@ -26,8 +26,8 @@ class _AllReactionsViewState extends State<AllReactionsView> {
@override @override
void initState() { void initState() {
initAsync();
super.initState(); super.initState();
initAsync();
} }
@override @override

View file

@ -24,8 +24,8 @@ class _ChatGroupActionState extends State<ChatGroupAction> {
@override @override
void initState() { void initState() {
initAsync();
super.initState(); super.initState();
initAsync();
} }
Future<void> initAsync() async { Future<void> initAsync() async {

View file

@ -61,8 +61,8 @@ class _ChatListEntryState extends State<ChatListEntry> {
@override @override
void initState() { void initState() {
initAsync();
super.initState(); super.initState();
initAsync();
} }
@override @override

View file

@ -137,9 +137,9 @@ class _ResponsePreviewState extends State<ResponsePreview> {
@override @override
void initState() { void initState() {
super.initState();
_message = widget.message; _message = widget.message;
initAsync(); initAsync();
super.initState();
} }
Future<void> initAsync() async { Future<void> initAsync() async {

View file

@ -41,8 +41,8 @@ class _MessageInfoViewState extends State<MessageInfoView> {
@override @override
void initState() { void initState() {
initAsync();
super.initState(); super.initState();
initAsync();
} }
@override @override

View file

@ -39,6 +39,7 @@ class _RestoreFlameCompState extends State<RestoreFlameComp> {
@override @override
void initState() { void initState() {
super.initState();
_groupId = getUUIDforDirectChat( _groupId = getUUIDforDirectChat(
widget.contactId, widget.contactId,
userService.currentUser.userId, userService.currentUser.userId,
@ -47,7 +48,6 @@ class _RestoreFlameCompState extends State<RestoreFlameComp> {
_groupSub = stream.listen((update) { _groupSub = stream.listen((update) {
if (mounted) setState(() => _group = update); if (mounted) setState(() => _group = update);
}); });
super.initState();
} }
@override @override

View file

@ -41,6 +41,7 @@ class _ContactViewState extends State<ContactView> {
@override @override
void initState() { void initState() {
super.initState();
_contactSub = twonlyDB.contactsDao.watchContact(widget.userId).listen(( _contactSub = twonlyDB.contactsDao.watchContact(widget.userId).listen((
update, update,
) { ) {
@ -63,7 +64,6 @@ class _ContactViewState extends State<ContactView> {
_keyVerifications = update; _keyVerifications = update;
}); });
}); });
super.initState();
} }
@override @override

View file

@ -39,8 +39,8 @@ class _GroupViewState extends State<GroupView> {
@override @override
void initState() { void initState() {
initAsync();
super.initState(); super.initState();
initAsync();
} }
@override @override

View file

@ -47,9 +47,9 @@ class _RegisterViewState extends State<RegisterView> {
@override @override
void initState() { void initState() {
super.initState();
proofOfWork = widget.proofOfWork.$1; proofOfWork = widget.proofOfWork.$1;
_registrationDisabled = widget.proofOfWork.$2; _registrationDisabled = widget.proofOfWork.$2;
super.initState();
} }
Future<void> createNewUser() async { Future<void> createNewUser() async {

View file

@ -28,8 +28,8 @@ class _PublicProfileViewState extends State<PublicProfileView> {
@override @override
void initState() { void initState() {
initAsync();
super.initState(); super.initState();
initAsync();
} }
Future<void> initAsync() async { Future<void> initAsync() async {

View file

@ -26,8 +26,8 @@ class _BackupServerViewState extends State<BackupServerView> {
@override @override
void initState() { void initState() {
_urlController.text = 'https://';
super.initState(); super.initState();
_urlController.text = 'https://';
unawaited(initAsync()); unawaited(initAsync());
} }

View file

@ -33,6 +33,7 @@ class _UserDiscoveryEnabledCompState extends State<UserDiscoveryEnabledComp> {
@override @override
void initState() { void initState() {
super.initState();
_contactsGettingAnnouncedStream = twonlyDB.contactsDao _contactsGettingAnnouncedStream = twonlyDB.contactsDao
.watchContactsAnnouncedViaUserDiscovery() .watchContactsAnnouncedViaUserDiscovery()
.listen((contacts) { .listen((contacts) {
@ -41,7 +42,6 @@ class _UserDiscoveryEnabledCompState extends State<UserDiscoveryEnabledComp> {
}); });
}); });
_initAsync(); _initAsync();
super.initState();
} }
@override @override

View file

@ -22,10 +22,10 @@ class _UserDiscoverySettingsViewState extends State<UserDiscoverySettingsView> {
@override @override
void initState() { void initState() {
super.initState();
_minimumRequiredImagesExchanged = _minimumRequiredImagesExchanged =
userService.currentUser.minimumRequiredImagesExchanged; userService.currentUser.minimumRequiredImagesExchanged;
_userDiscoveryThreshold = userService.currentUser.userDiscoveryThreshold; _userDiscoveryThreshold = userService.currentUser.userDiscoveryThreshold;
super.initState();
} }
Future<void> _saveChanges() async { Future<void> _saveChanges() async {

View file

@ -31,6 +31,7 @@ class _ProfileViewState extends State<ProfileView> {
@override @override
void initState() { void initState() {
super.initState();
twonlyScoreSub = twonlyDB.groupsDao.watchSumTotalMediaCounter().listen(( twonlyScoreSub = twonlyDB.groupsDao.watchSumTotalMediaCounter().listen((
update, update,
) { ) {
@ -38,7 +39,6 @@ class _ProfileViewState extends State<ProfileView> {
twonlyScore = update; twonlyScore = update;
}); });
}); });
super.initState();
} }
@override @override

View file

@ -21,8 +21,8 @@ class MemoriesItemThumbnailComp extends StatefulWidget {
class _MemoriesItemThumbnailCompState extends State<MemoriesItemThumbnailComp> { class _MemoriesItemThumbnailCompState extends State<MemoriesItemThumbnailComp> {
@override @override
void initState() { void initState() {
initAsync();
super.initState(); super.initState();
initAsync();
} }
Future<void> initAsync() async { Future<void> initAsync() async {