-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added carousel size constraint, carousel fading transition, carousel …
…sliding transition, carousel dot indicator widget, and more carousel examples
- Loading branch information
1 parent
50920c3
commit e064491
Showing
6 changed files
with
568 additions
and
139 deletions.
There are no files selected for viewing
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
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
61 changes: 61 additions & 0 deletions
61
docs/lib/pages/docs/components/carousel/carousel_example_3.dart
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import 'package:shadcn_flutter/shadcn_flutter.dart'; | ||
|
||
import '../carousel_example.dart'; | ||
|
||
class CarouselExample3 extends StatefulWidget { | ||
const CarouselExample3({super.key}); | ||
|
||
@override | ||
State<CarouselExample3> createState() => _CarouselExample3State(); | ||
} | ||
|
||
class _CarouselExample3State extends State<CarouselExample3> { | ||
final CarouselController controller = CarouselController(); | ||
@override | ||
Widget build(BuildContext context) { | ||
return SizedBox( | ||
width: 800, | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
SizedBox( | ||
height: 200, | ||
child: Carousel( | ||
transition: const CarouselLayout.fading(), | ||
controller: controller, | ||
draggable: false, | ||
autoplaySpeed: const Duration(seconds: 1), | ||
itemCount: 5, | ||
itemBuilder: (context, index) { | ||
return NumberedContainer(index: index); | ||
}, | ||
duration: const Duration(seconds: 1), | ||
), | ||
), | ||
const Gap(8), | ||
Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
CarouselDotIndicator(itemCount: 5, controller: controller), | ||
const Spacer(), | ||
OutlineButton( | ||
shape: ButtonShape.circle, | ||
onPressed: () { | ||
controller | ||
.animatePrevious(const Duration(milliseconds: 500)); | ||
}, | ||
child: const Icon(Icons.arrow_back)), | ||
const Gap(8), | ||
OutlineButton( | ||
shape: ButtonShape.circle, | ||
onPressed: () { | ||
controller.animateNext(const Duration(milliseconds: 500)); | ||
}, | ||
child: const Icon(Icons.arrow_forward)), | ||
], | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
docs/lib/pages/docs/components/carousel/carousel_example_4.dart
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:shadcn_flutter/shadcn_flutter.dart'; | ||
|
||
import '../carousel_example.dart'; | ||
|
||
class CarouselExample4 extends StatefulWidget { | ||
const CarouselExample4({super.key}); | ||
|
||
@override | ||
State<CarouselExample4> createState() => _CarouselExample4State(); | ||
} | ||
|
||
class _CarouselExample4State extends State<CarouselExample4> { | ||
final CarouselController controller = CarouselController(); | ||
@override | ||
Widget build(BuildContext context) { | ||
return SizedBox( | ||
width: 800, | ||
height: 200, | ||
child: Carousel( | ||
transition: const CarouselLayout.sliding(gap: 24), | ||
controller: controller, | ||
draggable: false, | ||
autoplaySpeed: const Duration(seconds: 2), | ||
curve: Curves.linear, | ||
itemCount: 5, | ||
sizeConstraint: const CarouselSizeConstraint.fixed(200), | ||
itemBuilder: (context, index) { | ||
return NumberedContainer(index: index); | ||
}, | ||
duration: Duration.zero, | ||
), | ||
); | ||
} | ||
} |
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
Oops, something went wrong.