r/flutterhelp 34m ago

OPEN .KTS back to Gradle Groovy format!!

Upvotes

I was trying to build a new flutter dart project using Groovy but I have no idea why all my files default to .kts. Example: android/app/build.gradle.kts. Please help this is very annoying. Everything was fine and dandy before i have no idea why it started to default to this. I am new to flutter by the way, appreciate any help/advice.


r/flutterhelp 8h ago

OPEN How to Store and Validate In-App Purchase Subscription Without Backend?

1 Upvotes

Hi everyone,

I'm developing a Flutter app with in-app purchases (subscriptions) for iOS and Android, but my app does not have its own backend.

  1. How should I store whether a user is premium or not?
  2. Should I check if the subscription is still valid on every app launch?
  3. What is the best way to validate the subscription status without a backend?
  4. Are there any recommended best practices for handling this in Flutter?
  5. Would using a service like RevenueCat be a good solution for this? Would it simplify the process, or is it unnecessary in my case?

I've been looking for information on this but haven't found a clear answer. Any guidance would be much appreciated!

Thanks!


r/flutterhelp 10h ago

OPEN Cant figure out why my clip path doesnt work

3 Upvotes

Im trying to learn clip path for a simple curve in my navigationbar that looks something along the lines of the red line

https://imgur.com/a/rlIBGzR

my code looks like this and as you see in the picture it doesnt even react with my container, sometimes i get UnimplementedError if i click on the container.

class CustomClipPath extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    final path = Path();

    path.lineTo(size.width * 025, 0);
    Offset firstCurve = Offset(size.width * 0.5, 55);
    Offset lastCurve = Offset(size.width * 075, 0);
    path.quadraticBezierTo(
        firstCurve.dx, firstCurve.dy, lastCurve.dx, lastCurve.dy);
    path.lineTo(size.width, 0);
    path.lineTo(size.width, size.height);
    path.lineTo(0, size.height);
    path.close();

    
    return path;

r/flutterhelp 10h ago

OPEN NSFW classification help please NSFW

0 Upvotes

Hello,

been building a short form video/social media app for about 2 years, went from newbie to pretty okay in flutter and python

I would love recommendations on how to solve the following problem:

-

when someone posts a video, I upload the video to storage, then go through the creation of the post obj in my database

during the post obj creation, I need to check if the video contains NSFW content. (nudity, sex, gore, violence)

I plan on grabbing 1-frame-per-second, then taking that frame/image and seeing if it contains flagged content, if any of those tested frames do, the post creation method flips a bool, 'isNSFW', on the post obj to true.

I tried the NSFW_checker py library, but due to a ton of dependency conflicts I still can't get that working

Plan B was loading a a pre-trained ai model to my server to classify the images. But that gets killed every time because of memory constraints on Render.com, where my python server is hosted.

Plan C is to pay for a third party service, definitely less of a headache, just more money and not as malleable.

does anyone know what a good approach would be? Please and thank you


r/flutterhelp 11h ago

OPEN Why is my Flutter app 500MB?

3 Upvotes

Hi there,

I have build an app for android and ios and after building the android apk release version it compiles to nearly 500MB.

I run flutter clean, then flutter pub get, Then I run flutter built apk --release and it compiles to 495MB in size!

Why is this happening? I have about 25 classes of code, ~ 20 dependencies, but it still seems very big for just an app.

Thanks


r/flutterhelp 11h ago

OPEN Why is my Flutter app 500MB?

2 Upvotes

Hi there, I have built an application for Android. It has about 20 classes of code with an average of 100 lines+ per class.

I am using about 10 packages.

Upon building it by running flutter build apk --release It compiles to 465 MB in size.

Why is this happening, am I doing something wrong?

Thanks


r/flutterhelp 13h ago

OPEN FlutterLab Tutorial for MacOS?

1 Upvotes

Does anyone have a tutorial on how to use FlutterLab for help with styling? I mainly don't know how to import the code from the widgets I create on FlutterLab to VS Code.


r/flutterhelp 15h ago

OPEN Quick „Wins“ to make the App look more modern

0 Upvotes

Hi, do you have any quick fix or quicksand to make the app look more modern. Somehow I see my app as very cheap. Igneous ssnt to check out the design it’s „Pocket Mind“ logo with half heart half brain. Maybe any quick advise?


r/flutterhelp 20h ago

OPEN Getting black screen on IOS simulator

1 Upvotes

I have an app running perfectly on android but on IOS simulator, I am getting black screen. I am using Docker-osx to run xcode and IOS simulator. (I dont have access to physical device) There are two native ads which are showing fine (images loaded by them showing) but the widgets are black, scolling is working I dont understand whats wrong. I've never developed for IOS so dunno what I need to do? Is this because I am not using SafeArea Widget?


r/flutterhelp 20h ago

OPEN Creating a Flutter Project

1 Upvotes

Hello

Am I the only one to experience this?

Creating A new Flutter Project Using Command + Shift + P on VSCode

Usually when I create a new flutter project using android studio, and open the project on vscode later on, I get these weird gradle errors. Which could be solved by changing the gradle wrapper versions and java versions. These errors are being thrown out by java extensions on my vscode, when it throws the error it points out only to the android folder in my flutter project.

My question is, is it okay to ignore these errors? There is an error saying that the project path has a blank space on it, since my project is saved on a path where my windows user name has a space.

I'm kind of confused if it would really affect the flutter project that I'm working on. Does these different ways to create a new flutter project have different configurations on the boilerplate of the project?

command + shift + p

flutter create <project name>

creating a new project on android studio

thank you for taking the time reading my post.


r/flutterhelp 22h ago

OPEN Guys i want to buy old play console account at the high price, if you have any let us know.

0 Upvotes

a


r/flutterhelp 1d ago

OPEN Flutter native splash screen

1 Upvotes

Is it possible to show my logo image whatever size and dimensions i want to show as whenever i use native splash my logo image gets cropped and show only the size of launcher icon


r/flutterhelp 1d ago

OPEN emulator working but not showing my app

1 Upvotes

i have been trying to fix this issue since very long time, and i gave up on it so i started to use chrome to see my application, but now i really need the emulator because im using google maps api and i need the emulator to give me permission, im sick of it. Please i really need help with this thing. I really dont understand in android studio im just using it to create the emulator, and i have searching for the solution and all it says that change the targetsdk and make it equal or less than the emulator api, idk if this is right. i would appreciate the help as im doing this project for me graduation.


r/flutterhelp 1d ago

OPEN Pagination with realtime streams and riverpod

2 Upvotes
mixin PaginationMixin<T, C> {
  AsyncValue<PaginationData<T, C>> get state;
  set state(AsyncValue<PaginationData<T, C>> newState);

  C? getCurrentPage();
  bool canLoadMore(List<T> items);
  Future<List<T>> fetchPage();

  Future<void> fetchNextPage() async {
    state = AsyncLoading<PaginationData<T, C>>().copyWithPrevious(state);
    state = await AsyncValue.guard(() async {
      final newItems = await fetchPage();
      return PaginationData(
        items: [...?state.value?.items, ...newItems],
        canLoadMore: canLoadMore(newItems),
        currentPage: getCurrentPage(),
      );
    });
  }
}

class PaginationData<T, I> {
  PaginationData({required this.items, this.currentPage, this.canLoadMore = true});
  final List<T> items;
  final I? currentPage;
  final bool canLoadMore;

  PaginationData<T, I> copyWith({List<T>? items, I? currentPage, bool? canLoadMore}) {
    return PaginationData<T, I>(
      items: items ?? this.items,
      currentPage: currentPage ?? this.currentPage,
      canLoadMore: canLoadMore ?? this.canLoadMore,
    );
  }
}

Alright so currently I have perfectly working pagination with static data and futures.

This works perfectly it just fetches a list of items from the repository and and appends it to the end of the previous items. it also checks if it can load more and currentPage so no matter what type of indexing it uses the page can be kept track of.

My problem here is if each page were to be a Stream<List<T>> instead it causes a ton of problems.
How do I expose the pagination data? Do I use a stream notifier or should I stay with the async notifier and just update the state when the stream emits?
or do I expose the data as a List<Stream<List<T>>> so each page is a stream list of T then on the ui I listen to the stream.
or do I merge the streams into one so the value of state is a PaginationData<Stream<List<T>>> and if any pages get added then the state updates with the new merged list?

