idkit_gshared

Last updated:

0 purchases

idkit_gshared Image
idkit_gshared Images
Add to Cart

Description:

idkit gshared

idkit_gshared #
1. Briefly
This package is for global data sharing of Flutter projects. The following is a detailed introduction and use of its methods.
2. Use


Preconditions
First create a global shared data management object,As follows:
final IDKitGShared gShared = IDKitGShared();
copied to clipboard


Basic sharing
Register #
1.Register int、list、map......
gShared.register<int>(520);
gShared.register<int>(1314, mark: 'love');
copied to clipboard
2. Register object
gShared.register(
const TestInfo('Asynchronous registration'),
);
gShared.register(
const TestInfo('Asynchronous registration - Mark'),
mark: 'mark',
);
copied to clipboard
3. Asynchronous registration
gShared.register<Future<String>>(
Future.delayed(const Duration(seconds: 1), () {
return '110';
}),
);
gShared.register<Future<TestInfo>>(
Future.delayed(const Duration(seconds: 1), () {
return const TestInfo('120');
}),
mark: 'mark',
);
copied to clipboard
Read #
1. Read int、list、map......
gShared.read<int>() -> int?
gShared.read<int>(mark: 'love') -> int?
copied to clipboard
2. Read object
gShared.read<TestInfo>() -> TestInfo?
gShared.read<TestInfo>(mark: 'mark') -> TestInfo?
copied to clipboard
3. Read data asynchronously
FutureBuilder<String>(
future: gShared.read<Future<String>>(),
initialData: '000',
builder: (_, AsyncSnapshot<String> snapshot) {
return Text('${snapshot.data}');
},
),
FutureBuilder<String>(
future: gShared.read<Future<String>>(mark: 'mark'),
initialData: '000 - mark',
builder: (_, AsyncSnapshot<String> snapshot) {
return Text('${snapshot.data}');
},
),
copied to clipboard
Update data #
gShared.update<String>((value) => 'I am a baby!');
gShared.update<String>((value) => 'I am a baby!',mark:'mark');
copied to clipboard
unRegister #
gShared.unRegister<String>();
gShared.unRegister<String>(mark: 'mark');
copied to clipboard
or
gShared.unRegisterAll();
gShared.unRegisterAll(listen: true);
copied to clipboard


Listen sharing
Register #
gShared.registerListen<String>();
gShared.registerListen<String>(mark: 'mark');
copied to clipboard
Watch #
StreamBuilder<String?>(
stream: gShared.watch<String>(),
initialData: 'listen - 0',
builder: (_, s) {
final String? a = s.data;
return Text(a ?? 'listen - 0');
},
),
StreamBuilder<String?>(
stream: gShared.watch<String>(mark: 'mark'),
initialData: 'listen - 0',
builder: (_, s) {
final String? a = s.data;
return Text(a ?? 'listen - 0');
},
)
copied to clipboard
unRegister listen #
gShared.unRegisterListen<String>();
gShared.unRegisterListen<String>(mark: 'mark');
copied to clipboard
Convert #
gShared.convertListen<int>();
gShared.convertListen<int>(mark:'mark');
copied to clipboard


3. Summarize #
This version of the package covers some of the above methods. If you don't understand anything or don't understand how to use it, you can leave me a message!

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.