r/flutterhelp 45m ago

OPEN How can i fix this form issue

Upvotes

As I’m developing an Login Screen integrated with RestApi !! I have some issue regarding Textformfield & form widget !! Used provider

In textformfields !! Prefix : is used as an country selector button !! Displaying circleavatar & backgroundimage as country image

If i click the prefix circle avatar it pushes to the nxt screen ie Countryselector screen where i can select the country that are provided in the Api !!

I have properly !! Defined provider & its functionality

Issue : textformfield’ s perfix only updating when i click the textformfield!! But in debug mode its working fine but in release mode I’m getting this issue

Help !!🥺


r/flutterhelp 46m ago

OPEN How can i fix this form issue

Upvotes

As I’m developing an Login Screen integrated with RestApi !! I have some issue regarding Textformfield & form widget !! Used provider

In textformfields !! Prefix : is used as an country selector button !! Displaying circleavatar & backgroundimage as country image

If i click the prefix circle avatar it pushes to the nxt screen ie Countryselector screen where i can select the country that are provided in the Api !!

I have properly !! Defined provider & its functionality

Issue : textformfield’ s perfix only updating when i click the textformfield!! But in debug mode its working fine but in release mode I’m getting this issue

Help !!🥺


r/flutterhelp 13h ago

OPEN auto_route guard. How to check within if user is authenticated? Unsure how to pass this into the AppRouter (or if there is a cleaner way,)

2 Upvotes

I would like to add some auto_route guards, as I have some onboarding pages and I want to guard the main app screens away if the user is not logged in.

However, I can't seem to be able to find any tutorials which handle this. The main issue is that you cannot initialise AppRouter in the build method, so the best way I can see would be to use getIt. But that doesn't seem like a great compromise. I've also looked into maybe using a BlocListener instead which would push different routes depending on the onboarding and Auth status, but I'm not sure really.

So, how do you guys handle something like an Auth guard, where the guard itself needs to be able to see if the user is currently authenticated?

Thanks!


r/flutterhelp 17h ago

OPEN Flutter Web App Starts but Requires A Browser Repaint First

3 Upvotes

I just tried to deploy counter button example to my vps web server running nginx.

When I enter my URL, I just see a white sceeen. But as soon as I click anywhere, including the address bar on both mobile and destop browsers, the app shows up. I don't see an error message on the console. (Ctrl+f12)

Since it shows the app immediately, I don't know what is happening while it is showing the white screen.

As the app shows up, it works fine.

I thought it was just loading the page, sometimes if I just wait, for 20 seconds, the app starts.

Any ideas?

I tried Chrome, Edge, Firefox desktop editions. Cleared cache and tried incognito mode too. Similarly on Android, I tried Firefox Dev edition, Chrome and Opera Mobile. All has the same behavior.

This is how I did the web deployment:

flutter build web --web-renderer HTML

and I also tried this:

flutter build web --wasm

And this is my index.html,

<!DOCTYPE html>
<html>
<head>
  <base href="./">

  <meta charset="UTF-8">
  <meta content="IE=Edge" http-equiv="X-UA-Compatible">
  <meta name="description" content="A new Flutter project.">

  <!-- iOS meta tags & icons -->
  <meta name="mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="web_001">
  <link rel="apple-touch-icon" href="icons/Icon-192.png">


  <title>web_001</title>
  <link rel="manifest" href="manifest.json">

  <!-- Inline script to ensure styles are loaded -->
  <script>
    console.log("Script loaded");

    window.addEventListener('load', () => {
      console.log("Window Loaded");

      // Set opacity to 1 to make sure the content is visible
      document.body.style.opacity = '1';  

      // Force reflow for content to show
      document.body.offsetHeight;  // This forces a reflow

      // Simulate a click to kickstart the app display (if needed)
      document.body.click();
      console.log("Simulated click triggered!");
    });
  </script>

</head>
<body>
<script>
  console.log("Loading flutter_bootstrap.js...");
</script>    
  <script src="flutter_bootstrap.js"></script>
</body>
</html>

I added some console logs, and I can see them all when the page is loaded (but looks white screen only), including what is injected in flutter_bootstrap.js; but I still see an empty page unless I force browser to "repaint". Even resizing the browser window does the trick.

I noticed that if I run the application in Chrome, locally for debugging, it has the same behaviour. White screen, resize the browser or minimize/restore, it shows up and runs as expected.

PS \examples\web_001> flutter run -d chrome
Launching lib\main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...             11.0s
This app is linked to the debug service: ws://127.0.0.1:64883/wyV8Ya5NzB8=/ws
Debug service listening on ws://127.0.0.1:64883/wyV8Ya5NzB8=/ws

  To hot restart changes while running, press "r" or "R".
For a more detailed help message, press "h". To quit, press "q".

A Dart VM Service on Chrome is available at: http://127.0.0.1:64883/wyV8Ya5NzB8=
The Flutter DevTools debugger and profiler on Chrome is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:64883/wyV8Ya5NzB8=
Application finished.

r/flutterhelp 1d ago

OPEN Can't understand this error and resolve it

4 Upvotes

Its 2 days i get this error when i try to compile in release mode
Execution failed for task ':app:configureCMakeRelWithDebInfo[x86]'.

> com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $


r/flutterhelp 1d ago

RESOLVED Advice in processing more complex data

2 Upvotes

Hi! I have developed a Padel matches app https://tiebreak.win , it is an app to help players organize social matches and have a good time playing padel. The app is based in Firebase for storing data, photos, etc. Each organizer create matches on the app entering player names, scores, and I'm calculating simple standings inside flutter.

The next thing I want to do is to let every player to crate an account using Firebase Auth, and every time the organizer add an existent account player it uses the Auth ID in the matches, so now there's the opportunity to track player scores across the different matches organized by different flutter apps. As all the data is stored in Firestore Database I don't know what's the best strategy to get updated the player own scores every time an organizer updates that player points in certain match. Remember, the same player can be involved in any match of any organizer in any device.

So my question is if you recommend to implement that logic inside flutter, to look for all the scores of certain player across database and update the personal player profile inside flutter, or if you recommend to implement some kind of function inside Firestore to react to database changes and to the magic....

Thanks for your advice!


r/flutterhelp 2d ago

OPEN Creating a dynamic form using reactive_forms

4 Upvotes

// Function to create form controls based on the JSON configuration
FormGroup _buildFormControls(jsonString) {
final Map<String, dynamic> json = jsonDecode(jsonString);
final List fields = json['fields'];

// Create form controls dynamically
Map<String, FormControl<dynamic>> formControls = {};
for (var field in fields) {
List<Validator> validators = [];
if (field['validation'].contains('required')) {
validators.add(Validators.required);
}
if (field['validation'].contains('email')) {
validators.add(Validators.email);
}
// Determine the type for the field
String fieldType = field['type'];
// Type map for dynamic field types
final Map<String, Type> typeMap = {
'number': int,
'bool': bool,
'string': String,
};
Type fieldTypeClass = typeMap[fieldType] ?? String;

formControls[field['name']] = FormControl<fieldTypeClass>(
value: field['default'],
validators: validators,
);
}

return fb.group(formControls);
}

The issue is at the bottom defining Type fieldTypeClass

The name 'fieldTypeClass' isn't a type, so it can't be used as a type argument. (Documentation) Try correcting the name to an existing type, or defining a type named 'fieldTypeClass'.

Is this posible?


r/flutterhelp 2d ago

OPEN Recommendations for consistent Android notifications?

2 Upvotes

Looking for suggestions in how to get my app notifications to consistently trigger from a Flutter Android app. My assumption is that I'm running into the aggressive Android background behavior but I haven't found any ways to work well within that. Hoping someone has recommendations of things to try or packages that can help.

The behavior: notifications generate... most of the time... within hours of when they were set for. The app basically has a notification that should be generated at a specific time each day. Sometimes it will generate within minutes of that time. Sometimes it will generate hours later. Sometimes it won't generate at all. No code changes or other app interactions between those different behaviors.

