inde.html
<div>
<button id="bt2" style="width:140px; height:60px;">动态创建按钮</button>
<div id="carteButton_div"></div>
</div>
main.dart
import 'dart:html';
import 'dart:core';
void main() {
var I =1;
void createButton(Event e)
{
ButtonElement btn1 = new ButtonElement();
btn1.id = I.toString() ;
btn1.text = "第" + I.toString() + "个按钮";
I++;
querySelector('#carteButton_div').append( btn1);
}
querySelector('#bt2').onClick.listen( createButton );
}
结果: