GithubHelp home page GithubHelp logo

vandadnp / flutter-tips-and-tricks Goto Github PK

View Code? Open in Web Editor NEW
6.8K 286.0 1.1K 429.77 MB

A Collection of Flutter and Dart Tips and Tricks

Home Page: https://linktr.ee/vandadnp

Dart 100.00%
flutter dart flutter-ui

flutter-tips-and-tricks's Introduction

Table of Contents

Usage

Click on any of the tips/tricks above to get to their source-code/infographic and demo videos (if applicable)

License

Copyright 2022 @ Vandad Nahavandipoor

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

flutter-tips-and-tricks's People

Contributors

vandadnp avatar

Stargazers

Ramin Daqiq avatar 박영수 avatar joe ward avatar Muhammad Osama Noor avatar  avatar  avatar Emmanuel Holonou avatar Amr Samy avatar Huzaifa Yasin avatar Eshan Rubbani avatar  avatar Himanshu Soni avatar He Linming avatar Ahmed Adnan avatar Ryan Wang avatar Richard Oppong avatar Belabied Redouane avatar  avatar Crishop avatar  avatar Harshit Khandelwal avatar Ali farhad avatar  avatar Ahmed Adel avatar chetan rawat avatar Salar Pro avatar  avatar Praveen Kumar avatar  avatar Abinash Karki avatar Paulius Greičiūnas avatar Keannu Gran avatar Loup Mayeur avatar Mewo avatar Mudar Najjar avatar zeX514 avatar Max avatar Mohamed Ahmed avatar shishir sapkota avatar Amr Tawfik avatar Letters avatar icxldd avatar wuwenjie avatar Tirguy avatar Hai Nguyen H. P avatar YellowBean avatar Mahmoud Hafez Eltarqi avatar Phantom II avatar Ayoub BOUDARGA avatar  avatar Sibil Rahman avatar Juzuli M P avatar SilentBluer avatar Fajla Rabby avatar Autumn avatar MoonDev avatar Calcifer P avatar  avatar Anant avatar r avatar Hsungjin avatar Sakib avatar ‪Yousef Sobhy‬‏ avatar Katlego Barayi avatar Rushikesh Chaudhari avatar Batuhan Selek avatar Anthony Beato Abreu avatar Atharva Jayant Paradkar avatar Bavley Adel avatar Bayu Nugroho avatar Christian Galeone avatar Abdillah Haidar avatar Mehmet Peker avatar Shayan Poursadeghi avatar Ekrem Bayram avatar  avatar  avatar  avatar Sherif Alabi  avatar Victor Pereira avatar Paul Zarudnev avatar gama avatar Abraham Herrera avatar Profile avatar Mateusz Basiaga avatar Vedant Kothari avatar mortza mansory avatar Chetan Vaghela avatar Andrei Polushin avatar  avatar Paul avatar Aidar avatar ataballyyev avatar Ahmad Abu Hasan avatar Mustafa Kara avatar Muhammad Usman avatar Tuğrul Altun avatar Yiğit Tanrıverdi avatar To why lieter→ avatar Kermit White avatar

Watchers

buyaka avatar Maciej Kuś avatar Solli Moreira Honorio avatar Milad Nekofar avatar Abdelouahab Djoudi avatar Gad D Lord avatar Zlati Pehlivanov avatar ipfans avatar Serhii Hanzii avatar Vladimir Minkin avatar Keith D Commiskey avatar mitien avatar Wawan avatar Ricardo da Silva Ogliari avatar Loïc Sharma avatar senthilkumar avatar  avatar James Cloos avatar Kanybek Momukeev avatar MohsinAli avatar Vinh Nguyen avatar Elijah Bee avatar  avatar Klemen Tusar avatar Bai Loong avatar akbarwibawa avatar Joseh-Henrique avatar Vongsi avatar  avatar Hank G avatar  avatar Rafael G Tejeda avatar  avatar Jianwu Gao avatar Emerson Siega avatar Nathaniel Ashiagbor avatar trashcoder avatar Tuna Aras avatar Eren ŞİMŞEK avatar Ali Seyedabadi avatar Aby Mathew avatar Auré-Chan avatar Nacuta Claudiu avatar Fitri Wibowo avatar Ahmed Wahdan avatar Muruganandham K avatar Sun avatar  avatar Willesmar avatar Marciomacdev avatar Thiago Coelho avatar Mario Uriarte avatar  avatar Dirceu de Medeiros Teixeira avatar James avatar Babar Bashir avatar Friedhold Matz avatar Hoang Phan avatar BlackKnight avatar Popeye Lau avatar madroid avatar masashi-sutou avatar Achim Schlemmer avatar Fernando Franzim avatar mazenalhomsie avatar julytian avatar Mrinal Jain avatar Loi PT avatar Rodrigo Felipe avatar tiny Flutter team avatar  avatar Dharmesh Vaghani avatar Matías Irland avatar  avatar Saabir avatar  avatar S.Shahini avatar Tembo avatar Đặng Ngọc Đức avatar Ariel Ferreiro Diaz avatar Estiak ahamed avatar RuiXI avatar Tiago Storch de Almeida avatar Nebi Sarigul avatar Jaroslav Bien avatar Mohamed Dernoun avatar Vaniot avatar Phương Nguyễn avatar oldbird avatar Akash Singh avatar riderofzion avatar TheodoreQiu avatar TRAN VAN TOAN avatar Shun Min Chang avatar Andrei Pericleanu avatar  avatar GM Nazmul Hossain avatar Pascal Stech avatar LiuYipeng avatar  avatar

