我正在尝试使用 flutter_local_notifications 插件向我的应用程序添加通知,但 AndroidInitializationSettings 需要可绘制资源并在未提供时引发此错误:
"PlatformException (PlatformException(INVALID_ICON, The resource could not be found. Please make sure it has been added as a drawable resource to your Android head project., null))"
Run Code Online (Sandbox Code Playgroud)
问题是我不知道Android头项目在哪里。
当渲染 widget 的多个实例并且调用 getValue 方法时,flutter 会抛出错误 ScrollController 附加到多个滚动视图。我假设这是因为它们都使用相同的控制器,但我不知道如何解决这个问题,而无需在每次使用时创建单独的小部件。有更好的方法来解决这个问题吗?
class NumScroller extends StatelessWidget{
final int max,min;
final double height,width;
final TextAlign alignment;
static ScrollController controller;
NumScroller({this.height,this.width,this.alignment,this.min,this.max, initialOffset}){
controller = new ScrollController(initialScrollOffset: initialOffset);
}
getValue() => (controller.offset~/height) + min;
@override
Widget build(BuildContext context) {
return new Container(
width: width,
height: height,
child: ListView.builder(itemBuilder: (context, index) {
return new Container(height: height, child:Text((max - index).toString(),textAlign: alignment,));
},
itemCount: max - min+1,
controller: controller,
physics: PageScrollPhysics(),
itemExtent: height,
)
);
}
}
Run Code Online (Sandbox Code Playgroud)