Skip to content

Commit

Permalink
feat: Enhance flutter analyze
Browse files Browse the repository at this point in the history
  • Loading branch information
littleGnAl committed Mar 11, 2022
1 parent 1b44bcd commit a321374
Show file tree
Hide file tree
Showing 49 changed files with 1,201 additions and 1,933 deletions.
41 changes: 22 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,29 @@ on:
push:
branches:
- master
# Temporarily allow check on dev/flutter2-iris branch
- 'dev/flutter2-iris'
pull_request:
branches:
- master
# Temporarily allow check on dev/flutter2-iris branch
- 'dev/flutter2-iris'

jobs:
# DO NOT run flutter test as this time, because the unit test is broken, will re-enable it
# when unit tests being fixed.
# unittest_flutter:
# name: Run Flutter Unit Test
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - uses: actions/setup-java@v1
# with:
# java-version: '11'
# - uses: subosito/flutter-action@v1
# with:
# flutter-version: '2.10.0'
# - run: flutter pub get
# - run: flutter test
flutter_codestyle_check:
name: Flutter codestyle/analyze check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '11'
- uses: subosito/flutter-action@v1
with:
flutter-version: '2.10.0'
- run: flutter pub get
- run: bash ci/dartfmt_check.sh
- run: flutter analyze

integration_test_android:
name: Run Flutter Android Integration Tests
needs: flutter_codestyle_check
runs-on: macos-11
timeout-minutes: 60
env:
Expand All @@ -60,6 +56,7 @@ jobs:

integration_test_ios:
name: Run Flutter iOS Integration Tests
needs: flutter_codestyle_check
runs-on: macos-11
timeout-minutes: 60
env:
Expand All @@ -76,6 +73,7 @@ jobs:

integration_test_macos:
name: Run Flutter macOS Integration Tests
needs: flutter_codestyle_check
runs-on: macos-11
timeout-minutes: 60
env:
Expand All @@ -90,6 +88,7 @@ jobs:

integration_test_windows:
name: Run Flutter Windows Integration Tests
needs: flutter_codestyle_check
runs-on: windows-2019
timeout-minutes: 60
env:
Expand All @@ -104,6 +103,7 @@ jobs:

unittest_android:
name: Run Android Unit Test
needs: flutter_codestyle_check
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
Expand All @@ -119,6 +119,7 @@ jobs:

unittest_ios:
name: Run iOS Unit Test
needs: flutter_codestyle_check
runs-on: macos-11
timeout-minutes: 60
steps:
Expand All @@ -131,6 +132,7 @@ jobs:

build_android:
name: Build Android
needs: flutter_codestyle_check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand All @@ -147,6 +149,7 @@ jobs:

build_ios:
name: Build iOS
needs: flutter_codestyle_check
runs-on: macos-11
timeout-minutes: 60
steps:
Expand Down
11 changes: 6 additions & 5 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
include: package:pedantic/analysis_options.yaml
include: package:flutter_lints/flutter.yaml
analyzer:
exclude:
# Ignore generated files
- '**/*.g.dart'
- 'lib/src/*.g.dart'
- 'lib/src/generated/*.dart'
errors:
undefined_prefixed_name: ignore
- 'integration_test_app/**'
- 'test/**'

linter:
rules:
- public_member_api_docs
public_member_api_docs: false
9 changes: 9 additions & 0 deletions ci/dartfmt_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -e
set -x

if ! dart format --output=none --set-exit-if-changed .; then
echo "The code style of files above are incorrect."
echo "Make sure you follow the dart code style (https://github.com/dart-lang/dart_style)."
exit 1
fi
27 changes: 14 additions & 13 deletions example/lib/examples/advanced/audio_mixing/audio_mixing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import 'dart:async';
import 'package:agora_rtc_engine/rtc_engine.dart';
import 'package:agora_rtc_engine_example/config/agora.config.dart' as config;
import 'package:agora_rtc_engine_example/examples/log_sink.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';

