To implement this functionality, follow these steps:
- Add a new file to your project, calling it navigation_dialog.dart.
- Add the following code to the navigation_dialog.dart file:
import 'package:flutter/material.dart';
class NavigationDialog extends StatefulWidget {
@override
_NavigationDialogState createState() => _NavigationDialogState();
}
class _NavigationDialogState extends State<NavigationDialog> {
Color color = Colors.blue[700];
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: color,
appBar: AppBar(
title: Text('Navigation Dialog Screen'),
),
body: Center(
child: ElevatedButton(
child: Text('Change Color'),
onPressed: () {
}),
),
);
}
- Now create the asynchronous method that will return the chosen color, calling it showColorDialog, and marking it as async:
_showColorDialog(BuildContext...