lc_lazy_future_builder 0.1.0 copy "lc_lazy_future_builder: ^0.1.0" to clipboard
lc_lazy_future_builder: ^0.1.0 copied to clipboard

SDKDart
unlisted

add lazy load with future annotation

example/example.dart

import 'dart:async';

import 'package:lc_lazy_future/lc_lazy_future.dart';

part 'example.g.dart';

/// will generate TODO
@LcLazyGroup(
  extendType: ExtendType.useMixin,
  lazyOfStart: lazyOfStart,
  lazyOfEnd: lazyOfEnd,
)
class Example {
  String? fieldA;
  String? fieldB;
  String? fieldC;
  String? fieldD;
  String? fieldE;

  Example(
    this.fieldA, {
    this.fieldB = '',
    required this.fieldC,
  });

  /// will generate `Example.create` function
  @LcLazyFuture()
  Future<void> _create() async {
    await Future.delayed(const Duration(seconds: 1));
  }

  /// will generate `Example.update` function
  @LcLazyFuture(lazyOfStart: lazyOfStart, lazyOfEnd: lazyOfEnd)
  Future<void> _update() async {
    await Future.delayed(const Duration(seconds: 1));
  }
}

/// will generate TODO
@LcLazyGroup(
  lazyOfStart: Util.lazyOfStart,
  lazyOfEnd: Util.lazyOfEnd,
)
class Example2 {
  String? fieldD;
  String? fieldE;
  String? fieldF;
  String? fieldG;

  Example2(
    this.fieldD, [
    this.fieldE,
    this.fieldF,
    this.fieldG,
  ]);

  /// will generate `Example.create` function
  @LcLazyFuture(lazyOfStart: lazyOfStart, lazyOfEnd: lazyOfEnd)
  Future<void> _create() async {
    await Future.delayed(const Duration(seconds: 1));
  }

  /// will generate `Example.update` function
  @LcLazyFuture()
  Future<void> _update() async {
    await Future.delayed(const Duration(seconds: 1));
  }

  @LcLazyFuture()
  void _say() {
    /// todo
  }

  @LcLazyFuture()
  bool _sayBool() {
    /// todo
    return false;
  }

  @LcLazyFuture()
  bool? _sayBoolNullable() {
    /// todo
    return false;
  }

  @LcLazyFuture()
  FutureOr<bool> _sayFutureOr(int a, [dynamic b, double? c]) async {
    // TODO
    return false;
  }

  @LcLazyFuture(lazyOfStart: lazyOfStart)
  FutureOr<bool?> _sayFutureOrNullable(bool? a, dynamic b, {int? c}) async {
    // TODO
    return false;
  }
}

class Util {
  Util._();

  static Future<void> lazyOfStart() async {
    //
  }

  static Future<void> lazyOfEnd() async {
    //
  }
}

Future<void> lazyOfStart() async {
  //
}

Future<void> lazyOfEnd() async {
  //
}
0
likes
140
points
14
downloads

Publisher

unverified uploader

Weekly Downloads

add lazy load with future annotation

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, build, lc_lazy_future, meta, source_gen, source_helper

More

Packages that depend on lc_lazy_future_builder