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
| abstract final class UtilFunctions { | |
| static bool compareQueries(String value, String query) { | |
| final String formattedValue = value.trim().toLowerCase(); | |
| final List<String> queryWords = query.split(' '); | |
| if (queryWords.length == 1) { | |
| return formattedValue.contains(query.trim().toLowerCase()); | |
| } | |
| bool hasMatch = false; | |
| for (String queryWord in queryWords) { | |
| hasMatch = formattedValue.contains(queryWord.trim().toLowerCase()); |
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/widgets.dart'; | |
| typedef CustomAnimationBuilderCallback = Widget Function( | |
| BuildContext context, | |
| double value, | |
| Widget? child, | |
| ); | |
| class CustomAnimationBuilder extends StatefulWidget { | |
| final Duration duration; |
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'; | |
| /// A mixin for adding timer to state or screens | |
| ///e.g when there's a reset password otp timer | |
| /// | |
| /// Add it to your immutable state class like so: | |
| /// class PasswordState extends AuthState with TimerMixin { | |
| /// ... | |
| /// | |
| /// @override |
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('compute line height ${computeTextSizeFromText(''' | |
| font-family: Poppins; | |
| font-size: 25px; | |
| font-weight: 500; | |
| line-height: 38px; | |
| letter-spacing: 0em; | |
| text-align: left; | |
| ''')}',); |
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('compute line height ${computeTextSizeFromText(''' | |
| font-family: Poppins; | |
| font-size: 25px; | |
| font-weight: 500; | |
| line-height: 38px; | |
| letter-spacing: 0em; | |
| text-align: left; | |
| ''')}',); |
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'; | |
| class AllowPointer extends SingleChildRenderObjectWidget { | |
| const AllowPointer({ | |
| super.key, | |
| this.allowing = true, | |
| this.ignoringSemantics, | |
| super.child, | |
| }); |
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
| // ignore_for_file: lines_longer_than_80_chars | |
| import 'dart:async'; | |
| import 'dart:math' as math; | |
| import 'package:flutter/foundation.dart'; | |
| import 'package:flutter/gestures.dart'; | |
| import 'package:flutter/material.dart' hide ScrollableState; | |
| import 'package:flutter/rendering.dart'; | |
| import 'package:flutter/scheduler.dart'; |
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/gestures.dart'; | |
| import 'package:flutter/material.dart'; | |
| ///copied and modified from [stackoverflow](https://stackoverflow.com/questions/76155321/how-can-i-recognize-two-fingers-on-the-screen-in-flutter/76156071?noredirect=1#comment134304616_76156071) | |
| class NPointerSingleChildScrollView extends StatefulWidget { | |
| final int numberOfPointers; | |
| final Axis scrollDirection; | |
| final bool reverse; | |
| final EdgeInsetsGeometry? padding; |
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() { | |
| listPatternExample(); | |
| mapPatternExample(); | |
| recordPatternExample(); | |
| print(switchExpressionExample()); | |
| print(complexSwitchExpressionExample()); | |
| variablePatternExample(); | |
| nullPatternExample(); | |
| castPatternExample(); | |
| patternInConditions(); |
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
| Color interpolateColors(double value, List<Color> colors) { | |
| assert(value >= 0 || value <= 1, 'value must be between 0 and 1'); | |
| final int colorListLength = colors.length - 1; | |
| final int maxExpectedIndex = (colorListLength * value).ceil(); | |
| final int minExpectedIndex = (colorListLength * value).floor(); | |
| final Color minColor = colors[minExpectedIndex]; | |
| final Color maxColor = colors[maxExpectedIndex]; |
NewerOlder