Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broadcast is not working #130

Open
mrdc opened this issue May 25, 2023 · 0 comments
Open

Broadcast is not working #130

mrdc opened this issue May 25, 2023 · 0 comments

Comments

@mrdc
Copy link

mrdc commented May 25, 2023

Hello,

Trying to make a simple broadcast app, but can't get it to work. Beacon is not broadcasting.
I've checked the example many times, but don't see why the app is not broadcasting. No errors etc, so it's hard to debug the issue. Am I missing something in my code?

iOS: 16.5
flutter: 3.0.5
flutter_beacon: 0.5.1
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_beacon/flutter_beacon.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Test',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {

  @override
  void initState() async {
    super.initState();
    await flutterBeacon.initializeAndCheckScanning;
  }

  @override
  void dispose() {
    super.dispose();
  }

  void broadcastBeacon() async {
    await flutterBeacon.startBroadcast(
      BeaconBroadcast(
        identifier: 'test',
        proximityUUID: 'CB10023F-A318-3394-4199-A8730C7C1AEC',
        major: 0,
        minor: 0,
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
          child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
        Text("Test"),
        ElevatedButton(
      onPressed: () async {
        broadcastBeacon();
      },
      child: Text('Start broadcast'),
    )
      ])),
    );
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant