@@ -85,6 +85,8 @@ class InnerInfiniteScrollTabViewState extends State<InnerInfiniteScrollTabView>
85
85
final List <Tween <double >> _tabSizeTweens = [];
86
86
List <Tween <double >> get tabSizeTweens => _tabSizeTweens;
87
87
88
+ double get indicatorWidth => widget.separator? .width ?? 2.0 ;
89
+
88
90
late final _indicatorAnimationController =
89
91
AnimationController (vsync: this , duration: _tabAnimationDuration)
90
92
..addListener (() {
@@ -259,53 +261,54 @@ class InnerInfiniteScrollTabViewState extends State<InnerInfiniteScrollTabView>
259
261
Widget build (BuildContext context) {
260
262
return Column (
261
263
children: [
262
- SizedBox (
263
- height: widget.tabHeight,
264
- child: CycledListView .builder (
265
- scrollDirection: Axis .horizontal,
266
- controller: _tabController,
267
- contentCount: widget.contentLength,
268
- itemBuilder: (context, modIndex, rawIndex) {
269
- return Material (
270
- color: widget.backgroundColor,
271
- child: InkWell (
272
- onTap: () => _onTapTab (modIndex, rawIndex),
273
- child: ValueListenableBuilder <int >(
274
- valueListenable: _selectedIndex,
275
- builder: (context, index, _) =>
276
- ValueListenableBuilder <bool >(
277
- valueListenable: _isTabPositionAligned,
278
- builder: (context, tab, _) => _TabContent (
279
- isTabPositionAligned: tab,
280
- selectedIndex: index,
281
- indicatorColor: widget.indicatorColor,
282
- tabPadding: widget.tabPadding,
283
- modIndex: modIndex,
284
- tabBuilder: widget.tabBuilder,
285
- ),
286
- ),
287
- ),
288
- ),
289
- );
290
- },
291
- ),
292
- ),
293
264
Stack (
294
265
children: [
295
- if (widget.separator != null )
296
- Container (
297
- width: widget.size.width,
298
- decoration: BoxDecoration (
299
- border: Border (bottom: widget.separator! ),
300
- ),
266
+ SizedBox (
267
+ height: widget.tabHeight + (widget.separator? .width ?? 0 ),
268
+ child: CycledListView .builder (
269
+ scrollDirection: Axis .horizontal,
270
+ controller: _tabController,
271
+ contentCount: widget.contentLength,
272
+ itemBuilder: (context, modIndex, rawIndex) {
273
+ return Material (
274
+ color: widget.backgroundColor,
275
+ child: InkWell (
276
+ onTap: () => _onTapTab (modIndex, rawIndex),
277
+ child: ValueListenableBuilder <int >(
278
+ valueListenable: _selectedIndex,
279
+ builder: (context, index, _) =>
280
+ ValueListenableBuilder <bool >(
281
+ valueListenable: _isTabPositionAligned,
282
+ builder: (context, tab, _) => _TabContent (
283
+ isTabPositionAligned: tab,
284
+ selectedIndex: index,
285
+ indicatorColor: widget.indicatorColor,
286
+ tabPadding: widget.tabPadding,
287
+ modIndex: modIndex,
288
+ tabBuilder: widget.tabBuilder,
289
+ separator: widget.separator,
290
+ indicatorWidth: indicatorWidth,
291
+ ),
292
+ ),
293
+ ),
294
+ ),
295
+ );
296
+ },
301
297
),
302
- ValueListenableBuilder <bool >(
303
- valueListenable: _isTabPositionAligned,
304
- builder: (context, value, _) => Visibility (
305
- visible: value,
306
- child: _CenteredIndicator (
307
- indicatorColor: widget.indicatorColor,
308
- size: _indicatorSize,
298
+ ),
299
+ Positioned (
300
+ bottom: 0 ,
301
+ left: 0 ,
302
+ right: 0 ,
303
+ child: ValueListenableBuilder <bool >(
304
+ valueListenable: _isTabPositionAligned,
305
+ builder: (context, value, _) => Visibility (
306
+ visible: value,
307
+ child: _CenteredIndicator (
308
+ indicatorColor: widget.indicatorColor,
309
+ size: _indicatorSize,
310
+ indicatorWidth: indicatorWidth,
311
+ ),
309
312
),
310
313
),
311
314
),
@@ -363,6 +366,8 @@ class _TabContent extends StatelessWidget {
363
366
required this .tabPadding,
364
367
required this .indicatorColor,
365
368
required this .tabBuilder,
369
+ this .separator,
370
+ required this .indicatorWidth,
366
371
}) : super (key: key);
367
372
368
373
final int modIndex;
@@ -371,26 +376,37 @@ class _TabContent extends StatelessWidget {
371
376
final double tabPadding;
372
377
final Color indicatorColor;
373
378
final SelectIndexedTextBuilder tabBuilder;
379
+ final BorderSide ? separator;
380
+ final double indicatorWidth;
374
381
375
382
@override
376
383
Widget build (BuildContext context) {
377
- return Container (
378
- padding: EdgeInsets .symmetric (
379
- horizontal: tabPadding,
380
- ),
381
- decoration: BoxDecoration (
382
- border: Border (
383
- bottom: selectedIndex == modIndex && ! isTabPositionAligned
384
- ? BorderSide (
385
- color: indicatorColor,
386
- width: 2.0 ,
387
- )
388
- : BorderSide .none,
384
+ return Stack (
385
+ clipBehavior: Clip .none,
386
+ children: [
387
+ Container (
388
+ padding: EdgeInsets .symmetric (horizontal: tabPadding),
389
+ decoration: BoxDecoration (
390
+ border: Border (bottom: separator ?? BorderSide .none),
391
+ ),
392
+ child: Center (
393
+ child: tabBuilder (modIndex, selectedIndex == modIndex),
394
+ ),
389
395
),
390
- ),
391
- child: Center (
392
- child: tabBuilder (modIndex, selectedIndex == modIndex),
393
- ),
396
+ if (selectedIndex == modIndex && ! isTabPositionAligned)
397
+ Positioned (
398
+ bottom: 0 ,
399
+ left: 0 ,
400
+ right: 0 ,
401
+ child: Container (
402
+ height: indicatorWidth,
403
+ decoration: BoxDecoration (
404
+ borderRadius: BorderRadius .circular (indicatorWidth),
405
+ color: indicatorColor,
406
+ ),
407
+ ),
408
+ )
409
+ ],
394
410
);
395
411
}
396
412
}
@@ -400,26 +416,25 @@ class _CenteredIndicator extends StatelessWidget {
400
416
Key ? key,
401
417
required this .indicatorColor,
402
418
required this .size,
419
+ required this .indicatorWidth,
403
420
}) : super (key: key);
404
421
405
422
final Color indicatorColor;
406
423
final ValueNotifier <double > size;
424
+ final double indicatorWidth;
407
425
408
426
@override
409
427
Widget build (BuildContext context) {
410
428
return ValueListenableBuilder <double >(
411
429
valueListenable: size,
412
430
builder: (context, value, _) => Center (
413
- child: Transform .translate (
414
- offset: const Offset (0.0 , - 2.0 ),
415
- child: Container (
416
- height: 2.0 ,
417
- decoration: BoxDecoration (
418
- borderRadius: BorderRadius .circular (4 ),
419
- color: indicatorColor,
420
- ),
421
- width: value,
431
+ child: Container (
432
+ height: indicatorWidth,
433
+ decoration: BoxDecoration (
434
+ borderRadius: BorderRadius .circular (indicatorWidth),
435
+ color: indicatorColor,
422
436
),
437
+ width: value,
423
438
),
424
439
),
425
440
);
0 commit comments