Custom Pages
Add a custom page widget to the client runtime.
When to use this
How it works
Build a custom page
Last updated
Add a custom page widget to the client runtime.
Last updated
import 'package:flutter/material.dart';
import '../../models/app_view.dart';
class CustomChartView extends StatelessWidget {
final AppView view;
const CustomChartView({required this.view, Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
// Example: treat view.config['values'] as a List<num>
final values = (view.config?['values'] as List?)?.cast<num>() ?? [3, 8, 5];
final maxValue = values.isEmpty
? 1
: values.reduce((a, b) => a > b ? a : b).toDouble();
return SizedBox(
height: 160,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: values.map((v) {
final height = (v.toDouble() / maxValue) * 120;
return Expanded(
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 4),
height: height,
color: Colors.blueAccent,
),
);
}).toList(),
),
);
}
}Widget buildViewWidget(AppView view) {
switch (view.type) {
// ... other view types.
case 'custom_chart':
return CustomChartView(view: view);
default:
return const Placeholder();
}
}{ "values": [3, 8, 5] }