我在创建一个UI屏幕时遇到了麻烦,基本上这个屏幕有7个圆圈,一个在中间,六个在它周围。当六个圆圈中的任何一个被点击时,我希望所有六个圆圈都开始围绕中间的一个圆圈旋转。如需了解更多信息,请参阅所附图片。
直到现在我尝试使用flutter包circular_rotation: ^0.0.1
。这个包wwtly提供了我想要的东西,但问题是,这个包是让mr只创建4个圆圈围绕中间的一个,只是当我添加5,它开始表现wierd。
我的准则
import 'dart:math';
import 'package:circular_rotation/circular_rotation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:islamicapp/app/data/constant/app_color.dart';
import 'package:islamicapp/app/data/constant/image_string.dart';
import 'package:islamicapp/app/views/widgets/button_text2.dart';
import 'package:islamicapp/app/views/widgets/ktext2.dart';
class Randomizer extends StatefulWidget {
const Randomizer({super.key});
@override
State<Randomizer> createState() => _RandomizerState();
}
class _RandomizerState extends State<Randomizer> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColor.green,
body: Container(
width: Get.width,
height: Get.height,
alignment: Alignment.center,
child: CircularRotation(
circularRotationProperty: CircularRotationModel(
// defaultCircleStrokeWidth: Dimens.strokeSmall,
defaultCircleStrokeColor: Colors.transparent,
startAnimation: false,
repeatAnimation: false,
firstCircleAnimationDuration: 12000,
// thirdCircleAnimationDuration: 10000,
centerWidget: Container(
width: 150.w,
height: 150.h,
padding: EdgeInsets.all(10),
alignment: Alignment.center,
decoration: BoxDecoration(
color: AppColor.feel,
shape: BoxShape.circle,
),
child: KText2(
text: "feel".tr,
fontSize: 24.sp,
fontWeight: FontWeight.bold,
),
),
visibleThirdCircle: false,
firstCircleWidgets: [
InkWell(
// onTap: CircularRotation.eitherStartOrStopAnimation,
child: Container(
width: 100.w,
// height: 100.h,
padding: EdgeInsets.all(10),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: Column(
children: [
Image(
image: ImageString.happy,
width: 60.w,
height: 60.h,
),
KText2(
text: "happy".tr,
fontSize: 20.sp,
fontWeight: FontWeight.bold,
),
],
),
),
),
InkWell(
// onTap: CircularRotation.eitherStartOrStopAnimation,
child: Container(
width: 100.w,
// height: 100.h,
padding: EdgeInsets.all(10),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: Column(
children: [
Image(
image: ImageString.happy,
width: 60.w,
height: 60.h,
),
KText2(
text: "happy".tr,
fontSize: 20.sp,
fontWeight: FontWeight.bold,
),
],
),
),
),
InkWell(
// onTap: CircularRotation.eitherStartOrStopAnimation,
child: Container(
width: 100.w,
// height: 100.h,
padding: EdgeInsets.all(10),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: Column(
children: [
Image(
image: ImageString.happy,
width: 60.w,
height: 60.h,
),
KText2(
text: "happy".tr,
fontSize: 20.sp,
fontWeight: FontWeight.bold,
),
],
),
),
),
InkWell(
// onTap: CircularRotation.eitherStartOrStopAnimation,
child: Container(
width: 100.w,
// height: 100.h,
padding: EdgeInsets.all(10),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: Column(
children: [
Image(
image: ImageString.happy,
width: 60.w,
height: 60.h,
),
KText2(
text: "happy".tr,
fontSize: 20.sp,
fontWeight: FontWeight.bold,
),
],
),
),
),
],
firstCircleRadius: 330.w,
visibleSecondCircle: true,
// secondCircleRadius: 330.w,
// secondCircleAnimationDuration: 12000,
// thirdCircleRadius: 150.w,
// secondCircleWidgets: [
// Container(
// width: 120.w,
// // height: 100.h,
// padding: EdgeInsets.all(10),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// color: Colors.white,
// shape: BoxShape.circle,
// ),
// child: Column(
// children: [
// Image(
// image: ImageString.happy,
// width: 60.w,
// height: 60.h,
// ),
// KText2(
// text: "happy".tr,
// fontSize: 20.sp,
// fontWeight: FontWeight.bold,
// ),
// ],
// ),
// ),
// ],
// thirdCircleWidgets: _thirdCircleImages,
// thirdCircleRadians: Dimens.thirdCircleRadians,
// secondCircleRadians: Dimens.secondCircleRadians,
// firstCircleRadians: Dimens.firstCircleRadians,
),
),
),
);
}
}
1条答案
按热度按时间eh57zj3b1#
您可以使用circle_list包创建它,如下所示
more examples here
code is here