Skip to content

Instantly share code, notes, and snippets.

@jacobaraujo7
Created May 12, 2019 23:01
Show Gist options
  • Save jacobaraujo7/2fc0f4a727003f8f75dc1624537e7a21 to your computer and use it in GitHub Desktop.
Save jacobaraujo7/2fc0f4a727003f8f75dc1624537e7a21 to your computer and use it in GitHub Desktop.
import 'package:bloc_pattern/bloc_pattern.dart';
import 'package:flutter/material.dart';
import 'value_bloc.dart';
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
Widget _textValue(String v) {
return Text(v,
style: TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
),
);
}
@override
Widget build(BuildContext context) {
print("reconstruindo");
ValueBloc valueBloc = BlocProvider.getBloc<ValueBloc>();
return Material(
color: Color.lerp(Colors.red, Colors.purple, valueBloc.value),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
StreamBuilder<String>(
stream: valueBloc.valueStringOut,
initialData: "",
builder: (BuildContext context, snapshot) {
return _textValue(snapshot.data);
},
),
Container(
height: 25,
),
StreamBuilder<double>(
stream: valueBloc.valueOut,
initialData: 0,
builder: (context, snapshot) {
return Slider(
activeColor: Colors.white,
inactiveColor: Colors.white,
min: 0.0,
max: 1.0,
onChanged: valueBloc.onChangeValue,
value: snapshot.data);
},
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment