I want to achieve this kind of swipe image 1
But when i deisgned i am getting this kind of output image 2
I want the smoothness while swiping and don’t want to use any packages.
Any suggestion or help is appriciated.
I have tries using Transfor.rotate but there is no animation the reaults i got you can see above
import 'package:flutter/material.dart';
import 'package:mawada/cardCollections/widgets/card_play_widget.dart';
import 'package:mawada/constants/app_color.dart';
import 'package:mawada/shared/widgets/app_button.dart';
class CardPlay extends StatefulWidget {
const CardPlay({super.key});
@override
State<CardPlay> createState() => _CardPlayState();
}
class _CardPlayState extends State<CardPlay>
with SingleTickerProviderStateMixin {
final pageController = PageController(viewportFraction: 0.7);
int _index = 0;
late final AnimationController _animationController;
int currentPage = 0;
@override
void initState() {
super.initState();
_animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 500),
);
}
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColor.background,
appBar: AppBar(
actions: [
Padding(
padding: const EdgeInsets.only(right: 10.0),
child: Image.asset(
'assets/logo2.png',
fit: BoxFit.cover,
height: 55,
),
)
],
),
body: ListView(
padding: const EdgeInsets.symmetric(vertical: 30),
children: [
// Progress indiator
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(30),
boxShadow: [
BoxShadow(
offset: const Offset(0, 2),
color: Colors.grey.withOpacity(0.5),
spreadRadius: 1,
blurRadius: 2)
]),
child: LinearProgressIndicator(
value: 0.2,
semanticsLabel: "0.2",
backgroundColor: Colors.white,
valueColor: const AlwaysStoppedAnimation<Color>(
AppColor.primary,
),
minHeight: 45,
borderRadius: BorderRadius.circular(30)),
),
),
const SizedBox(
height: 50,
),
SizedBox(
height: 400,
child: PageView.builder(
// physics: PageScrollPhysics(),
onPageChanged: (int index) => setState(() => _index = index),
controller: pageController,
itemCount: 10,
itemBuilder: (context, i) {
final double rotation = (i - _index) == 1
? 0.1
: (i - _index) == -1
? -0.1
: 0.0;
return Center(
child: Transform.rotate(
filterQuality: FilterQuality.low,
angle: i == _index ? 0 : rotation,
// angle: i == currentPage ? _animationController.value * rotation : rotation,
child: i == _index
? const Padding(
padding: EdgeInsets.only(bottom: 30),
child: CardPlayWidget(),
)
: const CardPlayWidget()));
}),
)
],
),
bottomNavigationBar: Container(
height: 150,
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Center(
child: AppButton(
elevation: 0,
borderSideColor: AppColor.primary,
backgroundColor: AppColor.background,
foregroundColor: AppColor.primary,
buttonText: "Close",
onPressed: () {})),
));
}
}
This is the code i have written
2
Answers
You can use PageController along with GestureDetector and make PageView’s physics to NeverScrollableScrollPhysics. Try below once it may need some improvements according to your need :
try this
Foo
widget, the main idea is to useFlow
widget with a delegate that paints the rotated child: