tazboy

Untitled

Dec 12th, 2020
1,056
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class HomeScreen extends ConsumerWidget {
  2.   final _diceProvider = StateProvider<List<DieWidget>>((ref) {
  3.     return [DieWidget(value: 3, min: 1, max: 6)];
  4.   });
  5.  
  6.   // TODO: Longpress delete from list --> delete from screen
  7.  
  8.   @override
  9.   Widget build(BuildContext context, ScopedReader watch) {
  10.     final diceWatcher = watch(_diceProvider).state;
  11.     return Container(
  12.       child: Consumer(
  13.         builder: (context, watch, child) {
  14.           return Column(
  15.             children: [
  16.               FlatButton(
  17.                 child: Text("Add die"),
  18.                 onPressed: () {
  19.                   context
  20.                       .read(_diceProvider)
  21.                       .state
  22.                       .add(DieWidget(value: 5, min: 1, max: 6));
  23.                   print(diceWatcher[0].value);
  24.                 },
  25.               ),
  26.               [..._diceProvider]
  27.             ],
  28.           );
  29.         },
  30.       ),
  31.     );
  32.   }
  33. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×