暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

backgroundHistory.dart 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import 'package:flutter/material.dart';
  2. class Background extends StatelessWidget {
  3. const Background({Key? key}) : super(key: key);
  4. @override
  5. Widget build(BuildContext context) {
  6. return Scaffold(
  7. resizeToAvoidBottomInset: false,
  8. backgroundColor: Colors.white,
  9. body: Column(
  10. children: <Widget>[
  11. new Stack(
  12. children: <Widget>[
  13. WavyHeader()
  14. ],
  15. ),
  16. ],
  17. ),
  18. );
  19. }
  20. }
  21. const List<Color> orangeGradients = [
  22. /*Color(0xFFD21404),
  23. Color(0xFFFD7267)*/
  24. Color(0xFF4858A7),
  25. Color(0xFF6474C6),
  26. ];
  27. const List<Color> aquaGradients = [
  28. Color(0xFF8EF7DA),
  29. Color(0xFF5AEAF1),
  30. Colors.blueAccent,
  31. ];
  32. class WavyHeader extends StatelessWidget {
  33. @override
  34. Widget build(BuildContext context) {
  35. return ClipPath(
  36. clipper: TopWaveClipper(),
  37. child: Container(
  38. decoration: BoxDecoration(
  39. gradient: LinearGradient(
  40. colors: orangeGradients,
  41. begin: Alignment.topLeft,
  42. end: Alignment.center),
  43. ),
  44. height: MediaQuery.of(context).size.height / 2.5,
  45. ),
  46. );
  47. }
  48. }
  49. class TopWaveClipper extends CustomClipper<Path> {
  50. @override
  51. Path getClip(Size size) {
  52. // This is where we decide what part of our image is going to be visible.
  53. var path = Path();
  54. path.lineTo(0.0, 0.0);
  55. var firstControlPoint = new Offset(0, size.height - 30);
  56. var firstEndPoint = new Offset(0, size.height / 2);
  57. path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
  58. firstEndPoint.dx, firstEndPoint.dy);
  59. var secondControlPoint = Offset(size.width / 5, size.height / 4);
  60. var secondEndPoint = Offset(size.width / 1.5, size.height / 5);
  61. path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy,
  62. secondEndPoint.dx, secondEndPoint.dy);
  63. var thirdControlPoint =
  64. Offset(size.width - (size.width / 9), size.height / 6);
  65. var thirdEndPoint = Offset(size.width, 0.0);
  66. path.quadraticBezierTo(thirdControlPoint.dx, thirdControlPoint.dy,
  67. thirdEndPoint.dx, thirdEndPoint.dy);
  68. ///move from bottom right to top
  69. path.lineTo(size.width, 0.0);
  70. ///finally close the path by reaching start point from top right corner
  71. path.close();
  72. return path;
  73. }
  74. @override
  75. bool shouldReclip(CustomClipper<Path> oldClipper) => false;
  76. }