Flutter package and sample app to calculate Flight CO2 emissions

Overview

Flight CO2 Calculator

About

This plugin provides a collection of classes that can be used to:

  • Load a list of airports from the OpenFlights.org dataset.
  • Lookup airports matching a search query against the entire data-set of airports.
  • Calculate the distance and CO2 emissions from flights.

What you can do with this

Build a Flight CO2 Calculator app such as this:

How to use it

Load data:

List<Airport> airports = await AirportDataReader.load('data/airports.dat');

Create an AirportLookup service:

final airportLookup = AirportLookup(airports: airports);

Search for airports matching a query:

List<Airport> results = airportLookup.searchString(query);

Calculate distance and CO2 emissions:

class FlightCalculationData {
  FlightCalculationData({this.distanceKm, this.co2e});
  final double distanceKm;
  final double co2e;
}

FlightCalculationData _calculate(FlightDetails flightDetails) {
  double distanceKm;
  double co2e;
  Airport departure = flightDetails.departure;
  Airport arrival = flightDetails.arrival;
  if (departure != null && arrival != null) {
    double multiplier =
        flightDetails.flightType == FlightType.oneWay ? 1.0 : 2.0;
    distanceKm = DistanceCalculator.distanceInKmBetween(
        departure.location, arrival.location);
    distanceKm = CO2Calculator.correctedDistanceKm(distanceKm);
    co2e =
        CO2Calculator.calculateCO2e(distanceKm, flightDetails.flightClass) *
            multiplier;
  }
  return FlightCalculationData(distanceKm: distanceKm, co2e: co2e);
}

Example

See the sample Flight CO2 Calculator app bundled with the project in the example folder.

License: MIT

You might also like...

Flutter sample app using MLKit Vision API for text recognition

Flutter sample app using MLKit Vision API for text recognition

Flutter ML Kit Vision This a sample Flutter app integrated with the ML Kit Vision API for recognition of email addresses from an image. NOTE: The ML K

Oct 12, 2022

Flutter Video Conferencing SDK & Sample App

Flutter Video Conferencing SDK & Sample App

100ms Flutter SDK 🎉 Here you will find everything you need to build experiences with video using 100ms iOS/Android SDK. Dive into our SDKs, quick sta

Dec 22, 2022

A sample flutter app with mock API for movie details

A sample flutter app with mock API for movie details

movie_app A new Flutter project. screenshots Getting Started This project is a starting point for a Flutter application. A few resources to get you st

Oct 25, 2022

A sample app to showcase signin-signup UI demo using clippers in flutter

A sample app to showcase signin-signup UI demo using clippers in flutter

flutter_signin_signup A sample app to showcase signin-signup UI demo using clippers in flutter. Screenshots Login Register Pull Requests I welcome and

Nov 3, 2022

A sample app that implement Uncle Bob's Clean Architecture in Flutter

A sample app that implement Uncle Bob's Clean Architecture in Flutter

Clean Architecture for Flutter This a sample app that implement Uncle Bob's Clea

Nov 8, 2022

Sample app for Fullscale Learning - Flutter

notes_sample A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if

Dec 23, 2021

App can detect COVID via X-Ray image, just use some sample image available in the listed links.

App can detect COVID via X-Ray image, just use some sample image available in the listed links.

Covid19detector : Detecting COVID-19 from X-Ray 😮 App can detect COVID via X-Ray image, just use some sample image available in the listed links. And

Jun 14, 2022

Sample Horoscope app for Sirius 2021.

Astrology magic Идея Идея сделать гороскоп ришла к нам после того, как мы решили проверить нашу совместимость в работе. Тогда мы обнаружили, что не су

Jan 30, 2022

A sample application to show Paytm Flutter Clone.

A sample application to show Paytm Flutter Clone.

Flutter Paytm UI Demo A sample application to show Paytm Flutter Clone. Demo Android Screen iOS Screen Getting Started This project is a starting poin

Sep 27, 2022
Comments
  • The getter 'controller' isn't defined for the class 'BehaviorSubject'.

    The getter 'controller' isn't defined for the class 'BehaviorSubject'.

    I get following error. Any idea how to fix it? Thanks

    "flight_details_bloc.dart", "severity": 8, "message": "The getter 'controller' isn't defined for the class 'BehaviorSubject'.\nTry importing the library that defines 'controller', correcting the name to the name of an existing getter, or defining a getter or field named 'controller'.", "source": "dart", "startLineNumber": 124, "startColumn": 53, "endLineNumber": 124, "endColumn": 63, "tags": []

    opened by sat12341234 1
  • Images only of one resolution

    Images only of one resolution

    This is more of a question than an issue, I noticed you have included only one resolution image, I wonder how come your app did not get rejected on the AppStore. Not all iPhones use same resolution images. Or did you use different resolution images and not included in this GitHub repo. Can you please guide me how to include different resolution image and how to include them in pubspec.yaml

    opened by PritishSawant 0
Owner
Andrea Bizzotto
Flutter GDE ❖ Creator of codewithandrea.com ❖ YouTube: nnbd.me/yt ❖ Complete Dart Course: nnbd.me/dart
Andrea Bizzotto
Flutter app to calculate percentages

An app made in Flutter to quickly calculate percentage differences in stock prices. Additional buttons to quickly determine what the price would need to reach to get that percentage.

null 0 Jul 21, 2022
Calculate your pizza recipe in a few seconds! 🍕

Calcolapizza Calcolapizza lets you calculate the exact recipe for your pizza doughs in a few seconds. Set how many dough balls you want to make, their

Domenico Majorana 44 Dec 26, 2022
a sample flutter app using Injection, routing and simple authentication follows clean code and best practices

Flutter Clean Project A sample flutter app using Injection, routing and simple authentication follows clean code and best practices Features Cleaned f

Moez Shakeri 12 Jan 2, 2023
Flutter classified app - A sample app to showcase classified app using flutter

Flutter Classified App Demo A sample app to showcase classified app using flutter. Demo Android Screen iOS Screen Getting Started This project is a st

FlutterDevs 271 Dec 27, 2022
A sample application that allows a user to upload and share images, made with Flutter and Firebase

FlutterFire Gallery A sample Flutter app to upload images and share them via lin

Mais Alheraki 9 Oct 29, 2022
Sample Flutter Drawing App which allows the user to draw onto the canvas along with color picker and brush thickness slider.

DrawApp Sample Flutter Drawing App which allows the user to draw onto the canvas along with color picker and brush thickness slider. All code free to

Jake Gough 226 Nov 3, 2022
A quick sample app on how to implement a friend list and a profile page in Flutter.

FlutterMates All code resides in the /lib folder: there's no Android / iOS specific code needed. The article, slides and how this came to be, is here.

Codemate Ltd 526 Dec 29, 2022
Sample app to demonstrate the integration and working of Dyte SDK for mobile, using Flutter.

Flutter Sample App by dyte Sample App to demonstrate Dyte SDK in flutter Explore the docs » View Demo · Report Bug · Request Feature Table of Contents

Dyte 12 Jan 1, 2023
This repository is a sample app for learning TDD and clean architecture in action!

flutter_weather_app_sample A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get y

Aditya Rohman 71 Jan 1, 2023
DoneIt is a sample note app 📝 Flutter application 📱 built to demonstrate use of Clean Architecture tools. Dedicated to all Flutter Developers with ❤️.

DoneIt ?? DoneIt is a sample note app ?? Flutter application ?? built to demonstrate use of Clean Architecture tools. Dedicated to all Flutter Develop

Shubham Chhimpa 175 Dec 24, 2022