- create auth, main shell, home, profile, notifications and settings modules.
- added navigation, utils, design system and shared packages - implemented go router in entiered app - implemented flutter riverpod instead provider
This commit is contained in:
31
packages/utils/.gitignore
vendored
Normal file
31
packages/utils/.gitignore
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# Miscellaneous
|
||||
*.class
|
||||
*.log
|
||||
*.pyc
|
||||
*.swp
|
||||
.DS_Store
|
||||
.atom/
|
||||
.buildlog/
|
||||
.history
|
||||
.svn/
|
||||
migrate_working_dir/
|
||||
|
||||
# IntelliJ related
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# The .vscode folder contains launch configuration and tasks you configure in
|
||||
# VS Code which you may wish to be included in version control, so this line
|
||||
# is commented out by default.
|
||||
#.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
|
||||
/pubspec.lock
|
||||
**/doc/api/
|
||||
.dart_tool/
|
||||
.flutter-plugins-dependencies
|
||||
/build/
|
||||
/coverage/
|
||||
10
packages/utils/.metadata
Normal file
10
packages/utils/.metadata
Normal file
@@ -0,0 +1,10 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: "adc901062556672b4138e18a4dc62a4be8f4b3c2"
|
||||
channel: "stable"
|
||||
|
||||
project_type: package
|
||||
3
packages/utils/CHANGELOG.md
Normal file
3
packages/utils/CHANGELOG.md
Normal file
@@ -0,0 +1,3 @@
|
||||
## 0.0.1
|
||||
|
||||
* TODO: Describe initial release.
|
||||
1
packages/utils/LICENSE
Normal file
1
packages/utils/LICENSE
Normal file
@@ -0,0 +1 @@
|
||||
TODO: Add your license here.
|
||||
39
packages/utils/README.md
Normal file
39
packages/utils/README.md
Normal file
@@ -0,0 +1,39 @@
|
||||
<!--
|
||||
This README describes the package. If you publish this package to pub.dev,
|
||||
this README's contents appear on the landing page for your package.
|
||||
|
||||
For information about how to write a good package README, see the guide for
|
||||
[writing package pages](https://dart.dev/tools/pub/writing-package-pages).
|
||||
|
||||
For general information about developing packages, see the Dart guide for
|
||||
[creating packages](https://dart.dev/guides/libraries/create-packages)
|
||||
and the Flutter guide for
|
||||
[developing packages and plugins](https://flutter.dev/to/develop-packages).
|
||||
-->
|
||||
|
||||
TODO: Put a short description of the package here that helps potential users
|
||||
know whether this package might be useful for them.
|
||||
|
||||
## Features
|
||||
|
||||
TODO: List what your package can do. Maybe include images, gifs, or videos.
|
||||
|
||||
## Getting started
|
||||
|
||||
TODO: List prerequisites and provide or point to information on how to
|
||||
start using the package.
|
||||
|
||||
## Usage
|
||||
|
||||
TODO: Include short and useful examples for package users. Add longer examples
|
||||
to `/example` folder.
|
||||
|
||||
```dart
|
||||
const like = 'sample';
|
||||
```
|
||||
|
||||
## Additional information
|
||||
|
||||
TODO: Tell users more about the package: where to find more information, how to
|
||||
contribute to the package, how to file issues, what response they can expect
|
||||
from the package authors, and more.
|
||||
4
packages/utils/analysis_options.yaml
Normal file
4
packages/utils/analysis_options.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
91
packages/utils/lib/src/size_utils.dart
Executable file
91
packages/utils/lib/src/size_utils.dart
Executable file
@@ -0,0 +1,91 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MainConstants {
|
||||
static const double minWebAppRatio = 9.0 / 21.0;
|
||||
static const double maxWebAppRatio = 9.0 / 18.0;
|
||||
}
|
||||
|
||||
/// Utils for dynamic sizes
|
||||
class SizeUtils {
|
||||
static double height = 0.0;
|
||||
static double width = 0.0;
|
||||
static double physicalHeight = 0.0;
|
||||
static double physicalWidth = 0.0;
|
||||
|
||||
// Real value of aspect ratio height obtained through the display itself and not from calculating using the height and width
|
||||
static double aspectRatioWidth = 9;
|
||||
static double devicePixelRatio = 0.0;
|
||||
static double physicalAspectRatioHeight = 0;
|
||||
static double visibleAspectRatioHeight = 0;
|
||||
|
||||
// Padding of the screen where we cannot render elements without the SafeArea
|
||||
static EdgeInsets padding = const EdgeInsets.all(0);
|
||||
|
||||
static const double kWebDesiredAspectRatio = MainConstants.minWebAppRatio;
|
||||
|
||||
const SizeUtils();
|
||||
|
||||
/// init method which instantiates the class using MediaQuery. If a size is provided, it will use that size instead of the MediaQuery
|
||||
static void init({required BuildContext context, Size? size}) {
|
||||
if (size != null) {
|
||||
padding = EdgeInsets.zero;
|
||||
devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
||||
height = size.height;
|
||||
width = size.width;
|
||||
visibleAspectRatioHeight = (height / width) * aspectRatioWidth;
|
||||
physicalWidth = width;
|
||||
physicalHeight = height;
|
||||
physicalAspectRatioHeight =
|
||||
(physicalHeight / physicalWidth) * aspectRatioWidth;
|
||||
} else {
|
||||
height = MediaQuery.sizeOf(context).height;
|
||||
width = MediaQuery.sizeOf(context).width;
|
||||
padding = MediaQuery.of(context).padding;
|
||||
devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
||||
visibleAspectRatioHeight = (height / width) * aspectRatioWidth;
|
||||
|
||||
final FlutterView view =
|
||||
WidgetsBinding.instance.platformDispatcher.views.first;
|
||||
final Size realSize = view.display.size;
|
||||
|
||||
// Dimensions in physical pixels (px)
|
||||
physicalWidth = realSize.width / devicePixelRatio;
|
||||
physicalHeight = realSize.height / devicePixelRatio;
|
||||
physicalAspectRatioHeight =
|
||||
(physicalHeight / physicalWidth) * aspectRatioWidth;
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculate percentatge of screen height, for example: '5' would be a '5%' of the total screen size
|
||||
static double heightByPercent(double percent) => height * (percent / 100);
|
||||
|
||||
static double physicalHeightByPercent(double percent) =>
|
||||
physicalHeight * (percent / 100);
|
||||
|
||||
static double widthByPercent(double percent) => width * (percent / 100);
|
||||
|
||||
static bool get isSmallerScreen => visibleAspectRatioHeight <= 16;
|
||||
|
||||
static bool get isMediumScreen => physicalAspectRatioHeight <= 18.0;
|
||||
|
||||
static bool get isXLScreen => physicalAspectRatioHeight >= 20.0;
|
||||
|
||||
static Size get screenSize => Size(width, height);
|
||||
|
||||
static T getByScreen<T>({
|
||||
required T small,
|
||||
T? medium,
|
||||
required T big,
|
||||
T? xl,
|
||||
}) {
|
||||
if (isSmallerScreen) return small;
|
||||
if (isMediumScreen) return medium ?? small;
|
||||
if (isXLScreen && xl != null) return xl;
|
||||
return big;
|
||||
}
|
||||
|
||||
static double getDefaultTopBarHeight() {
|
||||
return getByScreen(small: 40.0, big: 55.0);
|
||||
}
|
||||
}
|
||||
1
packages/utils/lib/utils.dart
Normal file
1
packages/utils/lib/utils.dart
Normal file
@@ -0,0 +1 @@
|
||||
export 'src/size_utils.dart';
|
||||
54
packages/utils/pubspec.yaml
Normal file
54
packages/utils/pubspec.yaml
Normal file
@@ -0,0 +1,54 @@
|
||||
name: utils
|
||||
description: "A new Flutter package project."
|
||||
version: 0.0.1
|
||||
homepage:
|
||||
|
||||
environment:
|
||||
sdk: ^3.9.2
|
||||
flutter: ">=1.17.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^5.0.0
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter packages.
|
||||
flutter:
|
||||
|
||||
# To add assets to your package, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
#
|
||||
# For details regarding assets in packages, see
|
||||
# https://flutter.dev/to/asset-from-package
|
||||
#
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/to/resolution-aware-images
|
||||
|
||||
# To add custom fonts to your package, add a fonts section here,
|
||||
# in this "flutter" section. Each entry in this list should have a
|
||||
# "family" key with the font family name, and a "fonts" key with a
|
||||
# list giving the asset and other descriptors for the font. For
|
||||
# example:
|
||||
# fonts:
|
||||
# - family: Schyler
|
||||
# fonts:
|
||||
# - asset: fonts/Schyler-Regular.ttf
|
||||
# - asset: fonts/Schyler-Italic.ttf
|
||||
# style: italic
|
||||
# - family: Trajan Pro
|
||||
# fonts:
|
||||
# - asset: fonts/TrajanPro.ttf
|
||||
# - asset: fonts/TrajanPro_Bold.ttf
|
||||
# weight: 700
|
||||
#
|
||||
# For details regarding fonts in packages, see
|
||||
# https://flutter.dev/to/font-from-package
|
||||
Reference in New Issue
Block a user