android and windows targets

This commit is contained in:
yves committed 2026-11-07 15:48:01 +01:00
1 parent c069b8945d
commit 1d974b42a1
58 files changed
+2601 -111

No files matched your search

+62 -56
View File
@@ -4,7 +4,7 @@ import 'package:cesiumjs/cesiumjs.dart';
/// Optional Cesium ion token (https://ion.cesium.com/tokens), injected at
/// build time so it never lands in source control:
/// flutter run -d linux --dart-define-from-file=cesium_ion.json
/// flutter run --dart-define-from-file=cesium_ion.json
/// (see cesium_ion.example.json). Without it the demo uses OpenStreetMap
/// imagery and an ellipsoid globe.
const String ionToken = String.fromEnvironment('CESIUM_ION_TOKEN');
@@ -138,9 +138,58 @@ class _DemoPageState extends State<DemoPage> {
Widget build(BuildContext context) {
final ready = _controller.isReady;
const hasToken = ionToken != '';
// Phones: the side panel becomes a drawer.
final narrow = MediaQuery.sizeOf(context).width < 700;
final panel = ListView(
children: [
for (final p in _places)
ListTile(
dense: true,
leading: const Icon(Icons.place_outlined),
title: Text(p.name),
enabled: ready,
onTap: () {
if (narrow) Navigator.of(context).pop(); // close the drawer
_goTo(p);
},
),
const Divider(),
const ListTile(dense: true, title: Text('Orthophoto / fond')),
RadioGroup<CesiumImagery>(
groupValue: _imagery,
onChanged: (v) {
if (ready && v != null) _controller.setImagery(v);
},
child: Column(
children: [
for (final i in CesiumImagery.values)
RadioListTile<CesiumImagery>(
dense: true,
value: i,
enabled: ready && (i != CesiumImagery.ionAerial || hasToken),
title: Text(i.label),
),
],
),
),
SwitchListTile(
dense: true,
title: const Text('MNT (Cesium World Terrain)'),
value: _terrain,
onChanged: ready && hasToken ? _controller.setTerrain : null,
),
],
);
final viewer = CesiumViewer(
ionToken: hasToken ? ionToken : null,
controller: _controller,
onMessage: _onMessage,
onError: (e) => setState(() => _status = 'Error: $e'),
);
return Scaffold(
drawer: narrow ? Drawer(child: SafeArea(child: panel)) : null,
appBar: AppBar(
title: const Text('CesiumJS in Flutter (Linux / WebKitGTK)'),
title: const Text('CesiumJS in Flutter'),
actions: [
IconButton(
tooltip: 'Clear markers',
@@ -164,66 +213,23 @@ class _DemoPageState extends State<DemoPage> {
),
],
),
body: Row(
children: [
SizedBox(
width: 230,
child: ListView(
body: narrow
? viewer
: Row(
children: [
for (final p in _places)
ListTile(
dense: true,
leading: const Icon(Icons.place_outlined),
title: Text(p.name),
enabled: ready,
onTap: () => _goTo(p),
),
const Divider(),
const ListTile(dense: true, title: Text('Orthophoto / fond')),
RadioGroup<CesiumImagery>(
groupValue: _imagery,
onChanged: (v) {
if (ready && v != null) _controller.setImagery(v);
},
child: Column(
children: [
for (final i in CesiumImagery.values)
RadioListTile<CesiumImagery>(
dense: true,
value: i,
enabled:
ready &&
(i != CesiumImagery.ionAerial || hasToken),
title: Text(i.label),
),
],
),
),
SwitchListTile(
dense: true,
title: const Text('MNT (Cesium World Terrain)'),
value: _terrain,
onChanged: ready && hasToken ? _controller.setTerrain : null,
),
SizedBox(width: 230, child: panel),
Expanded(child: viewer),
],
),
),
Expanded(
child: CesiumViewer(
ionToken: hasToken ? ionToken : null,
controller: _controller,
onMessage: _onMessage,
onError: (e) => setState(() => _status = 'Error: $e'),
),
),
],
),
bottomNavigationBar: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
color: Theme.of(context).colorScheme.surfaceContainer,
child: Text(
'$_status $_camera',
style: Theme.of(context).textTheme.bodySmall,
child: SafeArea(
top: false,
child: Text(
'$_status $_camera',
style: Theme.of(context).textTheme.bodySmall,
),
),
),
);