This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| main(){ | |
| print(round(2.4)); | |
| print(round(2.1)); | |
| print(round(2.6)); | |
| print(round(2.8)); | |
| } | |
| double round(double num){ | |
| double decimal = double.parse((num - num.toInt()).toStringAsFixed(1)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| // ❌ Without Extension Function ❌ | |
| print(Countries.Cote_d_Ivoire.toString().split('.').last.replaceAll("_", " ")); // Cote d Ivoire | |
| print(Movies.Romance.toString().split('.').last.replaceAll("_", " ")); //Romance | |
| // ✅ With Extension Function ✅ | |
| print(Countries.Cote_d_Ivoire.enumValue); // Cote d Ivoire | |
| print(Movies.Romance.enumValue); //Romance | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| print(30.88922.withDecimalPoints(3)); //30.889 | |
| print(30.88922.withDecimalPointsFormatted(1)); //30.9 | |
| print(30.withDecimalPoints(3)); //30.0 | |
| print(30.withDecimalPointsFormatted(3)); //30.000 | |
| } | |
| extension DecimalPoints on num { | |
| double withDecimalPoints(int n) { | |
| return num.parse(this.toStringAsFixed(n)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: push | |
| name: Flutter CI | |
| jobs: | |
| build: | |
| name: Build and Test on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 10 | |
| strategy: | |
| matrix: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #If you are using zsh: | |
| echo "\nexport PATH="\$PATH:`pwd`/flutter/bin"">>~/.zshrc ; source ~/.zshrc | |
| #If you are using bash: | |
| echo "\nexport PATH="\$PATH:`pwd`/flutter/bin"">>~/.bashrc ; source ~/.bashrc | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:async'; | |
| import 'dart:io'; | |
| import 'package:synchronized/extension.dart'; | |
| main() async { | |
| var demo = Demo(); | |
| await demo.runSynchronized(); | |
| await demo.runNotSynchronized(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'package:flutter/rendering.dart'; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| debugShowCheckedModeBanner: false, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'package:flutter/rendering.dart'; | |
| void main() { | |
| runApp(App()); | |
| } | |
| class App extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| // 2,3,4,5,6,7,8,9,10 | |
| for (int i in 2.to(10)) { | |
| print(i); | |
| } | |
| // 2,3,4,5,6,7,8,9 | |
| for (int i in 2.until(10)) { | |
| print(i); | |
| } |