flutter widget 混合管理 子組件傳值給父組件

這裏最重要的就是定義@required this.onChanged

class SonWidget extends StatefulWidget {
  SonWidget ({Key key,this.weibo,@required this.onChanged}):super(key:key);
  Map weibo;
  final  ValueChanged<bool> onChanged;
}

然後再父widget 中  調用子widget

child:SonWidget(
 onChanged:(value){

 }
)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章