Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #30 from lunofono/null-safety
Browse files Browse the repository at this point in the history
Migrate to null-safety
  • Loading branch information
llucax authored Sep 22, 2021
2 parents d445ff6 + bd237af commit c6a2f49
Show file tree
Hide file tree
Showing 79 changed files with 1,580 additions and 1,386 deletions.
29 changes: 9 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ main, 'v[0-9]+.[0-9x]+.[0-9x]+*' ]

env:
FLUTTER_CHANNEL: beta
FLUTTER_CHANNEL: stable
JAVA_VERSION: 12.x

jobs:
Expand Down Expand Up @@ -35,27 +35,16 @@ jobs:
- name: Install dependencies
run: flutter pub get

# Analyze step needs different config for pull_request and push, so it is
# duplicated with if conditions to use the correct configuration for each
- name: Analyze (push)
if: github.event_name == 'push' && matrix.test_type == 'static'
uses: kitek/dartanalyzer-annotations-action@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
check_name: test
commit_sha: ${{ github.sha }}
- name: Analyze (pull_request)
if: github.event_name == 'pull_request' && matrix.test_type == 'static'
uses: kitek/dartanalyzer-annotations-action@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
check_name: test
commit_sha: ${{ github.event.pull_request.head.sha }}
- name: Generate unit tests mocks
run: tool/ci mocks-gen

- name: Analyze
if: matrix.test_type == 'static'
run: tool/ci analyze

- name: Check format
run: flutter format -n --set-exit-if-changed lib test example
if: matrix.test_type == 'static'
run: tool/ci format

- name: Run ${{ matrix.test_type }} tests
if: matrix.test_type != 'static'
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Generated Mocks

test/**/*.mocks.dart

# Miscellaneous
*.class
*.log
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ A Flutter widget to play content bundles for Lunofono.
This project is written in [Flutter](https://flutter.dev/). Once you have
a working Flutter SDK installed, you can test it using `flutter test`.

To run the tests you need to first generate the mocks:

```sh
flutter pub run build_runner build
```

### Git Hooks

This repository provides some useful Git hooks to make sure new commits have
Expand Down
32 changes: 31 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
include: package:pedantic/analysis_options.1.9.0.yaml
# 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

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
exclude:
- test/**.mocks.dart

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-lang.github.io/linter/lints/index.html.
#
# 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
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 29
compileSdkVersion 30

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -40,7 +40,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.lunofono_player"
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
12 changes: 12 additions & 0 deletions android/app/src/main/res/drawable-v21/launch_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />

<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
18 changes: 18 additions & 0 deletions android/app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.5.21'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
29 changes: 29 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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-lang.github.io/linter/lints/index.html.
#
# 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
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 29
compileSdkVersion 30

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -40,7 +40,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
minSdkVersion 23
targetSdkVersion 29
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />

<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
4 changes: 2 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.5.21'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
24 changes: 13 additions & 11 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import 'package:lunofono_player/lunofono_player.dart';
import 'package:lunofono_bundle/lunofono_bundle.dart';

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

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -78,7 +80,7 @@ final bundle = Bundle(
PlayContentAction(
Image(
Uri.parse('assets/heilshorn-cows.jpg'),
maxDuration: Duration(seconds: 2),
maxDuration: const Duration(seconds: 2),
),
),
backgroundColor: Colors.blue,
Expand All @@ -87,7 +89,7 @@ final bundle = Bundle(
PlayContentAction(
Audio(
Uri.parse('assets/Farm-SoundBible.com-1720780826.opus'),
maxDuration: Duration(seconds: 2),
maxDuration: const Duration(seconds: 2),
),
),
backgroundColor: Colors.green,
Expand All @@ -98,11 +100,11 @@ final bundle = Bundle(
<Medium>[
Image(
Uri.parse('assets/heilshorn-cows.jpg'),
maxDuration: Duration(seconds: 2),
maxDuration: const Duration(seconds: 2),
),
Image(
Uri.parse('assets/heilshorn-cows2.jpg'),
maxDuration: Duration(seconds: 2),
maxDuration: const Duration(seconds: 2),
),
],
),
Expand All @@ -117,7 +119,7 @@ final bundle = Bundle(
VisualizableMultiMediumTrack(
<Visualizable>[
Image(Uri.parse('assets/heilshorn-cows2.jpg'),
maxDuration: Duration(seconds: 2)),
maxDuration: const Duration(seconds: 2)),
],
),
backgroundTrack: AudibleBackgroundMultiMediumTrack(
Expand All @@ -132,7 +134,7 @@ final bundle = Bundle(
<Audible>[
Audio(
Uri.parse('assets/Farm-SoundBible.com-1720780826.opus'),
maxDuration: Duration(seconds: 4)),
maxDuration: const Duration(seconds: 4)),
],
),
backgroundTrack: VisualizableBackgroundMultiMediumTrack(
Expand All @@ -143,7 +145,7 @@ final bundle = Bundle(
),
Image(
Uri.parse('assets/heilshorn-cows2.jpg'),
maxDuration: Duration(seconds: 2),
maxDuration: const Duration(seconds: 2),
),
],
),
Expand All @@ -155,7 +157,7 @@ final bundle = Bundle(
);

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

// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
Expand Down Expand Up @@ -220,7 +222,7 @@ class _MyHomePageState extends State<MyHomePage> {
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
const Text(
'You have pushed the button this many times:',
),
Text(
Expand All @@ -233,7 +235,7 @@ class _MyHomePageState extends State<MyHomePage> {
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
Expand Down
14 changes: 10 additions & 4 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: lunofono_player_example
description: Demonstrate how to use the lunofono_player package

environment:
sdk: ">=2.7.0 <3.0.0"
sdk: '>=2.12.0 <3.0.0'
flutter: ">=1.17.0 <2.0.0"

dependencies:
Expand All @@ -15,13 +15,19 @@ dependencies:
lunofono_bundle:
git:
url: https://github.com/lunofono/lunofono_bundle.git
ref: v0.3.0
ref: v0.4.1

dev_dependencies:
flutter_driver:
sdk: flutter

flutter_lints: ^1.0.4

flutter_test:
sdk: flutter
integration_test: ^0.9.2+2
pedantic: ^1.9.0

integration_test:
sdk: flutter

flutter:
uses-material-design: true
Expand Down
2 changes: 1 addition & 1 deletion example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:lunofono_player_example/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
await tester.pumpWidget(const MyApp());

expect(find.byType(BundlePlayer), findsOneWidget);
});
Expand Down
Loading

0 comments on commit c6a2f49

Please sign in to comment.