Advertisement
rajath_pai

aug5_with_TextField

Aug 4th, 2021
974
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.53 KB | None | 0 0
  1.   import 'package:flutter/material.dart';
  2.   import 'package:flutter_blue/flutter_blue.dart';
  3.  
  4.   void main() => runApp(const MaterialApp(
  5.     debugShowCheckedModeBanner: false,
  6.     home: Home(),
  7.   ));
  8.  
  9.  
  10.   class Home extends StatelessWidget {
  11.     const Home({Key? key}) : super(key: key);
  12.  
  13.     @override
  14.     Widget build(BuildContext context) {
  15.       FlutterBlue flutterBlue = FlutterBlue.instance;
  16.       return Scaffold(
  17.         appBar: AppBar(
  18.           title: Wrap(
  19.             direction: Axis.horizontal,
  20.             crossAxisAlignment: WrapCrossAlignment.center,
  21.             children: const <Widget>[
  22.               Icon(
  23.                   Icons.bluetooth,
  24.                 //color : Colors.blue,
  25.               ),
  26.               Text(
  27.                   'My BLE',
  28.                 //style : TextStyle(color : Colors.white),
  29.               ),
  30.             ],
  31.           ),
  32.           centerTitle: true,
  33.           //backgroundColor: Colors.black,
  34.           backgroundColor: Colors.white54,
  35.         ),
  36.         body: Center(
  37.           child : Column(
  38.             mainAxisAlignment : MainAxisAlignment.center,
  39.             children: [
  40.               Padding(
  41.                 padding: const EdgeInsets.all(15.0),
  42.                 child: ElevatedButton(
  43.                   onPressed : (){
  44.                     flutterBlue.startScan(timeout: Duration(seconds: 4));
  45.                   },
  46.                   child : Text(
  47.                       'Turn on Bluetooth'
  48.                   ),
  49.                   style : ElevatedButton.styleFrom(
  50.                     primary: Colors.grey,
  51.                     padding: EdgeInsets.symmetric(horizontal: 30, vertical: 20),
  52.                   ),
  53.                 ),
  54.               ),
  55.               Padding(
  56.                 padding: const EdgeInsets.all(15.0),
  57.                   child : TextField(
  58.                     decoration: InputDecoration(
  59.                       border: OutlineInputBorder(),
  60.                       focusColor: Colors.red,
  61.                       labelText: 'User Name',
  62.                       labelStyle: TextStyle(color: Colors.white),
  63.                       hintText: 'Enter Your Name',
  64.                   ),
  65.                 ),
  66.               ),
  67.           ],
  68.           ),
  69.         ),
  70.         backgroundColor: Colors.grey[800],
  71.         floatingActionButton: const FloatingActionButton(
  72.           child: Text(
  73.             'click me',
  74.             textAlign: TextAlign.center ,
  75.           ),
  76.           onPressed: null,
  77.           backgroundColor: Colors.grey,
  78.         ),
  79.       );
  80.     }
  81.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement