Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Version up
Browse files Browse the repository at this point in the history
  • Loading branch information
markvideon committed Jan 31, 2023
1 parent a92024e commit e272502
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 19 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
## 4.0.0+2

* Miscellaneous format post-processing on the files.

## 4.0.0+1

* Miscellaneous tidy-up of package internals.

## 4.0.0

* Made [WidgetRef] property on [ComponentRef] private. It should not be accessed directly.
* Removed the [riverpodAwareGameProvider]. If required, this is better handled at the application-level.
* Removed the [riverpodAwar`eGameProvider]. If required, this is better handled at the application-level.

## 3.0.0

Expand Down
28 changes: 18 additions & 10 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,17 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: Row(crossAxisAlignment: CrossAxisAlignment.start, children: const [
Expanded(child: FlutterCountingComponent()),
Expanded(
home: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Expanded(child: FlutterCountingComponent()),
Expanded(
child: RiverpodGameWidget.initialiseWithGame(
uninitialisedGame: RefExampleGame.new,),)
],),
uninitialisedGame: RefExampleGame.new,
),
)
],
),
);
}
}
Expand All @@ -61,9 +66,10 @@ class FlutterCountingComponent extends ConsumerWidget {
children: [
Text('Flutter', style: textStyle),
stream.when(
data: (value) => Text('$value', style: textStyle),
error: (error, stackTrace) => Text('$error', style: textStyle),
loading: () => Text('Loading...', style: textStyle),)
data: (value) => Text('$value', style: textStyle),
error: (error, stackTrace) => Text('$error', style: textStyle),
loading: () => Text('Loading...', style: textStyle),
)
],
),
);
Expand All @@ -88,8 +94,10 @@ class RefExampleGame extends FlameGame with HasComponentRef {
class RiverpodGameWidget extends ConsumerStatefulWidget {
const RiverpodGameWidget.readFromProvider({super.key})
: uninitialisedGame = null;
const RiverpodGameWidget.initialiseWithGame(
{super.key, required this.uninitialisedGame,});
const RiverpodGameWidget.initialiseWithGame({
super.key,
required this.uninitialisedGame,
});

final FlameGame Function(WidgetRef ref)? uninitialisedGame;

Expand Down
8 changes: 6 additions & 2 deletions lib/src/component_ref.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ class ComponentRef {
void Function(Object error, StackTrace stackTrace)? onError,
bool fireImmediately = true,
}) {
return _widgetRef.listenManual<T>(provider, onChange,
onError: onError, fireImmediately: fireImmediately,);
return _widgetRef.listenManual<T>(
provider,
onChange,
onError: onError,
fireImmediately: fireImmediately,
);
}

T read<T>(ProviderListenable<T> provider) {
Expand Down
19 changes: 14 additions & 5 deletions lib/src/has_component_ref_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ mixin HasComponentRef on Component {
await super.onLoad();
}

void listen<T>(ProviderListenable<T> provider, void Function(T?, T) onChange,
{void Function(Object error, StackTrace stackTrace)? onError,}) {
_subscriptions.add(ref.listenManual<T>(provider, (p0, p1) {
onChange(p0, p1);
}, onError: onError,),);
void listen<T>(
ProviderListenable<T> provider,
void Function(T?, T) onChange, {
void Function(Object error, StackTrace stackTrace)? onError,
}) {
_subscriptions.add(
ref.listenManual<T>(
provider,
(p0, p1) {
onChange(p0, p1);
},
onError: onError,
),
);
}

@override
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flame_riverpod
description: Model classes and an example project for using Riverpod in conjunction with Flame.
version: 4.0.0+1
version: 4.0.0+2
homepage: https://markvideon.dev

environment:
Expand Down

0 comments on commit e272502

Please sign in to comment.