Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codingmitra/simple
A lightweight Flutter package for simplifying UI development
https://github.com/codingmitra/simple
Last synced: about 6 hours ago
JSON representation
A lightweight Flutter package for simplifying UI development
- Host: GitHub
- URL: https://github.com/codingmitra/simple
- Owner: codingmitra
- License: mit
- Created: 2024-10-15T20:41:12.000Z (24 days ago)
- Default Branch: main
- Last Pushed: 2024-10-15T21:05:20.000Z (23 days ago)
- Last Synced: 2024-10-17T08:49:00.395Z (22 days ago)
- Language: Dart
- Size: 10.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
**Simple UI Package**
======================A lightweight Flutter package for simplifying UI development.
**Features**
------------* **SimpleGap**: A replacement for the `SizedBox` widget, used to create spacing between two widgets.
* **SimplePadding/Margin**: A replacement for the `padding/margin` property, corresponds to CSS padding values.
* **Extensions**: A set of extensions for `BuildContext` `Widget`, `String`, and `DateTime` classes to simplify common tasks.**Getting Started**
-------------------Add the `simple` package to your `pubspec.yaml` file:
```yml
dependencies:
simple: ^0.0.1
```Then, run `flutter pub get` to install the package.
**Usage**
---------### SimpleGap
Use `SimpleGap` to create spacing between two widgets:
```dart
SimpleGap(8) // 8px gap
SimpleGap(16) // 16px gap
```### SimplePadding
Use `SimplePadding` to add padding to a widget:
```dart
SimplePadding() // no padding
SimplePadding(8) // 8px all sides
SimplePadding(8, 12) // 8px vertical and 12px horizontal
SimplePadding(8, 16, 4) // 8px top, 16px horizontal, 4px bottom
SimplePadding(4, 8, 12, 16) // 4px top, 8px right, 12px bottom, 16px left
```### SimpleMargin
Use `SimpleMargin` to add margin to a widget:
```dart
SimpleMargin() // no margin
SimpleMargin(8) // 8px all sides
SimpleMargin(8, 12) // 8px vertical and 12px horizontal
SimpleMargin(8, 16, 4) // 8px top, 16px horizontal, 4px bottom
SimpleMargin(4, 8, 12, 16) // 4px top, 8px right, 12px bottom, 16px left
```### Extensions
Use the extensions to simplify common tasks:
```dart
// BuildContext extensions
context.theme // Get ThemeData
context.colorScheme // Get ColorScheme
context.textTheme // Get TextTheme
context.mediaQuery // Get MediaQuery
context.size // Get Size
context.padding // Get Padding// Widget extensions
Widget.sliver; // Convert to SliverToBoxAdapter
Widget.expanded; // Convert to Expanded
Widget.flexible; // Convert to Flexible
Widget.flex(1); // Convert to Flexible with flex 1// String extensions
String.toTitleCase(); // Get title case string
String.toInt(); // Get int from string
String.toDouble(); // Get double from string// DateTime extensions
DateTime.date; // Get DateTime with time set to midnight
DateTime.dateString; // Get date string in YYYY-MM-DD
DateTime.timeString; // Get time string in HH:MM:SS
DateTime.dateTimeString; // Get Date Time string in YYYY-MM-DD HH:MM:SS
```**Example**
-----------Here is an example of using the `SimpleGap` and `SimplePadding` widgets:
```dart
import 'package:flutter/material.dart';
import 'package:simple/simple.dart';void main() {
runApp(const MyApp());
}class MyApp extends StatelessWidget {
const MyApp({super.key});@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Simple UI Example',
home: Example(),
);
}
}class Example extends StatelessWidget {
const Example({super.key});@override
Widget build(BuildContext context) {
return Column(
children: [
SimpleGap(16),
SimplePadding(16, 32, 16, 32),
Text('Hello World'),
SimpleGap(8),
Text('This is a simple UI example'),
],
);
}
}
```**API Documentation**
--------------------[https://pub.dev/documentation/simple/latest/]
**License**
----------This package is licensed under the MIT License. See the [LICENSE](https://github.com/codingmitra/simple_ui/blob/master/LICENSE) file for more information.