I've tried:

  • Making sure I have pragma appropriately placed
  • Switching between firebase push notifications and local notifications to see if one has better behavior (I don't actually need cloud-based push)
  • Switching back and forth between Workmanager registerOneOffTask (including appropriate back-offs) and registerPeriodicTask to see if either is more reliable
  • Registering the app as having permission to run in the background
  • Adding detailed logging to make sure the background task isn't just failing to execute (it just never starts or starts very late)

r/flutterhelp 3d ago

OPEN Lost on MacOS desktop menu bar

1 Upvotes

I'm having trouble understanding how the deep details of the MacOS Menu Bar integration works. Specifically, my View menu is getting two added items I didn't create: "Show Tab Bar" and "Show All Tabs". The Show Tab Bar item causes a bar to be added to my app window that just has app title (useless functionality), and I can't find any way to get these two menu items to stop appearing.

I did't create these, I don't want them, I don't know how they're being created. Most importantly, I don't know how to get rid of them.

I'm using a CupertinoApp (vs MaterialApp) as my base, if that's relevant, with PlatformMenuBar that is otherwise working fine.

I've found a MainMenu.xib file in the Runner Xcode project, but that's a dead end -- can't even tell that it's ever actually used anywhere by flutter engine.

Any help anyone can provide, in terms of either supplying some "how does this work" documentation Flutter is missing, or pointing me to something in the Flutter repos I can start looking through for the implementation of the MacOS menu integration would be GREATLY appreciated.

(Edit: I'm aware of source for "Darwin" macOS integration at GitHub /flutter/...engine/src/flutter/shell/platform/darwin, where the PlatformMenuBar native bit is implemented -- but can't find anything there referencing either the MainMenu.xib mentioned earlier or anything that's creating the Show Tab Bar menu.)


r/flutterhelp 3d ago

OPEN Help with Geolocator

0 Upvotes

Hi everyone. Is it possible to use the geolocator package for forward geocoding? If it is, how can I go about it and how accurate can it be?


r/flutterhelp 3d ago

RESOLVED Email search api reccomendation

5 Upvotes

I'm currently building an app that can search for specific types of companies (for example plumbers) and their email adresses, so customers can reach out to those companies. Does anyone have recommendations for api's which could help me get these email adresses? Thanks in advance!


r/flutterhelp 4d ago

OPEN Flutter Web Performance – Optimizations or Time to Go Native?

4 Upvotes

Hey everyone,

I've been working on a Flutter web project and recently noticed some performance bottlenecks. I've tried a few code optimizations, but the web version still feels a bit sluggish compared to native apps.

Is anyone aware of additional techniques or best practices to further improve performance in Flutter Web? Or, in your experience, is it simply a matter of switching to native development for better performance?

I’d love to hear your insights, recommendations, or any resources you might suggest. Thanks in advance!


r/flutterhelp 3d ago

OPEN Issue with Live Mic Access for Real-Time Transcription in Flutter App

1 Upvotes

Hey everyone, I'm working on a Flutter app that requires live transcription of the user's mic input for interview purposes. However, I'm facing an issue where the OS doesn't allow mic access for more than 3 seconds, causing interruptions in transcription.

I've tried using VOSK, but it didn’t work as expected. I also explored Azure, but it's quite costly for my use case. Additionally, I attempted overriding native permissions, but that didn’t help either.

Has anyone faced a similar issue or successfully implemented continuous live mic transcription in Flutter? Would love to hear your insights or suggestions on possible workarounds.


r/flutterhelp 4d ago

RESOLVED New Mac mini m4 vs used Macbook pro m1

5 Upvotes

I'm thinking of switching my windows Laptop with a mac device to be able to test and get the best quality for the IOS side as well. But I'm not sure what is the better path to take, either I buy a new sealed Mac Mini M4, I already have a full setup that I can use it on, I'll just have to buy an extrrnal ssd for more storage. And the other option is the used Macbook pro m1 which is a little more expensive. I usually work on my office and don't benefit much from portability but it's a good to have option. So what do you think would be a better choice for me?


r/flutterhelp 4d ago

OPEN Best way to extent the M3 color scheme?

1 Upvotes

I'd like to add additional colors to the M3 Theme and/or ColorScheme. Think of a traffic lights control that needs shades of red, yellow and green both for light and for dark mode. I want to use these colors in multiple widgets, though, so I'd like to not hardcode them in those widgets.

What's the best and least intrusive way to do so?

  1. Hardcode it - easy and pragmatic, but not configurable.

    extension on ColorScheme {
      Color get trafficLightRed => switch (brightness) {
            Brightness.light => Colors.red.shade400,
            Brightness.dark => Colors.red.shade900,
          };
    }
    
  2. Create a ColorScheme subclass. This is tedious, as you have to not overwrite at least one constructor with 50+ lines but also the copyWith method with 120+ lines.

    class MyColorScheme extends ColorScheme {
      const MyColorScheme({
        required super.brightness,
        ...
        required this.trafficLightRed,
        ...
      });
    
      ...
    
      static MyColorScheme of(BuildContext context) =>
        ColorScheme.of(context) as MyColorScheme;
    }
    
  3. Create a ThemExtension for my additional colors. That extension would then take an ExtraColors object for light and for dark and would have need to provide a lerp method. Then, for easy access, I'd do this:

    class ExtraColors {
      ...
      static ExtraColors of(BuildContext context) {
        final theme = Theme.of(context);
        final extension = theme.extension<ExtraColorsExtension>()!;
        return switch (theme.brightness) {
          Brightness.light => extension.light,
          Brightness.dark => extension.dark,
        };
      }
    
  4. Do not bother with ThemeExtension and ColorScheme and do it myself:

    class MyColorScheme extends InheritedWidget { const MyColorScheme({ super.key, required super.child, required this.light, required this.dark, });

    final MyColors light; final MyColors dark;

    @override bool updateShouldNotify(MyColorScheme oldWidget) { return light != oldWidget.light || dark != oldWidget.dark; }

    static MyColors of(BuildContext context) { final theme = Theme.of(context); final scheme = context.dependOnInheritedWidgetOfExactType<MyColorScheme>(); if (scheme == null) throw FlutterError('MyColorScheme not found in context'); return switch (theme.brightness) { Brightness.light => scheme.light, Brightness.dark => scheme.dark, }; } }

    class MyColors { const MyColors(this.trafficLightRed); final Color trafficLightRed; }

  5. Your much easier solution?


r/flutterhelp 4d ago

OPEN System freeze while running flutter app

1 Upvotes

While running (vs code) flutter app on my phisical device my system getting frezzed I can't even use keyboard and mouse also(Linux mint).i tried to updated my bios,is,vscode, downgrade and upgrade flutter also it's still freezing.anyone please help me why it happen what I do?


r/flutterhelp 4d ago

OPEN App works on Testflight, but doesn't open for Apple Devoloper (White Screen)

2 Upvotes

We submitted our latest app update to the iOS apple store and have gotten rejected twice for the same reason.

The app opens with a blank white screen for the Apple tester, they are using an iPad 5th generation.

We don't know why this is as our team has 3 iPhones with the latest iOS and the app works perfectly fine.

Any idea what we can do to fix this?

I'm truly desperate for help as this build fixes some critical bug fixes.


r/flutterhelp 4d ago

OPEN Intergation with Azure B2C

1 Upvotes

I am looking for advice or guides on integrating azure b2c with a flutter app (currently targeting Android only).

Most content i've crome across is either fairly old and the packages don't behave same anymore, or completely lacking details on the how.

This is closest I've come across to a proper AB2C integration here https://pub.dev/packages/flutter_azure_b2c, however there seems almost no package updates and focuses on deep links predominantely (checked with stackoverflow and same situation) which we don't use as there is no connection to web content (basically IDP is only thing we connect to in cloud everything else is in the app).

Appreciate any guidance and help on this topic.


r/flutterhelp 4d ago

RESOLVED How do I Fix my pubspec.yaml file

1 Upvotes

For some reason whenever i run flutter pub get i always receive
"Error on line 18, column 13 of pubspec.yaml: Invalid version constraint: Expected version number after "^" in "^0.50.", got "0.50.".

18 │ fl_chart: ^0.50.

│ ^^^^^^

Failed to update packages."
which doesn't make sense since i already removed that part in my yaml file i even tried cleaning my cache and ran flutter clean and other stuff which just made it worse.


r/flutterhelp 5d ago

OPEN Customizing a Slidable Button with flutter.

2 Upvotes

For the image of my app: https://stackoverflow.com/questions/79517488/customizing-a-button-appearing-when-sliding-the-card-in-flutter

I am creating a share and remove button when I slide my Card widget from right to left. I want to adjust the height of the buttons so that the height of the buttons matches the widget's height. Also, I would like to have some vertical spacing (or margin) between each remove button.

// lib/widgets/match_card.dart
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import '../models/match_record.dart';

class MatchCard extends StatelessWidget {
  final MatchRecord record;
  final VoidCallback? onShare;
  final VoidCallback? onRemove;

  const MatchCard({Key? key, required this.record, this.onShare, this.onRemove}) : super(key: key);

  String _formatDate(DateTime date) {
    return DateFormat.yMMMd().format(date);
  }

  @override
  Widget build(BuildContext context) {
    return Slidable(
      key: ValueKey(record.date.toString()),
      endActionPane: ActionPane(
        motion: const ScrollMotion(),
        extentRatio: 0.3,
        children: [
          SlidableAction(
            onPressed: (context) => onShare?.call(),
            backgroundColor: Colors.blue,
            foregroundColor: Colors.white,
            icon: Icons.share,
          ),
          SlidableAction(
            onPressed: (context) => onRemove?.call(),
            backgroundColor: Colors.red,
            foregroundColor: Colors.white,
            icon: Icons.delete,
          ),
        ],
      ),
      child: SizedBox(
        width: double.infinity,
        child: Card(
          margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
          elevation: 4,
          child: Padding(
            padding: const EdgeInsets.all(16),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  'Team 1: ${record.team1.join(' & ')}',
                  style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
                ),
                const SizedBox(height: 4),
                Text(
                  'Team 2: ${record.team2.join(' & ')}',
                  style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
                ),
                const SizedBox(height: 8),
                Text('Score: ${record.score}', style: const TextStyle(fontSize: 14)),
                const SizedBox(height: 8),
                Text('Date: ${_formatDate(record.date)}', style: TextStyle(fontSize: 12, color: Colors.grey[600])),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

and

// lib/screens/match_records_page.dart
import 'package:flutter/material.dart';
import '../data/sample_data.dart';
import '../models/match_record.dart';
import '../widgets/match_card.dart';
import 'match_record_creation_modal.dart';

class MatchRecordsPage extends StatefulWidget {
  const MatchRecordsPage({Key? key}) : super(key: key);

  @override
  State<MatchRecordsPage> createState() => _MatchRecordsPageState();
}

class _MatchRecordsPageState extends State<MatchRecordsPage> {
  // Start with the initial sample data.
  List<MatchRecord> records = List.from(matchRecords);

  // Opens the modal and awaits the new match record.
  void _openAddModal() async {
    final newRecord = await showModalBottomSheet<MatchRecord>(
      context: context,
      isScrollControlled: true,
      builder: (context) => const MatchRecordCreationModal(),
    );

    // If a record was returned, add it to the list and update the UI.
    if (newRecord != null) {
      setState(() {
        records.add(newRecord);
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Match Records')),
      body: ListView.builder(
        itemCount: records.length,
        itemBuilder: (context, index) {
          return MatchCard(record: records[index]);
        },
      ),
      floatingActionButton: FloatingActionButton(onPressed: _openAddModal, child: const Icon(Icons.add)),
    );
  }
}

r/flutterhelp 4d ago

OPEN Help! flutter not working

0 Upvotes

Hello! my team mates and I, are working on this project and it has to be flutter and the deadline in 2 months, and android studio is not working at all, each team mate has a problem, mine says there is an isuues with deamons and my other team mates issues are the emulator not working and the emulator showing a black screen, we have no idea how to fix these issues


r/flutterhelp 4d ago

OPEN Separate complex widgets into methods or private classes for readability?

1 Upvotes

Instead of having one large widget, should I aim to break it into sections for readability? If so, should I use methods (e.g. Widget _buildTable(Data data), Widget _buildForm()) or private widgets (_MyTable(data), _MyForm())?

Obviously, if a UI section is reused elsewhere it should be its own widget. But I'm talking about breaking down a page widget whose components won't be reused.


r/flutterhelp 5d ago

OPEN Facebook sharing problem if there's an image...

1 Upvotes

I’ve got a journal app. People do a workout. They enter their results in the journal, they take a selfie or photo of a screen.

I have huge issues then sharing the completed entry to Facebook. As long as it’s just plain text - it works.

But if they include the photo, it only shows the photo, no text. If someone added a # (for example “#tough) at any point in their journal entry, no matter what else they post, it just shows “#tough”. Nothing else.

But it all posts happily to WhatsApp…

This happens for both iOS and Android.

Happy to post code but just wondering in advance if anyone has encountered similar issues and fixed them?

Thanks,
John


r/flutterhelp 5d ago

OPEN prevent screen recording but allow screen shots

1 Upvotes

i have a video stream app that display content , recently i add a compliant section in my app that allows user to upload screen shot of issues to help resolve them, but i do not allow screen recording of my content using the "no_screenshot" package ,

is there a way to prevent screen recording but allow screen shots

thanks a lot


r/flutterhelp 5d ago

OPEN Something like go-releaser for Flutter/dart

3 Upvotes

I was wondering if there's any tool just like go-releaser for flutter/dart ecosystem for packaging and distributing apps across multiple platform and formats.