Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:flutter_blue/flutter_blue.dart';
- void main() => runApp(const MaterialApp(
- debugShowCheckedModeBanner: false,
- home: Home(),
- ));
- class Home extends StatelessWidget {
- const Home({Key? key}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- FlutterBlue flutterBlue = FlutterBlue.instance;
- return Scaffold(
- appBar: AppBar(
- title: Wrap(
- direction: Axis.horizontal,
- crossAxisAlignment: WrapCrossAlignment.center,
- children: const <Widget>[
- Icon(
- Icons.bluetooth,
- //color : Colors.blue,
- ),
- Text(
- 'My BLE',
- //style : TextStyle(color : Colors.white),
- ),
- ],
- ),
- centerTitle: true,
- //backgroundColor: Colors.black,
- backgroundColor: Colors.white54,
- ),
- body: Center(
- child : Column(
- mainAxisAlignment : MainAxisAlignment.center,
- children: [
- Padding(
- padding: const EdgeInsets.all(15.0),
- child: ElevatedButton(
- onPressed : (){
- flutterBlue.startScan(timeout: Duration(seconds: 4));
- },
- child : Text(
- 'Turn on Bluetooth'
- ),
- style : ElevatedButton.styleFrom(
- primary: Colors.grey,
- padding: EdgeInsets.symmetric(horizontal: 30, vertical: 20),
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(15.0),
- child : TextField(
- decoration: InputDecoration(
- border: OutlineInputBorder(),
- focusColor: Colors.red,
- labelText: 'User Name',
- labelStyle: TextStyle(color: Colors.white),
- hintText: 'Enter Your Name',
- ),
- ),
- ),
- ],
- ),
- ),
- backgroundColor: Colors.grey[800],
- floatingActionButton: const FloatingActionButton(
- child: Text(
- 'click me',
- textAlign: TextAlign.center ,
- ),
- onPressed: null,
- backgroundColor: Colors.grey,
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement