Skip to content

Commit

Permalink
example of compare
Browse files Browse the repository at this point in the history
  • Loading branch information
aprosail committed Jun 27, 2024
1 parent c0c8bab commit e09b345
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.2.0

- Wrap center align to parent.
- Add examples to compare before and after.

## 0.1.0

Expand Down
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
# Modifier

Syntax sugar optimizations to avoid nesting hell in Flutter.

Before:

```dart
import 'package:flutter/widgets.dart';
void main() {
runApp(const App());
}
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) {
final media = MediaQueryData.fromView(View.of(context));
return MediaQuery(
data: media,
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: Text('app root'),
),
),
);
}
}
```

After:

```dart
import 'package:flutter/widgets.dart';
import 'package:modifier/modifier.dart';
void main() {
runApp(const App());
}
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) => const Text('app root')
.center
.ensureDirection(context)
.ensureMedia(context);
}
```
16 changes: 16 additions & 0 deletions example/after.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter/widgets.dart';
import 'package:modifier/modifier.dart';

void main() {
runApp(const App());
}

class App extends StatelessWidget {
const App({super.key});

@override
Widget build(BuildContext context) => const Text('app root')
.center
.ensureDirection(context)
.ensureMedia(context);
}
23 changes: 23 additions & 0 deletions example/before.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:flutter/widgets.dart';

void main() {
runApp(const App());
}

class App extends StatelessWidget {
const App({super.key});

@override
Widget build(BuildContext context) {
final media = MediaQueryData.fromView(View.of(context));
return MediaQuery(
data: media,
child: const Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: Text('app root'),
),
),
);
}
}

0 comments on commit e09b345

Please sign in to comment.