mirror of
https://github.com/hanskokx/arcane_framework.git
synced 2026-05-14 10:29:06 +02:00
Fixed a bug in the example
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
+26
-14
@@ -152,8 +152,11 @@ class _ArcaneLoggingExampleState extends State<ArcaneLoggingExample> {
|
|||||||
builder: (context, enabledFeatures, _) {
|
builder: (context, enabledFeatures, _) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Card(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 200,
|
height: MediaQuery.sizeOf(context).height / 2,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -186,6 +189,8 @@ class _ArcaneLoggingExampleState extends State<ArcaneLoggingExample> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -544,6 +549,11 @@ class ArcaneServicesExample extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final FavoriteColorService? service =
|
final FavoriteColorService? service =
|
||||||
ArcaneServiceProvider.serviceOfType<FavoriteColorService>(context);
|
ArcaneServiceProvider.serviceOfType<FavoriteColorService>(context);
|
||||||
|
final ValueNotifier<MaterialColor?> notifier =
|
||||||
|
service?.notifier ?? ValueNotifier(null);
|
||||||
|
return ValueListenableBuilder(
|
||||||
|
valueListenable: notifier,
|
||||||
|
builder: (context, color, _) {
|
||||||
return Card(
|
return Card(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
@@ -555,16 +565,8 @@ class ArcaneServicesExample extends StatelessWidget {
|
|||||||
"Services",
|
"Services",
|
||||||
style: Theme.of(context).textTheme.headlineSmall,
|
style: Theme.of(context).textTheme.headlineSmall,
|
||||||
),
|
),
|
||||||
ValueListenableBuilder(
|
Text(
|
||||||
valueListenable: ArcaneService.ofType<FavoriteColorService>(
|
|
||||||
context,
|
|
||||||
)?.notifier ??
|
|
||||||
ValueNotifier(null),
|
|
||||||
builder: (context, color, _) {
|
|
||||||
return Text(
|
|
||||||
color != null ? "Favorite color: ${color.name}" : "",
|
color != null ? "Favorite color: ${color.name}" : "",
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -587,7 +589,9 @@ class ArcaneServicesExample extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text('${service == null ? 'Register' : 'Remove'} service'),
|
child: Text(
|
||||||
|
'${service == null ? 'Register' : 'Remove'} service',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
@@ -604,7 +608,14 @@ class ArcaneServicesExample extends StatelessWidget {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
service?.setMyFavoriteColor(colors[index]);
|
if (service == null) {
|
||||||
|
Arcane.log(
|
||||||
|
"FavoriteColorService is not registered",
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
service.setMyFavoriteColor(colors[index]);
|
||||||
Arcane.log(
|
Arcane.log(
|
||||||
"Set a color in FavoriteColorService",
|
"Set a color in FavoriteColorService",
|
||||||
metadata: {
|
metadata: {
|
||||||
@@ -615,8 +626,7 @@ class ArcaneServicesExample extends StatelessWidget {
|
|||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: colors[index],
|
color: colors[index],
|
||||||
border: service?.myFavoriteColor?.name ==
|
border: color?.name == colors[index].name
|
||||||
colors[index].name
|
|
||||||
? Border.all(width: 2)
|
? Border.all(width: 2)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
@@ -637,5 +647,7 @@ class ArcaneServicesExample extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user