https://github.com/netsells/flutter-adaptive-widgets
A set of Flutter utilities which allow you to dynamically adapt your app to the current platform.
https://github.com/netsells/flutter-adaptive-widgets
dart flutter
Last synced: about 1 month ago
JSON representation
A set of Flutter utilities which allow you to dynamically adapt your app to the current platform.
- Host: GitHub
- URL: https://github.com/netsells/flutter-adaptive-widgets
- Owner: netsells
- License: bsd-2-clause
- Created: 2019-10-14T12:59:29.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-10-14T14:50:51.000Z (over 5 years ago)
- Last Synced: 2025-03-02T19:07:11.271Z (2 months ago)
- Topics: dart, flutter
- Language: Dart
- Homepage: https://pub.dev/packages/adaptive_widgets
- Size: 62.5 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# adaptive_widgets
A set of utilities which allow you to dynamically adapt your app to the current platform.
## Installing
Simply add the dependency to your project's `pubspec.yaml` file:
```yaml
adaptive_widgets: ^0.0.4
```## Usage
### Adaptive Widget
You can use the `AdaptiveWidget` class to allow your app to choose between two different widgets depending on platform:
```dart
AdaptiveWidget(
cupertinoBuilder: (_) => CupertinoSlider(
onChanged: _valueChanged,
value: _value,
),
materialBuilder: (_) => Slider(
onChanged: _valueChanged,
value: _value,
),
);
```### Adaptive Route
The `createAdaptiveRoute` method returns either a `MaterialPageRoute` or a `CupertinoPageRoute` depending on the platform:
```dart
createAdaptiveRoute(
builder: (_) => MyNiceWidget(),
title: "My Nice Page",
);
```### Adaptive App
The `AdaptiveApp` class will build either a `MaterialApp` or a `CupertinoApp` depending on the platform.
It supports all the properties available in the Material and Cupertino app classes, except that rather than specifying one theme, you can specify a `cupertinoTheme`, `materialTheme`, and `materialDarkTheme`.
```dart
AdaptiveApp(
title: 'My Adaptive App',
home: HomeWidget(),
cupertinoTheme: CupertinoThemeData(),
materialTheme: ThemeData.light(),
materialDarkTheme: ThemeData.dark(),
);
```