Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
hoc081098 committed Jun 20, 2024
1 parent 778a134 commit 24007f0
Show file tree
Hide file tree
Showing 10 changed files with 327 additions and 139 deletions.
13 changes: 11 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
include: package:pedantic/analysis_options.1.11.0.yaml
include: package:flutter_lints/flutter.yaml
analyzer:
language:
strict-casts: true
strict-raw-types: true
linter:
rules:
- public_member_api_docs
- prefer_final_locals
- prefer_relative_imports
- public_member_api_docs
# https://github.com/dart-lang/lints#migrating-from-packagepedantic
- always_declare_return_types
- prefer_single_quotes
- unawaited_futures
- unsafe_html
6 changes: 1 addition & 5 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
include: package:pedantic/analysis_options.1.11.0.yaml
linter:
rules:
- prefer_final_locals
- prefer_relative_imports
include: package:flutter_lints/flutter.yaml
28 changes: 22 additions & 6 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_bloc_pattern/flutter_bloc_pattern.dart';
import 'package:flutter_disposebag/flutter_disposebag.dart';
import 'package:listenable_stream/listenable_stream.dart';
import 'package:rxdart/rxdart.dart';
import 'package:rxdart_ext/state_stream.dart';

void main() => runApp(MyApp());

Expand Down Expand Up @@ -47,27 +49,28 @@ class MainPage extends StatefulWidget {
_MainPageState createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
class _MainPageState extends State<MainPage> with DisposeBagMixin {
final controller = TextEditingController();
late final StreamSubscription<String> subscription;
late final StateStream<String> stateStream;

@override
void initState() {
super.initState();
subscription = controller

stateStream = controller
.toValueStream(replayValue: true)
.map((event) => event.text)
.debounceTime(const Duration(milliseconds: 500))
.where((s) => s.isNotEmpty)
.distinct()
.switchMap((value) => Stream.periodic(
const Duration(milliseconds: 500), (i) => '$value..$i'))
.listen(print);
.publishState('initial')
..connect().disposedBy(bag);
}

@override
void dispose() {
subscription.cancel();
controller.dispose();
super.dispose();
}
Expand All @@ -87,6 +90,19 @@ class _MainPageState extends State<MainPage> {
controller: controller,
decoration: const InputDecoration(filled: true),
),
Expanded(
child: RxStreamBuilder<String>(
stream: stateStream,
builder: (context, state) {
return Center(
child: Text(
state,
style: Theme.of(context).textTheme.titleMedium,
),
);
},
),
),
],
),
),
Expand Down
Loading

0 comments on commit 24007f0

Please sign in to comment.