DanmuModel constructor

DanmuModel({
  1. required int id,
  2. required String text,
  3. required Duration startTime,
  4. List<InlineSpan> spans = const [],
  5. bool isClickable = true,
  6. double? specifyY,
  7. ImageProvider<Object>? imageProvider,
  8. String? package,
  9. bool isRepeatable = false,
  10. double opacity = 1,
  11. EdgeInsets padding = const EdgeInsets.symmetric(vertical: 2, horizontal: 8),
  12. EdgeInsets margin = const EdgeInsets.symmetric(vertical: 2, horizontal: 8),
  13. double strokeWidth = 1,
  14. Size imageSize = const Size(52, 20),
  15. int flag = DanmuFlag.scroll | DanmuFlag.clickable,
  16. BoxDecoration? decoration,
  17. BoxDecoration? foregroundDecoration,
  18. AlignmentGeometry? alignment,
  19. Duration? insertTime,
  20. TextStyle textStyle = const TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500, decoration: TextDecoration.none),
})

Implementation

DanmuModel({
  required this.id,
  required this.text,
  required this.startTime,
  this.spans = const [],
  this.isClickable = true,
  this.specifyY,
  this.imageProvider,
  this.package,
  this.isRepeatable = false,
  this.opacity = 1,
  this.padding = const EdgeInsets.symmetric(vertical: 2, horizontal: 8),
  this.margin = const EdgeInsets.symmetric(vertical: 2, horizontal: 8),
  this.strokeWidth = 1,
  this.imageSize = const Size(52, 20),
  this.flag = DanmuFlag.scroll | DanmuFlag.clickable,
  this.decoration,
  this.foregroundDecoration,
  this.alignment,
  Duration? insertTime,
  this.textStyle = const TextStyle(
    color: Colors.white,
    fontSize: 16,
    fontWeight: FontWeight.w500,
    decoration: TextDecoration.none,
  ),
})  : assert(textStyle != null),
      assert(!flag.isSpecify || specifyY != null, "如果需要指定y坐标,必须传入specifyY值"),
      insertTime = insertTime ?? startTime;