Taxi Booking in Flutter - Dashboart.dart

 Create a file named as 'Dashboard.dart' in LibFolder 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:flutter/scheduler.dart';
import 'package:myfirstproject/RideDetail.dart';
import 'package:myfirstproject/ViewModels/locationviewmodel.dart';
import 'package:myfirstproject/cards/location_card.dart';
import 'package:provider/provider.dart';
import 'common/constants.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'common/bottomnavigationbar.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(create: (context) => LocationViewModel(),
    child: CommonWrapper(
     currentContent : Column(
        children: [
          Container(decoration: BoxDecoration(color: PrimaryColor,),
            child: Padding(
              padding: const EdgeInsets.all(20.0),
              child: Column(
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                     const Column(
                       mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                           Text(
                             textAlign: TextAlign.left,
                            'Blufast',
                            style: TextStyle(color: Colors.white),
                          ),
                          Text(
                            textAlign: TextAlign.left,
                            "Ride in minutes!",
                            style: TextStyle(color: Colors.white),
                          ),
                        ],
                      ),
                      Expanded(
                          child: Align(
                        alignment: Alignment.centerRight,
                        child: Container(
                          width: 80,
                          height: 37,
                          decoration: BoxDecoration(
                            border: Border.all(color: Colors.white),
                            color: PrimaryColor,

                            borderRadius: BorderRadius.circular(20.0),
                          ),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              IconButton(
                                icon: const Icon(Icons.menu),
                                onPressed: () {},
                                color: Colors.white,
                                iconSize: 20,
                              ),
                              const CircleAvatar( backgroundImage:NetworkImage("https://cdn-icons-png.flaticon.com/512/219/219969.png")  , radius: 15,)
                            ],
                          ),
                        ),
                      ))
                    ],
                  ),
                  SizedBox(height: 20,),
                  InkWell( onTap: () {Navigator.push(context, MaterialPageRoute(builder: (context) => const RideDetail()));},
                    child: Container(
                      width: double.infinity,
                      height: 100,
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(20.0),
                        color: Colors.white,
                      ),
                      child:  Padding(
                        padding: EdgeInsets.all(20.0),
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Text('Where did you go today?', style: TextStyle(color: Colors.black),),
                            Row(
                              children: [
                                IconButton(icon: Icon(FontAwesomeIcons.arrowCircleRight), onPressed: () {  },iconSize: 20, color: PrimaryColor,),
                                Text('Find the location', style: TextStyle(color: Colors.grey),)
                              ],
                            )
                          ],
                        ),
                      ),
                    ),
                  ),
                  SizedBox(height: 20.0),
                  Row(
                    children: [
                      Container(
                        decoration: BoxDecoration(borderRadius: BorderRadius.circular(10.0),border: Border.all(color: Colors.white)),
                        child: Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: Row(
                            children: [
                              IconButton(onPressed: () {}, icon:Icon( FontAwesomeIcons.home),color: Colors.white,),
                              Text('Home',style: TextStyle(color: Colors.white),),
                            ],
                          ),
                        ),
                      ),
                      SizedBox(width: 20.0,),
                      Container(
                        decoration: BoxDecoration(borderRadius: BorderRadius.circular(10.0),border: Border.all(color: Colors.white)),
                        child: Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: Row(
                            children: [
                              IconButton(onPressed: () {}, icon:Icon( FontAwesomeIcons.building),color: Colors.white,),
                              Text('Office',style: TextStyle(color: Colors.white),),
                            ],
                          ),
                        ),
                      ),
                      SizedBox(width: 20.0,),
                      Container(
                        decoration: BoxDecoration(borderRadius: BorderRadius.circular(10.0),border: Border.all(color: Colors.white)),
                        child: Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: Row(
                            children: [
                              IconButton(onPressed: () {}, icon:Icon( FontAwesomeIcons.film),color: Colors.white,),
                              Text('Others',style: TextStyle(color: Colors.white),),
                            ],
                          ),
                        ),
                      ),
                    ],
                  )
                ],
              ),
            ),
          ),
          Container(
              child: Padding(
                padding: const EdgeInsets.all(20.0),
                child: Column(
                  children: [
                    Container(decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(20.0)),
                      child: Padding(
                        padding: const EdgeInsets.all(20.0),
                        child: Row(
                          children: [
                            IconButton(onPressed: () {}, icon: Icon(FontAwesomeIcons.universalAccess),color: PrimaryColor, iconSize: 20,),
                            SizedBox(width: 10,),
                            Column(
                              mainAxisAlignment: MainAxisAlignment.start,
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Text('Safe+ only \$ 1. Join now!', style: TextStyle(color: Colors.black, fontSize: 15 ),),
                                Text('Compensation guarantee for you', style: TextStyle(color: Colors.black,fontSize: 10),),
                              ],
                            ),
                            Expanded(child:
                              Align(alignment: Alignment.centerRight,
                               child: IconButton(onPressed: () {}, icon: Icon(FontAwesomeIcons.angleRight),color: PrimaryColor, iconSize: 20,))),

                          ],
                        ),
                      ),
                    ),
                  ],
                ),
              ),
          ),
          Padding(
            padding: const EdgeInsets.all(20),
            child: Row(
              children: [
                Text('Popular Near', style: TextStyle(fontSize: 20, color: Colors.black, fontWeight: FontWeight.bold),),
                Expanded(child: Align(alignment: Alignment.centerRight, child: Text('See all', style: TextStyle(color: RegentGray),)))
              ],
            ),
          ),
          Consumer(builder: (context, viewModel, child)
          {
            viewModel = locationViewModel;
            if(viewModel == null)
             {
               return Text('No data available!!!');
             }
           else
             {
               return Expanded(
                 child: ListView.builder( scrollDirection: Axis.horizontal,  itemCount: viewModel.locationList.length, itemBuilder: (context,index)
                 {
                   final location = viewModel.locationList[index];
                   return LocationCard(locationModel: location);
                 }
                 ),
               );
             }
          })
        ],
      ),
    )
    );
  }
}

Go to Main project

Comments

Popular posts from this blog

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

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

School UI Design using xamarin form