/// AudioMixing Example
class AudioMixing extends StatefulWidget {
const AudioMixing({Key? key}) : super(key: key);

@override
State<StatefulWidget> createState() => _AudioMixingState();
}
Expand Down Expand Up @@ -50,7 +51,7 @@ class _AudioMixingState extends State<AudioMixing> {

Future<void> _initEngine() async {
_engine = await RtcEngine.createWithContext(RtcEngineContext(config.appId));
this._addListeners();
_addListeners();

await _engine.enableAudio();
await _engine.setChannelProfile(ChannelProfile.LiveBroadcasting);
Expand All @@ -60,14 +61,14 @@ class _AudioMixingState extends State<AudioMixing> {
void _addListeners() {
_engine.setEventHandler(RtcEngineEventHandler(
warning: (warningCode) {
logSink.log('warning ${warningCode}');
logSink.log('warning $warningCode');
},
error: (errorCode) {
logSink.log('error ${errorCode}');
logSink.log('error $errorCode');
},
joinChannelSuccess: (channel, uid, elapsed) {
logSink.log(
'joinChannelSuccess channel: ${channel}, uid: ${uid}, elapsed: ${elapsed}');
'joinChannelSuccess channel: $channel, uid: $uid, elapsed: $elapsed');
setState(() {
isJoined = true;
});
Expand Down Expand Up @@ -152,7 +153,7 @@ class _AudioMixingState extends State<AudioMixing> {
children: [
TextField(
controller: _controller,
decoration: InputDecoration(hintText: 'Channel ID'),
decoration: const InputDecoration(hintText: 'Channel ID'),
onChanged: (text) {
setState(() {
channelId = text;
Expand All @@ -164,7 +165,7 @@ class _AudioMixingState extends State<AudioMixing> {
Expanded(
flex: 1,
child: ElevatedButton(
onPressed: isJoined ? this._leaveChannel : this._joinChannel,
onPressed: isJoined ? _leaveChannel : _joinChannel,
child: Text('${isJoined ? 'Leave' : 'Join'} channel'),
),
)
Expand All @@ -176,7 +177,7 @@ class _AudioMixingState extends State<AudioMixing> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(mainAxisSize: MainAxisSize.min, children: [
Text('loopback: '),
const Text('loopback: '),
Switch(
value: _loopback,
onChanged: _isStartedAudioMixing
Expand All @@ -191,7 +192,7 @@ class _AudioMixingState extends State<AudioMixing> {
)
]),
Row(mainAxisSize: MainAxisSize.min, children: [
Text('replace: '),
const Text('replace: '),
Switch(
value: _replace,
onChanged: _isStartedAudioMixing
Expand All @@ -208,7 +209,7 @@ class _AudioMixingState extends State<AudioMixing> {
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text('cycle:'),
const Text('cycle:'),
Slider(
value: _cycle,
min: 0.0,
Expand All @@ -228,7 +229,7 @@ class _AudioMixingState extends State<AudioMixing> {
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text('startPos:'),
const Text('startPos:'),
Slider(
value: _startPos,
min: 1000,
Expand All @@ -249,8 +250,8 @@ class _AudioMixingState extends State<AudioMixing> {
),
ElevatedButton(
onPressed: !_isStartedAudioMixing
? this._startAudioMixing
: this._stopAudioMixing,
? _startAudioMixing
: _stopAudioMixing,
child: Text(
'${_isStartedAudioMixing ? 'Stop' : 'Start'} Audio Mixing'),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:agora_rtc_engine/rtc_engine.dart';
import 'package:agora_rtc_engine/rtc_local_view.dart' as RtcLocalView;
import 'package:agora_rtc_engine/rtc_remote_view.dart' as RtcRemoteView;
import 'package:agora_rtc_engine/rtc_local_view.dart' as rtc_local_view;
import 'package:agora_rtc_engine/rtc_remote_view.dart' as rtc_remote_view;
import 'package:agora_rtc_engine_example/config/agora.config.dart' as config;
import 'package:agora_rtc_engine_example/examples/log_sink.dart';
import 'package:flutter/foundation.dart';
Expand All @@ -9,6 +9,8 @@ import 'package:permission_handler/permission_handler.dart';

/// ChannelMediaRelay Example
class ChannelMediaRelay extends StatefulWidget {
const ChannelMediaRelay({Key? key}) : super(key: key);

@override
State<StatefulWidget> createState() => _State();
}
Expand Down Expand Up @@ -39,7 +41,7 @@ class _State extends State<ChannelMediaRelay> {
await Permission.microphone.request();
}
_engine = await RtcEngine.createWithContext(RtcEngineContext(config.appId));
this._addListener();
_addListener();

// enable video module and set up video encoding configs
await _engine.enableVideo();
Expand All @@ -61,26 +63,26 @@ class _State extends State<ChannelMediaRelay> {
_addListener() {
_engine.setEventHandler(RtcEngineEventHandler(
warning: (warningCode) {
logSink.log('warning ${warningCode}');
logSink.log('warning $warningCode');
},
error: (errorCode) {
logSink.log('error ${errorCode}');
logSink.log('error $errorCode');
},
joinChannelSuccess: (channel, uid, elapsed) {
logSink.log('joinChannelSuccess ${channel} ${uid} ${elapsed}');
logSink.log('joinChannelSuccess $channel $uid $elapsed');
setState(() {
isJoined = true;
});
},
userJoined: (uid, elapsed) {
logSink.log('userJoined $uid $elapsed');
this.setState(() {
setState(() {
remoteUid = uid;
});
},
userOffline: (uid, reason) {
logSink.log('userOffline $uid $reason');
this.setState(() {
setState(() {
remoteUid = null;
});
},
Expand All @@ -89,7 +91,7 @@ class _State extends State<ChannelMediaRelay> {
switch (state) {
case ChannelMediaRelayState.Idle:
logSink.log('ChannelMediaRelayState.Idle $code');
this.setState(() {
setState(() {
isRelaying = false;
});
break;
Expand All @@ -98,13 +100,13 @@ class _State extends State<ChannelMediaRelay> {
break;
case ChannelMediaRelayState.Running:
logSink.log('ChannelMediaRelayState.Running $code)');
this.setState(() {
setState(() {
isRelaying = true;
});
break;
case ChannelMediaRelayState.Failure:
logSink.log('ChannelMediaRelayState.Failure $code)');
this.setState(() {
setState(() {
isRelaying = false;
});
break;
Expand All @@ -121,7 +123,7 @@ class _State extends State<ChannelMediaRelay> {
await _engine.stopChannelMediaRelay();
return;
}
if (_channelMediaRelayController.text.length == 0) {
if (_channelMediaRelayController.text.isEmpty) {
return;
}

Expand Down Expand Up @@ -149,7 +151,7 @@ class _State extends State<ChannelMediaRelay> {
flex: 1,
child: ElevatedButton(
onPressed: _initEngine,
child: Text('Join channel'),
child: const Text('Join channel'),
),
)
],
Expand All @@ -164,7 +166,7 @@ class _State extends State<ChannelMediaRelay> {
Expanded(
child: TextField(
controller: _channelMediaRelayController,
decoration: InputDecoration(
decoration: const InputDecoration(
hintText: 'Enter target relay channel name',
))),
ElevatedButton(
Expand All @@ -181,23 +183,24 @@ class _State extends State<ChannelMediaRelay> {

_renderVideo() {
return Row(children: [
Expanded(
const Expanded(
child: AspectRatio(
aspectRatio: 1,
child:
kIsWeb ? RtcLocalView.SurfaceView() : RtcLocalView.TextureView(),
child: kIsWeb
? rtc_local_view.SurfaceView()
: rtc_local_view.TextureView(),
),
),
Expanded(
child: AspectRatio(
aspectRatio: 1,
child: remoteUid != null
? (kIsWeb
? RtcRemoteView.SurfaceView(
? rtc_remote_view.SurfaceView(
uid: remoteUid!,
channelId: _channelController.text,
)
: RtcRemoteView.TextureView(
: rtc_remote_view.TextureView(
uid: remoteUid!,
channelId: _channelController.text,
))
Expand Down
Loading

0 comments on commit a321374

Please sign in to comment.