I am using DefaultTabController for 3 TabBars. But i need to use only one page to be shown fetching the data from database all three TabBars are the same, But only the fetched data is different according to the index of its tap. How could i do so without create 3 copies of the same object WidgetOfTape
?
the code is:
DefaultTabController(
length: 3,
child: Scaffold(
body: const TabBarView(
children: [
WidgetOfTape(),
WidgetOfTape(),
WidgetOfTape(),
],
),
WidgetOfTape code is:
class WidgetOfTape extends HookWidget {
const WidgetOfTape ();
@override
Widget build(BuildContext context) {
return BlocSelector<ScheduledPossibleDayCubit, ScheduledPossibleDayState,
int>(selector: (state) {
return state.indexOfTap;
}, builder: (context, state) {
return BlocProvider<DisplayNoteInsidePagesCubit>(
lazy: false,
create: (context) => getIt<DisplayNoteInsidePagesCubit>()
..countDoneNoteOutOfAllNotes()
..retrieveData(indexOfTap: state),
child: Column(children: [
Expanded(child: BlocBuilder<DisplayNoteInsidePagesCubit,
DisplayNoteInsidePagesState>(
builder: (context, state) {
return ListView.builder(
shrinkWrap: true,
itemCount: state.notes.length,
itemBuilder: (BuildContext context, int index) {
return Row(
children: [
Expanded(
child: Text(
state.notes[index]['content'],
textAlign: TextAlign.justify,
style: Theme.of(context).textTheme.bodyText2,
),
),
],
);
});
},
))
]));
});
}
}