Skip to content

Commit

Permalink
[adaptive_style] add example
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Iapicca committed Apr 23, 2024
1 parent 60b2e18 commit d2ca9d2
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 0 deletions.
43 changes: 43 additions & 0 deletions examples/adaptive_style_example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
16 changes: 16 additions & 0 deletions examples/adaptive_style_example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# adaptive_style_example

A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
28 changes: 28 additions & 0 deletions examples/adaptive_style_example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
54 changes: 54 additions & 0 deletions examples/adaptive_style_example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import 'package:adaptive_style/adaptive_style.dart';
import 'package:flutter/material.dart';

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

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

@override
Widget build(context) => const AdaptiveSizeProvider(
child: MaterialApp(
home: MyHomePage(),
),
);
}

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

@override
Widget build(context) => Scaffold(
body: AdaptiveSizeBuilder(builder: (context, adaptiveSize) {
final deviceSize = adaptiveSize.mostSimilarDeviceSize;
return switch (deviceSize) {
(DeviceSize.iphoneSE) => const Stack(
children: [
Padding(
padding: EdgeInsets.all(10),
child: Center(
child: ColoredBox(
color: Colors.blue,
child: SizedBox.expand(),
),
),
),
],
),
_ => const Stack(
children: [
Padding(
padding: EdgeInsets.all(10),
child: Center(
child: ColoredBox(
color: Colors.red,
child: SizedBox.expand(),
),
),
),
],
),
};
}),
);
}
21 changes: 21 additions & 0 deletions examples/adaptive_style_example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: adaptive_style_example
description: "An example app for adaptive_style."

publish_to: 'none'
version: 1.0.0+1

environment:
sdk: ">=3.3.3 <4.0.0"

dependencies:
flutter:
sdk: flutter
adaptive_style: ^0.0.1

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^3.0.1

flutter:
uses-material-design: true
14 changes: 14 additions & 0 deletions examples/adaptive_style_example/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# melos_managed_dependency_overrides: adaptive_style,yak_flutter,yak_result,yak_runner,yak_tween,yak_utils
dependency_overrides:
adaptive_style:
path: ../../packages/adaptive_style
yak_flutter:
path: ../../packages/yak_flutter
yak_result:
path: ../../packages/yak_result
yak_runner:
path: ../../packages/yak_runner
yak_tween:
path: ../../packages/yak_tween
yak_utils:
path: ../../packages/yak_utils

0 comments on commit d2ca9d2

Please sign in to comment.