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

updated to v8.0.0 of Bloc, which includes Cubit support #6

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ doc/api/
.classpath
.project
.settings/

#
.idea/
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions .idea/flutter_bloc_devtools.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

130 changes: 130 additions & 0 deletions .idea/libraries/Dart_Packages.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions .idea/libraries/Dart_SDK.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/libraries/KotlinJavaRuntime.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/runConfigurations/main_dart.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/flutter_todos/.metadata → .metadata
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: 5391447fae6209bb21a89e6a5a6583cac1af9b4b
channel: beta
revision: 18116933e77adc82f80866c928266a5b4f1ed645
channel: stable

project_type: app
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.2 (2021)

* Update to v8.0.0 of bloc

## 0.1.1 (2020-11-15)

* Minor update to Readme.
Expand Down
39 changes: 30 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
# Remote Devtools for flutter_bloc

## Progress
Fork of https://github.com/andrea689/flutter_bloc_devtools, which doesn't support v8.0.0 of bloc.
This currently has rudimentary support for v8.0.0. It is a work in progress.

NOTE: In general, I don't recommend using this devtool unless you have a large amount of blocs and messages to deal with. For a small number of blocs, it is easier just to use [BlocObserver](https://bloclibrary.dev/#/coreconcepts?id=blocobserver) to log all bloc actions, which takes about 5-10 minutes to setup. See examples in the tutorials in https://bloclibrary.dev/

- [x] I got `flutter_bloc_devtools` to work with the example code. (see also the git branch "null_safety_migration")
- [ ] Doesn't deal well with enumerate types.
- [ ] Works with flutter_todos tutorial, v8.
- [ ] Write tests
- [ ] Update the package in pub.dev

Create an issue if you want to help.


## Original docs

Remote Devtools support for Blocs of [flutter_bloc](https://github.com/felangel/bloc/tree/master/packages/flutter_bloc).

N.B. `Cubit` is not supported
N.B. `Cubit` is *now* supported

![Devtools Demo](https://github.com/andrea689/flutter_bloc_devtools/raw/main/demo.gif)

Expand All @@ -12,26 +29,30 @@ Add the library to pubspec.yaml:

```yaml
dependencies:
flutter_bloc_devtools: ^0.1.0
flutter_bloc_devtools:
git:
url: https://github.com/chonghorizons/flutter_bloc_devtools.git
ref: main
```

Note: The version on pub.dev doesn't work with null safety and v8 of bloc.

## BlocObserver configuration

Add `RemoteDevToolsObserver` to your `Bloc.observer`:

```dart
void main() async {
final observer = RemoteDevToolsObserver('192.168.1.7:8000');
await observer.connect();
Bloc.observer = observer;

runApp(const CounterApp());
BlocOverrides.runZoned(
() async => runApp(const CounterApp()),
blocObserver: RemoteDevToolsObserver('127.0.0.1:8000'),
);
}
```

## Making your Events and States Mappable

Events and States have to implements `Mappable`:
Events and States ~~have to~~ may implement `Mappable`:

```dart
class CounterState extends Equatable implements Mappable {
Expand Down Expand Up @@ -67,4 +88,4 @@ Run your application. It will connect to the remotedev server. You can now debug
## Examples

- [Counter](example/counter)
- [Todos](example/flutter_todos)

2 changes: 2 additions & 0 deletions example/flutter_todos/android/.gitignore → android/.gitignore
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks
19 changes: 12 additions & 7 deletions ...le/flutter_todos/android/app/build.gradle → android/app/build.gradle
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,26 @@ 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'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

lintOptions {
disable 'InvalidPackage'
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutter_todos"
applicationId "com.example.flutter_bloc_devtools"
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flutter_todos">
package="com.example.flutter_bloc_devtools">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
12 changes: 3 additions & 9 deletions .../android/app/src/main/AndroidManifest.xml → android/app/src/main/AndroidManifest.xml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flutter_todos">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="flutter_todos"
package="com.example.flutter_bloc_devtools">
<application
android:label="flutter_bloc_devtools"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.flutter_bloc_devtools

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}
Loading