1
1
import "package:flutter/material.dart" ;
2
+ import "package:flutter/services.dart" ;
3
+ import "package:flutter_bloc/flutter_bloc.dart" ;
2
4
import "package:flutter_bloc_app_1/presentation/bottom_navbar/bottom_navbar.dart" ;
5
+ import "package:flutter_bloc_app_1/presentation/conversion_page/bloc/conversion_page_bloc.dart" ;
6
+ import "package:flutter_bloc_app_1/presentation/conversion_page/bloc/conversion_page_event.dart" ;
7
+ import 'package:any_base/any_base.dart' ;
8
+
9
+ const convert2decimal= AnyBase (AnyBase .bin, AnyBase .dec);
3
10
class conversion extends StatelessWidget {
4
11
12
+
5
13
@override
6
14
Widget build (BuildContext context){
15
+ TextEditingController binaryController= TextEditingController (text: "0" );
7
16
8
17
return Scaffold (
9
- body: Text ("Hi" ),
18
+ appBar: AppBar (title: Text ("Binary to Decimal Convertor" ,),
19
+ centerTitle: true ,
20
+ backgroundColor: Theme .of (context).primaryColor,
21
+ foregroundColor: Colors .white,),
22
+ body: Center (
23
+ child: Column (
24
+ mainAxisAlignment: MainAxisAlignment .center,
25
+ children: [
26
+ Text ("Enter Binary below:" ),
27
+
28
+ TextField (
29
+
30
+ inputFormatters: < TextInputFormatter > [FilteringTextInputFormatter .digitsOnly],
31
+ keyboardType: TextInputType .number,
32
+ controller: binaryController,
33
+ onChanged: (value) {
34
+ BlocProvider .of <ConversionBloc >(context).add (changeInText (value));
35
+ },
36
+ ),
37
+ Text ("Converted to Integer:" ),
38
+ BlocBuilder <ConversionBloc ,String >(builder: (context,state)=> Text (convert2decimal.convert (state)))
39
+
40
+
41
+ ],
42
+ ),
43
+ ),
10
44
bottomNavigationBar: bottomNavBar,
11
45
12
- );}}
46
+ );}}
47
+
0 commit comments