2021-10-12
2211
#flutter
Gonçalo Palma
71489
Oct 12, 2021 ⋅ 7 min read

Using WebSockets in Flutter

Gonçalo Palma Lead Flutter Developer at PvotalTech, writer.

Recent posts:

Master JavaScript Date And Time: From Moment.js To Temporal

Master JavaScript date and time: From Moment.js to Temporal

JavaScript’s Date API has many limitations. Explore alternative libraries like Moment.js, date-fns, and the new Temporal API.

Yan Sun
Dec 4, 2024 ⋅ 9 min read
Npm Vs. Npx: What’s The Difference?

npm vs. npx: What’s the difference?

Explore use cases for using npm vs. npx such as long-term dependency management or temporary tasks and running packages on the fly.

Fimber Elemuwa
Dec 3, 2024 ⋅ 5 min read
How To Audit And Validate AI-Generated Code Output

How to audit and validate AI-generated code output

Validating and auditing AI-generated code reduces code errors and ensures that code is compliant.

Boemo Mmopelwa
Dec 2, 2024 ⋅ 5 min read
Building A Background Remover With Vue And Transformers.js

Building a background remover with Vue and Transformers.js

Build a real-time image background remover in Vue using Transformers.js and WebGPU for client-side processing with privacy and efficiency.

Emmanuel John
Nov 29, 2024 ⋅ 9 min read
View all posts

4 Replies to "Using WebSockets in Flutter"

  1. Very intuitive. Would love to see an implementation with State management packages such as Flutter Bloc or Riverpod.

  2. i am getting error my url start from https:// but getting error
    XCEPTION CAUGHT BY WIDGETS LIBRARY
    I/flutter ( 7839): The following WebSocketException was thrown building MyApp(dirty):
    I/flutter ( 7839): Unsupported URL scheme ‘https’
    why my api giving me data on every 5 second
    this is my code
    final channel = WebSocketChannel.connect(Uri.parse(BASE_URL));
    print(channel.closeReason);

    channel.stream.listen((message) {
    final questionData = message;
    print(‘question message–> $questionData’);

    // Handle the received question as needed
    // For example, you can add it to a list of questions or display it in the UI
    }, onError: (error) {
    // Handle WebSocket error
    print(error.toString());
    });

Leave a Reply