pd_load_state

中文 | English

A Flutter plugin for managing network request UI states (loading/error/empty/success) with enhanced UI, multi-platform support and generic data carrying.

✨ Features

  • 🎨 Enhanced UI - Modern loading animations, gradient effects, smooth state transitions
  • 📱 Multi-platform Support - Perfectly compatible with Android, iOS, Web, macOS, Windows, Linux
  • Lightweight & Efficient - Simple API design for quick integration
  • 📦 Generic Data Carrying - Strongly-typed data transfer, carry business data directly in success state
  • 🌐 Internationalization - Built-in Chinese/English support with custom multi-language support
  • 🔧 Global Configuration - Unified configuration for default behavior and styles
  • 🎯 Accessibility Support - Complete semantic label support

📦 Installation

dependencies:
  pd_load_state: ^1.1.1
flutter pub get

🚀 Quick Start

import 'package:pd_load_state/pd_load_state.dart';

class SimpleExample extends StatefulWidget {
  const SimpleExample({super.key});

  @override
  State<SimpleExample> createState() => _SimpleExampleState();
}

class _SimpleExampleState extends State<SimpleExample> {
  final PDLoadState loadState = PDLoadState('SimpleExample');

  @override
  Widget build(BuildContext context) {
    return PDLoadStateLayout(
      loadState: loadState,
      onLoading: network,
      builder: (context) => const Center(child: Text('Content')),
    );
  }

  void network() {
    Future.delayed(const Duration(seconds: 2)).then((_) {
      loadState.success();
    });
  }
}

📖 Documentation

Refer to the doc/ directory for detailed documentation:

Document Description
basic_usage.md Basic Usage Guide
data_generics.md Generic Data Carrying
api_reference.md Complete API Documentation
configuration.md Global Configuration
i18n.md Internationalization
enhanced_ui.md Enhanced UI

📱 Example

For more example code, refer to the /example/lib/ directory:

  • basic_demo.dart - Basic usage
  • data_demo.dart - Data carrying
  • config_demo.dart - Configuration demonstration
  • i18n_demo.dart - Internationalization
  • animation_demo.dart - Animation effects
  • platform_demo.dart - Platform adaptation

🤝 Support and Community

📄 License

MIT License

Libraries

pd_load_state
一个用于管理网络请求不同 UI 状态的 Flutter 库,支持泛型数据携带。