68 lines
1.8 KiB
Dart
68 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:gps/provider/gps_model.dart';
|
|
import 'package:gps/utils/environment.dart';
|
|
import 'package:gps/utils/gps_persister.dart';
|
|
import 'package:gps/utils/gps_utils.dart';
|
|
import 'package:gps/widgets/gps_position_widget_provider.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
void main() {
|
|
runApp(const GpsProviderApp());
|
|
}
|
|
|
|
class GpsProviderApp extends StatelessWidget {
|
|
const GpsProviderApp({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'GPS Demo',
|
|
theme: ThemeData(
|
|
primarySwatch: Colors.blue,
|
|
),
|
|
home: GpsDemo(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class GpsDemo extends StatelessWidget {
|
|
GpsDemo({Key? key}) : super(key: key);
|
|
|
|
final GpsPersister _storage = CsvGpsPersister(Environment.storageDir());
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('GPS Demo'),
|
|
),
|
|
body: ChangeNotifierProvider(
|
|
create: (_) => GpsModel(GpsUtils().stream),
|
|
child: Center(
|
|
child: Column(
|
|
children: [
|
|
const GpsPositionWidget(),
|
|
Consumer<GpsModel>(
|
|
builder: (context, model, child) => Row(
|
|
children: [
|
|
IconButton(
|
|
onPressed: () => model.toggleRecording(),
|
|
icon: Icon(model.isRecording
|
|
? Icons.stop
|
|
: Icons.fiber_manual_record),
|
|
tooltip: model.isRecording ? "Stop Recording" : "Record",
|
|
),
|
|
IconButton(
|
|
onPressed: () => model.save(_storage),
|
|
icon: const Icon(Icons.save),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
],
|
|
)),
|
|
),
|
|
);
|
|
}
|
|
}
|