0

谁能帮我解决这个问题我正在学习如何从技术人员开花频道播放列表制作轮播屏幕截图中的错误如下我正在努力解决零安全问题任何人都可以解决这个问题。我尝试使用空安全性但无法成功谢谢在此处输入图像描述

4

1 回答 1

2

用包裹你的child内部。builderContainer()

//...
builder: (BuildContext context, Widget? child) {
    return Container(child: child);
  },
//...

这是如何使用的示例示例AnimatedBuilder()

class MyWidget extends StatefulWidget {
  @override
  _MyWidgetState createState() => _MyWidgetState();
}

class _MyWidgetState extends State<MyWidget> with 
TickerProviderStateMixin {
  late final AnimationController _controller = AnimationController(
  duration: const Duration(seconds: 10),
  vsync: this,
)..repeat();
@override
Widget build(BuildContext context) {
  return AnimatedBuilder(
    // This widget wont rebuild.
    child: Container(
      child: Text("I can not rebuild weeeee.....!!!"), color: Colors.green),
  animation: _controller,
  builder: (BuildContext context, Widget? child) {
    return Transform.rotate(
      angle: _controller.value * 2.0 * math.pi,
      // here you will pass your widget
      child: child,
     );
    },
  );
 }
}
于 2021-06-06T12:52:22.057 回答