我的GestureDetector身体简单,工作正常。我尝试在正文中添加功能,但显示断言失败。
class AlphabetPage extends StatefulWidget {
@override
_AlphabetPageState createState() => _AlphabetPageState();
}
class _AlphabetPageState extends State<AlphabetPage> {
testing(){
GestureDetector(
onTap: (){
play('a');
},
child: Container(
color: Colors.white,
margin: EdgeInsets.fromLTRB(15, 10, 0, 0),
child: Image(image: AssetImage('images/a.jpg'),
height: 60,
width: 60,
),
),
);
}
play(a){
final player = AudioCache();
player.play('$a.wav');
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.purple,
automaticallyImplyLeading: true,
//`true` if you want Flutter to automatically add Back Button when needed,
//or `false` if you want to force your own back button every where
title: Text('Alphabet Sounds'),
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () => Navigator.pop(context, false),
),
),
body: Column(children: <Widget>[
Row(
//ROW 1
children: [
testing(),
testing(),
],
),
],
),
),
);
}
}
如果不适使用测试功能,则当我将其包装在测试功能中并在其内部调用testing显示错误时,它将正常工作。
答案 0 :(得分:1)
将您的-DIMGUI_DIR="C:/bla/imgui"
更新为
testing