Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. import 'package:bloc_pattern/bloc_pattern.dart';
  2. import 'package:flutter/material.dart';
  3. import 'value_bloc.dart';
  4.  
  5. class HomePage extends StatefulWidget {
  6. @override
  7. _HomePageState createState() => _HomePageState();
  8. }
  9.  
  10. class _HomePageState extends State<HomePage> {
  11.  
  12. Widget _textValue(String v) {
  13. return Text(v,
  14. style: TextStyle(
  15. color: Colors.white,
  16. fontSize: 24,
  17. fontWeight: FontWeight.bold,
  18. ),
  19. );
  20. }
  21.  
  22. @override
  23. Widget build(BuildContext context) {
  24. print("reconstruindo");
  25.  
  26. ValueBloc valueBloc = BlocProvider.getBloc<ValueBloc>();
  27.  
  28. return Material(
  29. color: Color.lerp(Colors.red, Colors.purple, valueBloc.value),
  30. child: Column(
  31. mainAxisAlignment: MainAxisAlignment.center,
  32. children: <Widget>[
  33. StreamBuilder<String>(
  34. stream: valueBloc.valueStringOut,
  35. initialData: "",
  36. builder: (BuildContext context, snapshot) {
  37. return _textValue(snapshot.data);
  38. },
  39. ),
  40. Container(
  41. height: 25,
  42. ),
  43. StreamBuilder<double>(
  44. stream: valueBloc.valueOut,
  45. initialData: 0,
  46. builder: (context, snapshot) {
  47. return Slider(
  48. activeColor: Colors.white,
  49. inactiveColor: Colors.white,
  50. min: 0.0,
  51. max: 1.0,
  52. onChanged: valueBloc.onChangeValue,
  53. value: snapshot.data);
  54. },
  55. ),
  56.  
  57. ],
  58. ),
  59. );
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement