anyway/frontend/lib/modules/current_trip_save_button.dart
Remy Moll 2288a50b60
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 2m38s
Run linting on the backend code / Build (pull_request) Successful in 28s
Run testing on the backend code / Build (pull_request) Failing after 5m22s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 24s
Build and release debug APK / Build APK (pull_request) Failing after 3m29s
automatically save a trip when it is first created
2025-03-23 20:05:18 +01:00

53 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:anyway/main.dart';
import 'package:anyway/structs/trip.dart';
class saveButton extends StatefulWidget {
Trip trip;
saveButton({super.key, required this.trip});
@override
State<saveButton> createState() => _saveButtonState();
}
class _saveButtonState extends State<saveButton> {
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () async {
savedTrips.addTrip(widget.trip);
rootScaffoldMessengerKey.currentState!.showSnackBar(
SnackBar(
content: Text('Trip saved'),
duration: Duration(seconds: 2),
dismissDirection: DismissDirection.horizontal
)
);
},
child: SizedBox(
width: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.save,
),
Expanded(
child: Padding(
padding: EdgeInsets.only(left: 10, top: 5, bottom: 5, right: 5),
child: AutoSizeText(
'Save trip',
maxLines: 2,
),
),
),
],
),
)
);
}
}