background.dart 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import 'package:flutter/material.dart';
  2. /// Description: background for login and register page
  3. /// Time : 08/24/2023 Thursday
  4. /// Author : liuyuqi.gov@msn.cn
  5. class Background extends StatelessWidget {
  6. final Widget child;
  7. final String topImg, bottomImg;
  8. const Background(
  9. {super.key,
  10. required this.child,
  11. this.topImg = "assets/images/main_top.png",
  12. this.bottomImg = "assets/images/main_bottom.png"});
  13. @override
  14. Widget build(BuildContext context) {
  15. return Scaffold(
  16. resizeToAvoidBottomInset: false,
  17. body: SizedBox(
  18. // color: Colors.green,
  19. width: double.infinity,
  20. height: MediaQuery.of(context).size.height,
  21. child: Stack(
  22. alignment: Alignment.center,
  23. // alignment: Alignment.topCenter,
  24. children: [
  25. Positioned(
  26. top: 0,
  27. left: 0,
  28. child: Image.asset(
  29. topImg,
  30. width: 120,
  31. )),
  32. // Positioned(
  33. // bottom: 0,
  34. // right: 0,
  35. // child: Image.asset(
  36. // bottomImg,
  37. // width: 120,
  38. // )),
  39. SafeArea(
  40. child: Container(
  41. margin: const EdgeInsets.only(left: 20, right: 20),
  42. child: child,
  43. ))
  44. ],
  45. ),
  46. ),
  47. );
  48. }
  49. }