Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Availability for override breakpoints #25

Merged
merged 1 commit into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [2.1.0] - Apr 20, 2022

* Added `ResponsiveGridBreakpoints` for override default breakpoints
* Added optional `debug` property at `initScaling()` function
* Added `key` property at `ResponsiveGridRow`, `ResponsiveGridCol`, `ResponsiveGridList` widgets

## [2.0.0] - Apr 5, 2021

* Migrate to null safety
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,17 @@ Give every col the width it shall occupy at every size category assuming the tot

```

### Override breakpoints

Add before attach App widget

```dart
ResponsiveGridBreakpoints.value = ResponsiveGridBreakpoints(
xs: 600,
sm: 905,
md: 1240,
lg: 1440,
);
```

<img src="https://raw.githubusercontent.com/mohamed-selim-a/ResponsiveGrid_Flutter/master/images/3.jpg" width="300"> <img src="https://raw.githubusercontent.com/mohamed-selim-a/ResponsiveGrid_Flutter/master/images/4.jpg" height="300">
59 changes: 34 additions & 25 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:responsive_grid/responsive_grid.dart';

void main() => runApp(MyApp());
void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {

final Widget? homeWidget;

MyApp({this.homeWidget});
const MyApp({
this.homeWidget,
Key? key,
}) : super(key: key);

@override
Widget build(BuildContext context) {
Expand All @@ -17,13 +18,13 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: homeWidget ?? MyHomePage(title: 'Flutter Demo Home Page'),
home: homeWidget ?? const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
const MyHomePage({Key? key, required this.title}) : super(key: key);

final String title;

Expand Down Expand Up @@ -69,8 +70,8 @@ class _MyHomePageState extends State<MyHomePage> {
20
].map((i) {
return Container(
height: ((i%5) +1) * 100.0,
alignment: Alignment(0, 0),
height: ((i % 5) + 1) * 100.0,
alignment: const Alignment(0, 0),
color: Colors.cyan,
child: Text(i.toString()),
);
Expand All @@ -87,49 +88,49 @@ class _MyHomePageState extends State<MyHomePage> {
lg: 12,
child: Container(
height: 100,
alignment: Alignment(0, 0),
alignment: const Alignment(0, 0),
color: Colors.purple,
child: Text("lg : 12"),
child: const Text("lg : 12"),
),
),
ResponsiveGridCol(
xs: 6,
md: 3,
child: Container(
height: 100,
alignment: Alignment(0, 0),
alignment: const Alignment(0, 0),
color: Colors.green,
child: Text("xs : 6 \r\nmd : 3"),
child: const Text("xs : 6 \r\nmd : 3"),
),
),
ResponsiveGridCol(
xs: 6,
md: 3,
child: Container(
height: 100,
alignment: Alignment(0, 0),
alignment: const Alignment(0, 0),
color: Colors.orange,
child: Text("xs : 6 \r\nmd : 3"),
child: const Text("xs : 6 \r\nmd : 3"),
),
),
ResponsiveGridCol(
xs: 6,
md: 3,
child: Container(
height: 100,
alignment: Alignment(0, 0),
alignment: const Alignment(0, 0),
color: Colors.red,
child: Text("xs : 6 \r\nmd : 3"),
child: const Text("xs : 6 \r\nmd : 3"),
),
),
ResponsiveGridCol(
xs: 6,
md: 3,
child: Container(
height: 100,
alignment: Alignment(0, 0),
alignment: const Alignment(0, 0),
color: Colors.blue,
child: Text("xs : 6 \r\nmd : 3"),
child: const Text("xs : 6 \r\nmd : 3"),
),
),
],
Expand All @@ -145,25 +146,33 @@ class _MyHomePageState extends State<MyHomePage> {
ResponsiveGridRow(
children: [
ResponsiveGridCol(

xs: 6,
child: Column(
children: [
Container(height: 100, color: Colors.blue, margin: EdgeInsets.all(10),),// height 100px
Container(height: 100, color: Colors.blueGrey, margin: EdgeInsets.all(10),) // height 100px
Container(
height: 100,
color: Colors.blue,
margin: const EdgeInsets.all(10),
), // height 100px
Container(
height: 100,
color: Colors.blueGrey,
margin: const EdgeInsets.all(10),
) // height 100px
],
),
),
ResponsiveGridCol(

xs: 6,
child: Container(height: 400, color: Colors.black45, margin: EdgeInsets.all(10),), // height 500px
child: Container(
height: 400,
color: Colors.black45,
margin: const EdgeInsets.all(10),
), // height 500px
)
],
),

],
);
}

}
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.0.0"
version: "2.1.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down
Loading