Skip to content

Instantly share code, notes, and snippets.

@giuliano-macedo
Last active December 29, 2021 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giuliano-macedo/21c41c8b6bab7a9c8815c34501d42b34 to your computer and use it in GitHub Desktop.
Save giuliano-macedo/21c41c8b6bab7a9c8815c34501d42b34 to your computer and use it in GitHub Desktop.
Flutter TabController with onChange callback
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