am_state 0.0.2+1 copy "am_state: ^0.0.2+1" to clipboard
am_state: ^0.0.2+1 copied to clipboard

outdated

A state-management and data providing library.

am_state #

A state-management and data providing library.

---No stateful widgets needed---

Getting Started #

To initialize data provider #

import 'package:am_state/am_state.dart';

final dataProvider = AmDataProvider<int>(
  initialData: 0,
  providerId: 'dataP_01',
);

// OR
final dataProvider = AmDataProvider<int>();     // You can't access this with id

To get data any where after initializing the provider #

int? num = AmDataProvider<int>.of('dataP_01').data;

To Refresh widgets if data changed #

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

  @override
  Widget build(BuildContext context) {
    return Container(
      child: AmRefreshWidget<int>(
        amDataProvider: AmDataProvider<int>.of('providerId'),
        builder: (ctx, value) {
          return Text(
            '$value',
          );
        },
      ),
    );
  }
}

To change the provider data without refresh states #

    
    dataProvider.silentDataSet = dataProvider.data! + 1;
    // OR
    AmDataProvider<String>.of('providerId').silentDataSet = 'any data';

To change provider data with refresh states #


    dataProvider.data = dataProvider.data! + 1;
    // OR
    AmDataProvider<String>.of('providerId').data = 'Some Data';

To instantinously excute some code and then refresh states #


    dataProvider.activeFunction = () {
      //...Some Code....instantinously invoked then states refreshed
    };
    // OR
    AmDataProvider<String>.of('providerId').activeFunction = () {
      //...Some Code....instantinously invoked then states refreshed
    };

Please star my repo and follow me 😍 #

https://github.com/AmrMAM/FlutterPackage_am_state

12
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A state-management and data providing library.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on am_state