Skip to content

PirateBrook/data_tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pub package

A InheritedWidget that simplifies the tracker system share data for Component widget styling, Avoid multi-level parameter penetration .

Features

Lightweight for Tracking system or Analytics by Firebase etc. Provider a quick access for data of analytics.

Usage

class Example extends StatelessWidget {
  const Example({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return TrackerScope(
      params: const {"id": 101},
      parentContext: context,
      child: const ExampleComponent(),
    );
  }
}

class ExampleComponent extends StatelessWidget {
  const ExampleComponent({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return TrackerScope(
      params: const {"name": "brook", "age": "18"},
      parentContext: context,
      child: Builder(builder: (conetxt) {
        final id = Tracker.find(conetxt, "id");
        final idOrDefault =
            Tracker.findOrDefault(context, 'id', defaultVal: "101");
        final filters = Tracker.findMap(conetxt, ['id', 'name']);
        final allFilters = Tracker.findAllMap(conetxt, ['id', 'name']);
        final currentParams = Tracker.collectSelf(conetxt);
        final allParams = Tracker.collect(conetxt);

        return Column(
          children: [
            Text('$id'),
            Text('$idOrDefault'),
            Text('$filters'),
            Text('$allFilters'),
            Text('$currentParams'),
            Text('$allParams'),
          ],
        );
      }),
    );
  }
}

Use for dialog or another Cross-Context Scenes.

showDialog(
  context: context,
  builder: (context) {
    return TrackerScope(
      params: Tracker.collect(context),
      child: Container(),
    );
  },
);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages