Last active
December 29, 2021 11:22
-
-
Save giuliano-macedo/21c41c8b6bab7a9c8815c34501d42b34 to your computer and use it in GitHub Desktop.
Flutter TabController with onChange callback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class TabControllerWithOnChange extends TabController { | |
TabControllerWithOnChange({ | |
int initialIndex = 0, | |
required int length, | |
required TickerProvider vsync, | |
required void Function(int) onChange, | |
}) : super(initialIndex: initialIndex, length: length, vsync: vsync) { | |
addListener(() { | |
if (!indexIsChanging) { | |
return; | |
} | |
onChange(index); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment