loading.dart 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import 'package:flutter/material.dart';
  2. import 'easy_loading.dart';
  3. class FlutterEasyLoading extends StatefulWidget {
  4. /// should be [MaterialApp] or [CupertinoApp].
  5. /// make sure that loading can be displayed in front of all other widgets
  6. final Widget child;
  7. final TextDirection textDirection;
  8. const FlutterEasyLoading({
  9. Key key,
  10. @required this.child,
  11. this.textDirection = TextDirection.ltr,
  12. }) : super(key: key);
  13. @override
  14. _FlutterEasyLoadingState createState() => _FlutterEasyLoadingState();
  15. }
  16. class _FlutterEasyLoadingState extends State<FlutterEasyLoading> {
  17. @override
  18. void initState() {
  19. super.initState();
  20. }
  21. @override
  22. void dispose() {
  23. super.dispose();
  24. }
  25. @override
  26. Widget build(BuildContext context) {
  27. return Directionality(
  28. child: Overlay(
  29. initialEntries: [
  30. OverlayEntry(
  31. builder: (BuildContext _context) {
  32. EasyLoading.instance.context = _context;
  33. return widget.child;
  34. },
  35. ),
  36. ],
  37. ),
  38. textDirection: widget.textDirection,
  39. );
  40. }
  41. }