ecco_lint 0.0.1 copy "ecco_lint: ^0.0.1" to clipboard
ecco_lint: ^0.0.1 copied to clipboard

A custom lint package for the Ecco state management framework in Flutter

example/lib/main.dart

// ignore_for_file: unused_local_variable
import 'package:flutter/material.dart';
import 'package:ecco/ecco.dart';

void main() {
  runApp(const MyApp());
}

class CounterModel {
  final int count;
  CounterModel(this.count);
}

class CounterViewModel extends EccoNotifier<CounterModel> {
  CounterViewModel() : super(CounterModel(0));

  void increment() {
    ripple(CounterModel(state.count + 1));
  }
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: EccoProvider<CounterModel>(
        notifier: CounterViewModel(),
        child: const MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    // expect_lint: avoid_dynamic_ecco_notifier
    final dynamicNotifier = EccoNotifier<dynamic>(0);

    return Scaffold(
      appBar: AppBar(title: const Text('Ecco Example')),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          // expect_lint: missing_ecco_provider
          EccoBuilder<AnotherModel>(
            builder: (context, state) {
              return Text('Another count: ${state.count}');
            },
          ),
          EccoConsumer<CounterModel, CounterViewModel>(
            builder: (context, state, viewModel) {
              return Text('Count: ${state.count}');
            },
          ),
          ElevatedButton(
            onPressed: () {
              final viewModel = context.ecco<CounterViewModel>();
              // expect_lint: invalid_ripple_usage
              viewModel.ripple(viewModel.state);
            },
            child: const Text('Increment'),
          ),
        ],
      ),
    );
  }
}

class AnotherModel {
  final int count;
  AnotherModel(this.count);
}
1
likes
0
points
0
downloads

Publisher

verified publisherpermad.art

Weekly Downloads

A custom lint package for the Ecco state management framework in Flutter

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, analyzer_plugin, collection, custom_lint_builder

More

Packages that depend on ecco_lint