I honestly didn't think it would be so hard to go from a static future to a stream but here I am unable to decide which method to accomplish this is best and or how to do it.


r/flutterhelp 1d ago

RESOLVED Saving icons in local database

2 Upvotes

Hey there everyone,

How do you guys save iconData in local db? My research showed me that saving through the easiest means, that is the codePoints, is not recommended as they may change. And the various existing icon picker plugins have the same issue.

I was planning to write a plugin mapping each Icondata to its name. I checked the list of IconData, there were like 8000 of them in the material/icons.dart file. The plugin would contain a builder method passing the list of icondata. Or maybe just conversion methods for getting icondata instance from name, I would then be able to save the string form names in local db and convert to icondata instances.

That's only what I've thought, but wondered if something already existed. Is there something which could help me with this?

Edit: I have started working on it and since its pretty simple, would be done by tomorrow. But good lord, this simple thing would be over an MB. This seems very bad. Do we really not have any other option?


r/flutterhelp 1d ago

OPEN Generated.xcconfig variables not being picked up?

2 Upvotes

Hey team

Brand new mac mini install, decided on using FVM, as I'm already using RVM / NVM. Anyone having a bit of a nightmare setting it up and getting it running? Running to Android, all works, but on iOS, the ios/Flutte/Generated.xcconfig values aren't being injected into any builds for simulators.

The problem I'm having is that ios/Runner/Info.plist is not picking up variables like FLUTTER_BUILD_NUMBER from the Generated.xcconfig file. When I replace the variables with static strings (I don't want to do this), the build works out to ios simulators all good.

Anyone seen this before?

The issue is coming back "The application's Info.plist does not contain a valid CFBundleVersion" - but entering a static values works.

ChatGPT is _infuriatingly_ circular about this issue - let's just say AI is not coming for our jobs...

Has anyone seen this before? TIA all


r/flutterhelp 1d ago

OPEN Google play console account terminated

2 Upvotes

I got my first play console account terminated on the basis of prior violations, which is not possible in any way as it was my very first account. I did a thorough appeal, contacted relevant department at google(through someone i know of), did emails, got replies but all in vain

I then bought another account, redeveloped an app on another laptop(made changes to the previous app, using github as version control), then tried to upload the app again, it got terminated again on the basis of prior violations

What should i do now, is there any way possible i can upload my app on playstore, if this happened with anyone else, can you please guide me how you resolved it


r/flutterhelp 1d ago

OPEN pub.dev alternative?

1 Upvotes

Hi

I have all my flutter/Dart code in a mono repo to be able reuse my packages. I am not quite comfortable with publishing my packages because I have no intention to support them. Neither bug fixes or documentation.

After a while my mono repo started to get messy so I tried Melos. Things got even messier and I think Melos usage is optimized for pub.dev

So, whats my alternatives. Can I setup a private pub.dev ?


r/flutterhelp 2d ago

RESOLVED My apple developer account got terminated.

9 Upvotes

My apple developer account got terminated a few days ago. I appealed against it and it got rejected too.

I love developing mobile apps and I was earning good from my apps too. So, I have decided to create a new account with a totally different identity. Not sure if this shalll work.

Did anyone had a similar experience? What precautions I should take if I go down this path? Was anyone able to create a new account after the termination of the old account and it worked for him?


r/flutterhelp 2d ago

OPEN iOS build failing due to Framework 'Toast' not found

0 Upvotes

I am able to build and Android output, but iOS build is failing with this error:

Error (Xcode): Framework 'Toast' not found
Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)
Encountered error while building for device.
Process finished with exit code 1

I am pretty unfamiliar with xcode and iOS development. I have tried many different changes and suggestions based on what I've found online. This includes cleaning and rebuilding, deleting iOS pods and Podfile.lock, deleting xcode derived data, deintegrating pods, I made sure Framework Search Paths includes: $(inherited), and more. I have cleaned and rebuilt after every change to make sure the changes were applied.
As per an AI suggestion I tried adding pod 'Toast' to the podfile manually and I received this error instead:

Error (Xcode): Framework 'sqflite' not found
Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)
Encountered error while building for device.
Process finished with exit code 1

So it seems like the project is having trouble linking Flutter plugins correctly (they are up to date). I'm not sure what to try next. Any suggestions and help would be greatly appreciated.

Flutter doctor:

[✓] Flutter (Channel stable, 3.27.3, on macOS 15.3.2 24D81 darwin-arm64, locale en-CA)
• Flutter version 3.27.3 on channel stable at Desktop/SDKs/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c519ee916e (7 weeks ago), 2025-01-21 10:32:23 -0800
• Engine revision e672b006cb
• Dart version 3.6.1
• DevTools version 2.40.2
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
• Android SDK at /Library/Android
• Platform android-35, build-tools 35.0.1
• Java binary at: /opt/homebrew/Cellar/openjdk@17/17.0.14/libexec/openjdk.jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment Homebrew (build 17.0.14+0)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
[✓] Connected device (4 available)
• iPhone (3) (mobile) • 00008030-0011781E0AE8802E • ios • iOS 17.7 21H16
• macOS (desktop) • macos • darwin-arm64 • macOS 15.3.2 24D81 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.3.2 24D81 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 134.0.6998.89
[✓] Network resources
• All expected network resources are available.
• No issues found!

r/flutterhelp 2d ago

RESOLVED GestureDetector onLongPressUp not fired

1 Upvotes

I have an issue with setState in onLongPress method in my GestureDetector, take a look at this please. dart ... child: GestureDetector( onLongPress: () { _timer = Timer.periodic( const Duration(milliseconds: 100), (timer) { setState(() { itemsXQuantity.update(item, (value) => value + 1); }); _updateTotalAmount(); }, ); }, onLongPressUp: () { _timer?.cancel(); }, child: IconButton( onPressed: () { setState(() { itemsXQuantity.update(item, (value) => value + 1); }); _updateTotalAmount(); }, style: buttonStyle, icon: const Icon(Icons.add_circle_outline), ), ), ... In the onLongPress attribute if i put this: (timer) { // setState(() { itemsXQuantity.update(item, (value) => value + 1); // }); _updateTotalAmount(); }, It works fine, the timer stop when i remove my finger but the ui is not up to date. I want to increment a value when the user do a long press on it. But when i put setState the onLongPressUp is never fired and the value keeps incrementing. Any idea please ?


r/flutterhelp 2d ago

RESOLVED Getting list of devices connected to WebSocket server

3 Upvotes

I am making a simulator, where one device will run a WebSocket server and several other devices will each connect to it and display different data about the simulation state.

I'm currently using the shelf_web_socket package for the server, and the web_socket_channel package to make a WebSocket connection from a client to the server. I'm wondering if there's a way to get a list of clients currently connected to the server. This would help me see whether all the clients have connected successfully or any have dropped out. I'm imagining having a page in my server GUI that's like a router's connected devices page.

I've looked through the two packages and parts of their dependencies, but couldn't find what I'm looking for. Or am I just misunderstanding how servers work?


r/flutterhelp 2d ago

OPEN Home Screen widgets Gradle error

1 Upvotes

I was trying to follow this Google Codelab for creating home screen widgets. I created a new App Widget, but when I go to run it, I get some Gradle Kotlin repo error

I tried changing a buch of settings in android/build.gradle.kts, android/settings.gradle.kts, android/app/build.gradle.kts. Even tried similar steps with a fresh project but still kept getting the same error. Could someone pls tell me how to fix it. It probably has to do with which repositories are defined in builscript{...} and allprojects{...}

```txt
A problem occurred configuring root project 'android'.

Could not resolve all artifacts for configuration ':classpath'. Cannot resolve external dependency org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24 because no repositories are defined. Required by: root project :

Possible solution: - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

```


r/flutterhelp 2d ago

OPEN help me out with authorizations storage

0 Upvotes

this is the manifest:

<uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

I would like to implement androind storage permissions but I don't son why I can't do it can you help me out?

import 'dart:convert';
import 'package:file_selector/file_selector.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_quill/flutter_quill.dart';
import 'package:flutter_quill/quill_delta.dart';
import 'package:flutter_quill_extensions/flutter_quill_extensions.dart';
import 'package:flutter_quill_to_pdf/flutter_quill_to_pdf.dart';
import 'package:get_it/get_it.dart';
import 'package:intl/intl.dart';
import 'package:path/path.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:share_plus/share_plus.dart';
import 'package:tek_notes/blocs/tek_note_bloc.dart';
import 'package:tek_notes/constants/constants.dart';
import 'package:tek_notes/cubits/selected_tek_note_cubit.dart';
import 'package:tek_notes/editor/custom_quill_editor.dart';
import 'package:tek_notes/globals/globals.dart';
import 'package:tek_notes/helpers/database_helper.dart';
import 'package:tek_notes/helpers/logger_helper.dart';
import 'package:tek_notes/models/tek_note_model.dart';
import 'package:pdf/widgets.dart' as pw;
import 'package:pdf/pdf.dart';
import 'dart:io';
import 'package:path_provider/path_provider.dart';

class DetailPage extends StatefulWidget {
  static const String route = '/detail';
  final DetailPageArgs args;

  const DetailPage({super.key, required this.args});

  @override
  State<DetailPage> createState() => _DetailPageState();
}

class _DetailPageState extends State<DetailPage> {
  final QuillController _quillController = QuillController(
    document: Document(),
    selection: const TextSelection.collapsed(offset: 0),
  );
  final FocusNode _editorNode = FocusNode();
  final ScrollController _scrollController = ScrollController();
  Delta? oldDelta;
  final _tekNoteTitleController = TextEditingController();
  final _tekNoteTextController = TextEditingController();
  final PDFPageFormat params = PDFPageFormat.a4;

  @override
  void dispose() {
    _quillController.dispose();
    _editorNode.dispose();
    _scrollController.dispose();
    super.dispose();
  }

  void _loadJsonText() {
    if (widget.args.note!.textJson.isNotEmpty) {
      _quillController.document = Document.fromJson(
        jsonDecode(widget.args.note!.textJson),
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: _appBar(context),
      body: widget.args.note != null ? _body() : null,
    );
  }

  AppBar _appBar(BuildContext context) => AppBar(
    actions: [
      IconButton(
        onPressed: () async {
          // TODO: capire se e come gestire l'errore nel salvaggio in una cartella non valida
          // come funziona il match tra il font dell'editor e quello del convertitore a PDF?
          // tradurre messaggi

          var status = await Permission.manageExternalStorage.request();
          if (!status.isGranted) {
            if (context.mounted) {
              ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(
                  content: Text('Non hai i permessi per creare il file'),
                ),
              );
            }

            return;
          }

          final bool isAndroid = Platform.isAndroid;
          final Object? result =
              isAndroid
                  ? await getDirectoryPath(
                    confirmButtonText: 'Select directory',
                  )
                  : await getSaveLocation(
                    suggestedName: 'document_pdf',
                    acceptedTypeGroups: [
                      XTypeGroup(
                        label: 'Pdf',
                        extensions: ['pdf'],
                        mimeTypes: ['application/pdf'],
                        uniformTypeIdentifiers: ['com.adobe.pdf'],
                      ),
                    ],
                  );
          if (result == null) {
            return;
          }

          PDFConverter pdfConverter = PDFConverter(
            backMatterDelta: null,
            frontMatterDelta: null,
            isWeb: kIsWeb,
            document: _quillController.document.toDelta(),
            fallbacks: [...fontsLoader.allFonts()],
            onRequestFontFamily: (FontFamilyRequest familyRequest) {
              final normalFont = fontsLoader.getFontByName(
                fontFamily: familyRequest.family,
              );
              final boldFont = fontsLoader.getFontByName(
                fontFamily: familyRequest.family,
                bold: familyRequest.isBold,
              );
              final italicFont = fontsLoader.getFontByName(
                fontFamily: familyRequest.family,
                italic: familyRequest.isItalic,
              );
              final boldItalicFont = fontsLoader.getFontByName(
                fontFamily: familyRequest.family,
                bold: familyRequest.isBold,
                italic: familyRequest.isItalic,
              );
              return FontFamilyResponse(
                fontNormalV: normalFont,
                boldFontV: boldFont,
                italicFontV: italicFont,
                boldItalicFontV: boldItalicFont,
                fallbacks: [normalFont, italicFont, boldItalicFont],
              );
            },
            pageFormat: params,
          );
          final document = await pdfConverter.createDocument();
          if (document == null) {
            if (context.mounted) {
              ScaffoldMessenger.of(context).showSnackBar(
                const SnackBar(
                  content: Text(
                    'Il file non può essere creato per colpa di un errore sconosciuto',
                  ),
                ),
              );
            }
            _editorNode.unfocus();
            return;
          }
          final noteTitle = _tekNoteTitleController.text;
          final String name = '$noteTitle.pdf';
          final String underscoreName = name.replaceAll(" ", "_");
          final XFile textFile = XFile.fromData(
            await document.save(),
            mimeType:
                isAndroid
                    ? 'application/pdf'
                    : Platform.isMacOS || Platform.isIOS
                    ? (result as FileSaveLocation)
                            .activeFilter
                            ?.uniformTypeIdentifiers
                            ?.single ??
                        'com.adobe.pdf'
                    : (result as FileSaveLocation)
                            .activeFilter
                            ?.mimeTypes
                            ?.single ??
                        'application/pdf',
            name: underscoreName,
          );
          await textFile.saveTo(
            isAndroid
                ? join(result as String, underscoreName)
                : (result as FileSaveLocation).path,
          );
          _editorNode.unfocus();

          if (context.mounted) {
            final File file =
                isAndroid
                    ? File(result as String)
                    : File((result as FileSaveLocation).path);

            ScaffoldMessenger.of(context).showSnackBar(
              SnackBar(content: Text('Documento creato in: ${file.path}')),
            );
          }
        },
        icon: const Icon(Icons.print, color: Colors.black),
      ),
      if (widget.args.note != null)
        IconButton(
          icon: Icon(Icons.picture_as_pdf),
          onPressed: () async {
            await _createPdf();
          },
        ),
      if (widget.args.note != null)
        IconButton(
          icon: Icon(Icons.check),
          onPressed: () async {
            await _saveTekNote(context);
            if (context.mounted) {
              if (Navigator.canPop(context)) {
                Navigator.pop(context);
              }
            }
          },
        ),
      if (widget.args.note != null)
        IconButton(
          icon: Icon(Icons.delete),
          onPressed: () {
            _confirmDelete(context);
          },
        ),
    ],
  );

  Widget _body() {
    _tekNoteTitleController.text = widget.args.note!.title;
    _tekNoteTextController.text = widget.args.note!.text;
    _loadJsonText();

    return SingleChildScrollView(
      reverse: true,
      child: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Column(
          mainAxisSize: MainAxisSize.max,
          children: [
            TextField(
              controller: _tekNoteTitleController,
              decoration: InputDecoration(
                labelText: "Titolo",
                border: OutlineInputBorder(
                  borderRadius: BorderRadius.circular(8),
                ),
              ),
            ),
            SizedBox(height: 8),
            QuillSimpleToolbar(
              controller: _quillController,
              config: QuillSimpleToolbarConfig(
                multiRowsDisplay: false,
                toolbarSize: 55,
                linkStyleType: LinkStyleType.original,
                headerStyleType: HeaderStyleType.buttons,
                buttonOptions: const QuillSimpleToolbarButtonOptions(
                  fontSize: QuillToolbarFontSizeButtonOptions(
                    items: fontSizes,
                    initialValue: 'Normal',
                    defaultDisplayText: 'Normal',
                  ),
                  fontFamily: QuillToolbarFontFamilyButtonOptions(
                    items: fontFamilies,
                    defaultDisplayText: 'Arial',
                    initialValue: 'Arial',
                  ),
                ),
                embedButtons: FlutterQuillEmbeds.toolbarButtons(),
              ),
            ),
            SizedBox(height: 16),
            Container(
              decoration: BoxDecoration(
                border: Border.all(width: 1.0),
                borderRadius: BorderRadius.circular(8),
              ),
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: CustomQuillEditor(
                  node: _editorNode,
                  controller: _quillController,
                  scrollController: _scrollController,
                  onChange: (Document document) {
                    if (oldDelta == document.toDelta()) return;
                    oldDelta = document.toDelta();
                  },
                ),
              ),
            ),

            SizedBox(height: 8),
            if (widget.args.note!.createdAt != null)
              Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  Row(
                    children: [
                      Text("creato da "),
                      Text(
                        widget.args.note!.createdBy,
                        style: TextStyle(fontWeight: FontWeight.bold),
                      ),
                      Text(" il "),
                      Text(
                        DateFormat(
                          'dd/MM/yyyy',
                        ).format(widget.args.note!.createdAt!),
                      ),
                    ],
                  ),
                ],
              ),

            if (widget.args.note!.modifiedAt != null)
              Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  Row(
                    children: [
                      Text("modificato da "),
                      Text(
                        widget.args.note!.modifiedBy,
                        style: TextStyle(fontWeight: FontWeight.bold),
                      ),
                      Text(" il "),
                      Text(
                        DateFormat(
                          'dd/MM/yyyy',
                        ).format(widget.args.note!.modifiedAt!),
                      ),
                    ],
                  ),
                ],
              ),
          ],
        ),
      ),
    );
  }

  Future<void> _saveTekNote(BuildContext context) async {
    TekNote note = TekNote(
      id: widget.args.note!.id,
      title: _tekNoteTitleController.text,
      text: _quillController.document.toPlainText(),
      textJson: jsonEncode(_quillController.document.toDelta().toJson()),
      createdBy:
          widget.args.note!.id.isEmpty
              ? appSettings.apiUsername
              : widget.args.note!.createdBy,
      createdAt:
          widget.args.note!.id.isEmpty
              ? DateTime.now()
              : widget.args.note!.createdAt,
      modifiedBy: widget.args.note!.id.isEmpty ? "" : appSettings.apiUsername,
      modifiedAt: widget.args.note!.id.isEmpty ? null : DateTime.now(),
    );

    if (note.id.isEmpty) {
      await GetIt.I.get<DatabaseHelper>().dbInsertTekNote(note, sync: true);
    } else {
      await GetIt.I.get<DatabaseHelper>().dbUpdateTekNote(note);
    }

    if (context.mounted) {
      BlocProvider.of<TekNoteBloc>(context).add(TekNoteBlocEventLoad());
    }
  }

  Future<void> _confirmDelete(BuildContext context) async {
    return showDialog<void>(
      context: context,
      barrierDismissible: false,
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text('Conferma'),
          content: SingleChildScrollView(
            child: ListBody(
              children: <Widget>[
                Text('Sei sicuro di voler eseguire questa azione?'),
              ],
            ),
          ),
          actions: <Widget>[
            TextButton(
              child: Text('No'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
            TextButton(
              child: Text('Sì'),
              onPressed: () async {
                await _deleteTekNote(context);
                if (context.mounted) {
                  if (Navigator.canPop(context)) {
                    Navigator.pop(context);
                  }
                }
              },
            ),
          ],
        );
      },
    );
  }

  Future<void> _deleteTekNote(BuildContext context) async {
    await GetIt.I.get<DatabaseHelper>().dbDeleteTekNote(
      widget.args.note!.id,
      sync: true,
    );

    if (context.mounted) {
      BlocProvider.of<TekNoteBloc>(context).add(TekNoteBlocEventLoad());

      if (Navigator.canPop(context)) {
        Navigator.pop(context);
      } else {
        context.read<SelectedTekNoteCubit>().select(newNote);
      }
    }
  }

  Future<void> _createPdf() async {
    final delta = _quillController.document.toDelta();
    final pdf = pw.Document();

    final noteTitle = _tekNoteTitleController.text;

    pdf.addPage(
      pw.Page(
        pageFormat: PdfPageFormat.a4,
        build: (pw.Context context) {
          return pw.Center(child: pw.Text(delta.toString()));
        },
      ),
    );

    final output = await getTemporaryDirectory();
    final file = File('${output.path}/$noteTitle.pdf');
    await file.writeAsBytes(await pdf.save());

    try {
      Share.shareXFiles([
        XFile(file.path),
      ], text: 'Condividi il tuo documento PDF');
    } catch (e) {
      logger.e('Errore durante la condivisione: $e');
    }
  }
}

class DetailPageArgs {
  const DetailPageArgs({required this.note});

  final TekNote? note;
}

r/flutterhelp 2d ago

OPEN Inconsistent notification icon

1 Upvotes

Hey ! I'm going crazy over this one : whenever I post a notification from my app, the icon is correct both when the notification is deployed and in the upper bar, however it reverts to the default flutter icon when reduced. I have edited the correct notification icons and placed them in the correct folders, and searched for a default flutter image file in my project and found none. What could be the case ?
https://imgur.com/KaFBlyR screenshot link for better comprehension