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:

JavaScript Dictionary

JavaScript dictionary: How to use objects and maps for key-value pairs

Learn how to use JavaScript dictionaries with Objects and Maps. Discover key differences, performance insights, and best use cases with practical examples.

Elijah Agbonze
Feb 25, 2025 ⋅ 9 min read
A guide to the CSS grid-template-columns property

A guide to the CSS grid-template-columns property

Take a deep dive into the CSS grid template columns property, an essential part of the CSS Grid Layout specification.

Samuel Martins
Feb 25, 2025 ⋅ 15 min read
A Guide To Node.js Readable Streams

A guide to Node.js readable streams

Explore how Node.js readable streams process data in small chunks, manage data flow, handle errors, and ensure resource cleanup.

Yan Sun
Feb 25, 2025 ⋅ 7 min read
Advanced React State Management Using URL Parameters

Advanced React state management using URL parameters

Manage state in React using URL parameters for better performance, SEO, and accessibility while enabling shareable and server-rendered application states.

Rahul Chhodde
Feb 24, 2025 ⋅ 16 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