widgetItem.dart 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import 'dart:io';
  2. import 'package:flutter/material.dart';
  3. class WidgetItem {
  4. factory WidgetItem() => _getInstance();
  5. static WidgetItem _instance;
  6. static WidgetItem _getInstance() {
  7. if (_instance == null) {
  8. _instance = WidgetItem._internal();
  9. }
  10. return _instance;
  11. }
  12. WidgetItem._internal();
  13. Widget returnFileOperateButton(BuildContext context, int cardColor,
  14. Function(FileSystemEntity file,int type) fun,String titleText,FileSystemEntity file,int type) {
  15. Color color;
  16. switch(titleText){
  17. case '删除':
  18. color=Colors.blueGrey;
  19. break;
  20. case '重命名':
  21. color=Colors.blue;
  22. break;
  23. case '复制':
  24. color=Colors.blueAccent;
  25. break;
  26. case '剪切':
  27. color=Colors.lightBlue;
  28. break;
  29. case '收藏':
  30. color=Colors.cyan;
  31. break;
  32. case '取消收藏':
  33. color=Colors.cyanAccent;
  34. break;
  35. }
  36. return Container(
  37. width: 170,
  38. child: Card(
  39. color: Color(cardColor),
  40. margin: EdgeInsets.only(left: 5, right: 5, bottom: 20),
  41. child: InkWell(
  42. child: Center(
  43. child: Padding(
  44. padding: EdgeInsets.all(10),
  45. child: Text(titleText, style: TextStyle(color: color)),
  46. ),
  47. ),
  48. onTap: () {
  49. Navigator.pop(context);
  50. fun(file,type);
  51. },
  52. ),
  53. ),
  54. );
  55. }
  56. }