Taxi Booking in Flutter - RideDetail dart

 Create a file named as 'RideDetail.dart' in Lib Folder and paste following code:


Create a Taxi Booking Project in flutter

Please, support my blog by clicking on our sponsors ad!



import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:myfirstproject/Dashboard.dart';
import 'package:myfirstproject/cards/areaspot_card.dart';
import 'package:myfirstproject/cards/location_card.dart';
import 'package:myfirstproject/common/bottomnavigationbar.dart';
import 'package:myfirstproject/common/constants.dart';
import 'package:myfirstproject/ViewModels/locationviewmodel.dart';
import 'package:provider/provider.dart';

class RideDetail extends StatefulWidget {
  const RideDetail({Key? key}) : super(key: key);
  @override
  RideDetailState createState() => RideDetailState();
}

class RideDetailState extends State {
  final LocationViewModel  locationViewModel = LocationViewModel();
  @override
  void initState()
  {
    locationViewModel.GetData();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(create: (context) => LocationViewModel(),
        child: Column(
          children: [
            Container( decoration: BoxDecoration(color: Colors.white),
                  child: Padding(
                    padding: const EdgeInsets.all(20.0),
                    child: Column(
                      children: [
                            Row(
                              children: [
                                IconButton(
                                  onPressed: () { Navigator.pop(context); },
                                  icon: Icon(FontAwesomeIcons.close),
                                  color: Navy,
                                ),
                                Expanded(child: Align(alignment: Alignment.center, child: Text("Where did you go today?", style: TextStyle(color: Navy, fontWeight: FontWeight.bold, fontSize: 15) )))
                              ],
                            ),
                            SizedBox(height: 20,),
                            Container( decoration: BoxDecoration(border: Border.all(color: Color(0XffF0F4F7)), color: Color(0XFFFDFEFF), borderRadius: BorderRadius.circular(10.0)),
                              child: Padding(
                                padding: const EdgeInsets.all(10.0),
                                child: Column(
                                  children: [Material(child: Container(child: TextField(decoration: const InputDecoration(hintText: 'Pickup', labelText: 'Drop off'),))),
                                   Material(child: Container(child: TextField(decoration: const InputDecoration(hintText: 'Drop off', labelText: 'Drop off'),))),
                                  ],
                                ),
                              )
                              ,
                            ),
                            SizedBox(height: 20,),
                            Align(alignment: Alignment.centerLeft,
                              child: Container(width: 150, decoration: BoxDecoration(border: Border.all(color: RegentGray), borderRadius: BorderRadius.circular(10.0)),
                              child: Row(
                                children: [
                                  IconButton(onPressed: (){}, icon: Icon(FontAwesomeIcons.circleArrowDown),iconSize: 15,),
                                  Text('Select on Map',style: TextStyle(color: Navy,fontSize: 15),)
                                ],
                              ),
                              ),
                            )

                      ],
                    ),
                  ),
                ),
            Consumer(builder:(context,viewModel,child)
            {
              viewModel = locationViewModel;
              if(viewModel == null)
              {
                return Expanded(
                  child: Container(
                    decoration: BoxDecoration(color: SecondaryColor),
                    child: Row(mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children:
                      [
                        Expanded(child: Align(alignment: Alignment.center,
                            child: Text('Bluefast is like a flying bird.',
                              style: TextStyle(color: Navy),)))
                      ],
                    ),
                  ),
                );
              }
              else
                {
                  return Expanded(
                      child: Container(decoration: BoxDecoration(color: SecondaryColor),
                        child: ListView.builder(padding: EdgeInsets.zero, scrollDirection: Axis.vertical,  itemCount: viewModel.locationList.length, itemBuilder: (context,index)
                  {
                    final location = viewModel.locationList[index];
                    return AreaSpotCard(locationModel: location);
                  },

              ),
                      ),);
                }
            })

          ],
        ));
  }
}

Go to Main project

Comments

Popular posts from this blog

Push Notifications in .NET MAUI: A Comprehensive Guide

Explore the UI libraries available for .NET MAUI at no cost.

Push Notification using Firebase in xamarin form (Android and IOS)