flutter-tips-and-tricks's Issues

Tip 196: Error Handling Value Passing

About https://github.com/vandadnp/flutter-tips-and-tricks/tree/main#future-error-handling-in-dart

Maybe a note would be helpful, to use that with caution. The creation of the error-value could be expensive and with your approach, I would create that object all the time, even if I don't need it. That is the reason, as far as I know, to pass a creation function into it. Just my thought to avoid bad designs for newcomers to dart.

Thanks for all your tips, I like it a lot.

Integer range optimization

Hi. The extension method to could be made more optimized or idiomatic (since its return type is declared as Iterable) by avoiding unnecessary array creation. The code won't be as pretty though 😃

extension To on int {
Iterable<int> to(int other, [bool inclusive = true]) => other > this
? [for (int i = this; i < other; i++) i, if (inclusive) other]
: [for (int i = this; i > other; i--) i, if (inclusive) other];
}

vs

extension To on int {
  Iterable<int> to(int other, [bool inclusive = true]) sync* {
    if (other > this) {
      for (int i = this; i < other; i++) yield i;
    } else {
      for (int i = this; i > other; i--) yield i;
    }

    if (inclusive) yield other;
  }
}

Add the update to the release description

Hey! Thanks for a very cool repo ✌️

Would be nice if the release message contained the tip itself or at least a link to the new section. So if I see the release in the feed, I could just read it by entering the release page.

Can't access the tips and tricks anymore using the normal url

Hello Vandad, that's for creating such a useful project. I've been playing around with loading the tips and trick in the terminal for a while now using this method Flutter Tips and Tricks in Terminal but just now the link doesn't show all the images and dart code just the .md files. Is there a new method to get each tip with its image and source code now? I'm creating an open source app using this repo and would really like it to work out.

I also can't get the dart files now, https://raw.githubusercontent.com/vandadnp/flutter-tips-and-tricks/main/tipsandtricks/implementing-zip-and-tuples-in-dart/implementing-zip-and-tuples-in-dart.dart This like gives me a 404 error. But I can access the .jpg freely.

extension OrDefault<T> on T does not work

As suggested at https://github.com/vandadnp/flutter-tips-and-tricks/blob/main/tipsandtricks/default-value-for-optionals-in-dart/default-value-for-optionals-in-dart.md

I declared:

extension OrDefault<T> on T {
  T get orDefault {
    final value = this;
    if (value == null) {
      return {
        int: 0,
        String: '',
        double: 0.0,
        num: 0,
        bool: false,
        Map: {},
        List: [],
        Set: {},
      }[T] as T;
    } else {
      return value;
    }
  }
}

  test('Test ObjectExtension.orDefault()', () async {
    const int? nullInt = null;
    expect(nullInt.orDefault, 0); // fails since T is int? and returns null instead of 0.
  });

Null-Aware Infix Operators in Dart - likely unneeded code on line "return shadow + (other ?? 0) as T"

RE: https://github.com/vandadnp/flutter-tips-and-tricks/blob/main/tipsandtricks/null-aware-infix-operators-in-dart/null-aware-infix-operators-in-dart.md

Having:

T? operator +(final T? other) {
  final shadow = this;
  if (shadow != null) {
    return shadow + (other ?? 0) as T;
  } else {
    return null;
  }
}

and the test:

test('Test null + operator', () {
    int? var1;
    var1++;
    var1 += 1;
    var1 = var1 + 1;
    var1 = 2;
    var1++;
    var1 += 1;
    var1 = var1 + 1;
    expect(var1, 5);
}

The test runs successfully but with code coverage we can see that the line

return shadow + (other ?? 0) as T;

never gets called which leads me to the speculation that shadow always equals to NULL when the extension is called and the extension is not "attached" if T is not null.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.