转盘滑块viewportfraction
和纵横比。如何计算纵横比以获得预期的宽度和高度。我用的是carousel包。
我想这样实现(
,
)。我尝试了宽高比,视口分数,但我的尝试是不完美的工作。
下面是我的结果
。我在Chrome浏览器上运行。当viewportfraction
和aspect ratio
不能达到预期的宽度和高度值时。如何计算aspect ratio
和viewportfraction
?
这是我的代码。
class UiDesignSlider extends StatefulWidget {
const UiDesignSlider({Key? key}) : super(key: key);
@override
State<UiDesignSlider> createState() => _UiDesignSliderState();
}
class _UiDesignSliderState extends State<UiDesignSlider> {
final u = Get.find<UtilityController>();
DateTime dateTime = DateTime.now();
int current = 0;
final CarouselController _controller = CarouselController();
final List<String> sliderScreenList = [
'challenge2',
'challenge3',
'challenge4',
];
@override
Widget build(BuildContext context) {
bool isMobile = Responsive.isMobile();
return Container(
height: isMobile ? 250 : 350,
width: u.size.width,
color: Colors.green,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 30),
Expanded(
child: CarouselSlider(
items: sliderScreenList.map((i) {
return Builder(
builder: (BuildContext context) {
return Column(
children: [
Expanded(
child: Image.asset(
'assets/images/carousel/$i.png',
),
),
],
);
},
);
}).toList(),
carouselController: _controller,
options: CarouselOptions(
onPageChanged: (index, reason) {
setState(() {
current = index;
});
},
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: sliderScreenList.asMap().entries.map((entry) {
return GestureDetector(
onTap: () => _controller.animateToPage(entry.key),
child: SlideOnOff(
isOn: current == entry.key ? true : false,
u: u,
),
);
}).toList(),
),
],
),
);
}
}
1条答案
按热度按时间pcww981p1#
我自己有办法。这是我的解决方案。