static_block.dart 898 B

123456789101112131415161718192021222324252627282930
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/widgets.dart';
  3. import 'package:flutter_2048/views/number_text.dart';
  4. import 'package:flutter_2048/views/block/base_block.dart';
  5. import 'package:flutter_2048/model/block_info.dart';
  6. class StaticBlock extends BaseBlock {
  7. final BlockInfo info;
  8. StaticBlock({
  9. Key key,
  10. this.info,
  11. AnimationController controller,
  12. }) : super(
  13. key: key,
  14. animation:
  15. new Tween<double>(begin: 0.0, end: 0.0).animate(controller),
  16. );
  17. @override
  18. Widget buildBlock(BuildContext context, BlockProps props) {
  19. return Positioned(
  20. top:
  21. (info.current ~/ props.mode) * (props.blockWidth + props.borderWidth),
  22. left:
  23. (info.current % props.mode) * (props.blockWidth + props.borderWidth),
  24. child: NumberText(value: this.info.value, size: props.blockWidth),
  25. );
  26. }
  27. }