Giter Club home page Giter Club logo

flutter_corelibrary's Introduction

flutter_corelibrary's People

Contributors

albert221 avatar bartekpacia avatar denis-lncd avatar dependabot[bot] avatar fasuh avatar gogolon avatar jtarkowski27 avatar kamilsztandur avatar kotertom avatar krzysztofmamak avatar lukaszgarstecki avatar mateuszwojtczak avatar mchudy avatar pdenert avatar piotrrogulski avatar piotruela avatar robertodrowaz avatar shilangyu avatar xezolpl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

flutter_corelibrary's Issues

Update override_api_endpoint readme

Usage section is obsolete. Currently more named params are required.

Suggested example of usage:

final apiEndpoint = await overrideApiEndpoint(
  sharedPreferences: await SharedPreferences.getInstance(),
  getInitialUri: getInitialUri,
  deeplinkOverrideSegment: 'override',
  deeplinkQueryParameter: 'apiAddress',
  defaultEndpoint: Uri.parse('https://api.test.lncd.pl'),
);

Allow reading `Credentials` in `LoginClient` API

Currently there is only a method onCredentialsChanged that gives you new Credentials? object you base .

I have a case where I'd need read to access the accessToken and perform some action outside LoginClient with it. Currently there is no way to do so.

Enforce actionable and trackable `TODO` comments

In Patrol, I have accumulated many TODO comments, and I'm not happy with their quality. I would like to be able enforce "good TODOs" - TODOs that have a link to a GitHub issue so the team doesn't lose track of them.

Examples

BAD

// TODO: set reasonable duration or create new exception for this case
// TODO(bartekpacia): set reasonable duration or create new exception for this case
// TODO(bartekpacia): set reasonable duration or create new exception for this case. See #2137

The last is wrong because it makes no sense to include username in the TODO since the person responsible for the issue will very likely be the author of the issue.

GOOD

// TODO: set reasonable duration or create new exception for this case. See https://github.com/leancodepl/patrol/issues/2137

or we could go full-minimalism style - just require the issue number:

// TODO: set reasonable duration or create new exception for this case. See #2137

To paraphrase:

  • GOAL: Enforce every TODO comment to have See #<github-issue-number at the end
  • GOAL: Enforce every TODO comment to not have username (e.g. `// TODO(bartekpacia): ...)
  • NON GOAL: Check if the provided issue link/number is valid/exists/is really an issue (and not a PR or a discussion)

Question

I'm not sure how multiline TODOs should be treated. Should it be:

// TODO(bartekpacia): set reasonable duration or create new exception for this case
// See https://github.com/leancodepl/patrol/issues/2137

or:

// TODO(bartekpacia): set reasonable duration or create new exception for this case
// TODO(bartekpacia): See https://github.com/leancodepl/patrol/issues/2137

?

Do we want to use `discarded_futures` lint?

Examples of code that is invalid when the discarded_futures lint is on:

Example 1

bad

TextButton(
  onPressed: () => Navigator.of(context).push(
    MaterialPageRoute<void>(
      builder: (_) => const WebViewScreen(),
    ),
  ),
  child: const Text('Open webview screen'),
),

good
Gotta add the async.

TextButton(
  onPressed: () async => Navigator.of(context).push(
    MaterialPageRoute<void>(
      builder: (_) => const WebViewScreen(),
    ),
  ),
  child: const Text('Open webview screen'),
),

Screenshot 2022-09-19 at 12 37 18 PM

Example 2

This is worse than the first example.

Let's say the we have a method with the following signature in our widget: Future<Position> _determinePosition() async.

Then this code is invalid:

FutureBuilder<Position>(
  future: _determinePosition(),
  builder: (context, snapshot) {
    // ...
  }
)

Screenshot 2022-09-19 at 12 35 34 PM

In this case, I worked around by making the method into a getter, but it wouldn't be possible if I needed to pass some arguments.

Example 3

Technically it's correct, but marking the closure as async messes with mocktail and tests fail.

Screenshot 2022-09-28 at 9 34 56 AM

Do we want to keep this lint, or should we release leancode_lint v1.3.1 with this lint disabled (until it gets better?).

Rename `use_design_system_item` to something more accurate

I think the name of the use_design_system_item lint rule is too specific for what it is actually capable of. It can be used for classes that are not related to design system (though I agree it's the most common use case, and the migration cost probably outweights the (lack of) benefits).

Update `leancode_lint` to use new `language` modes and remove `strong-mode`

When using leancode_lint on Flutter beta, it spits out:

Screenshot 2023-03-16 at 11 35 38 PM

another example:

Screenshot 2023-03-16 at 11 39 02 PM

The cause lies here:

analyzer:
  strong-mode:
    implicit-casts: false
    implicit-dynamic: false

We should change it to:

analyzer:
  language:
    strict-casts: true
    strict-inference: true
    strict-raw-types: true

as suggested by Customizing static analysis docs.

Learn more:

cc: @Albert221 @shilangyu

Rename login_client methods

Consider changing login_client api so that it clearly indicates that method returns Future<T>. For example _loginClient.initialize() requires await so it can be called initializeAsync instead.

Stop depending on `flutter_lints` in `leancode_lints`

The initial idea was to base our lints on flutter_lints to be compatible with community standards. But this has long stopped being the case. We now patch flutter_lints instead of extending it. For example we disable the use_build_context_synchronously rule since we deemed it too restrictive.

I suggest we drop flutter_lints completely and just maintain our own set of rules. One less dependency also means we don't have to be wary of upgrading flutter_lints in fear that it might introduce/disable some unwanted/wanted rules.

Use analyzer rules only

Practical explanation

This screenshot shows 2 warnings.
Screenshot 2022-05-18 at 4 05 15 PM

diagnostics

Clicking on unused_element redirects us to dart.dev/tools, to a section about a particular diagnostic (aka diagnostic message – in our case the diagnostic is unused_element). This website doesn't use the "lint" word anywhere.

Diagnostics are specified in analysis_options.yaml like this:

analyzer:
  errors:
    unused_element: false
    unused_field: true

Learn more about diagnostic messages on dart.dev

lints

Clicking on use_build_context_synchronously redirects us to dart-lang.github.io/linter, to a page about a particular lint rule (aka lint).

Lints are specified in analysis_options.yaml like this:

linter:
  rules:
    use_build_context_synchronously: false
    library_private_types_in_public_api: true

Learn more about linter rules on dart.dev

output

I've talked with @RobertOdrowazLNCD about this today. We agreed that the distinction between diagnostics and lints is blurry.

He suggested that if possible, we should define both diagnostics and lints in analyzer, so there'll be a smaller chance of making a mistake and defining a diagnostic in linter.rules). i tried and looks like it's not possible (?)

PS I've found explanation of difference between diagnostics and lints here

Do we need `usePostFrameEffect`?

Is this:

usePostFrameEffect(() {
  callback();
});

much better than the vanilla:

WidgetsBinding.instance.addPostFrameCallback((_) {
  someCallback();
);

?

The one (and only?) advantage that I can think of is the possibility to invoke callback conditionally by passing keys to usePostFrameEffect. I haven't ever encountered a use case for this tho.

TextSpans structure in leancode_markup

          Do we want to have a flat structure of text spans instead of using nested spans?
What we have now What I though we want to have
[b]aaa [i]bbb[/i][/b] [b]aaa [i]bbb[/i][/b]
TextSpan(b, aaa) + TextSpan(b+i, bbb) TextSpan(b, aaa + TextSpan(i, bbb))

Originally posted by @Albert221 in #249 (comment)

Cleaner README for cqrs

As the package got more mature it's a good moment to enhance its README with a bit more advanced features.

Any feedback is welcome.

The current proposal for enhancements:

  • Description of Query, Command, and Operation CQRS methods, abstractly.
    • Describing ValidationErrors
  • Note showing how to create a query/command
    • Note shortly introducing to the Dart contracts generator.
      Yes, the package isn't tied with the generator anyhow, but in real life, those two are at least almost always used together and it'd be a good idea to explain the concept with real use-case tips.
  • Maybe a simple graphical (i.e. a logo) for the package?

Nested hook widgets trigger a `avoid_conditional_hooks` false positive

The following useState is marked:

class W extends HookWidget {
  const W({super.key});

  @override
  Widget build(BuildContext context) {
    if (Random().nextBool()) {
      return HookBuilder(
        builder: (context) {
          useState(1);
          return const SizedBox();
        },
      );
    }

    return const SizedBox();
  }
}

It shouldn't as it exists in a different hook scope. It happens because when analysing W it looks for all used hooks inside of it. Instead it should stop recursing down once it encounters a new hook scope. This is done in helpers.dart@getAllInnerHookExpressions.

Add Stream for Credentials changes

Right now it's quite hard to manage the circular dependency on some kind of authentication (say) cubit and the login client itself. The authentication thing needs the login client, but the login client needs to somehow "push" the credentials changes back to this authentication thing. Streams were initially used in the leancode_login_client and they served a good purpose for that.

Right now it uses a simple callback because the OAuth client used it too, but for this purpose, a stream looks like a much more viable solution.

NoSuchMethodError after logging out and trying to log in again

Makes it impossible to log in again without restarting the app.

flutter:
flutter: NoSuchMethodError: The method 'openUrl' was called on null.
flutter: Receiver: null
flutter: Tried calling: openUrl("POST", Instance of '_SimpleUri')
flutter: #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
flutter: #1      IOClient.send
package:http/src/io_client.dart:31
flutter: #2      BaseClient._sendUnstreamed
package:http/src/base_client.dart:91
flutter: #3      BaseClient.post
package:http/src/base_client.dart:32
flutter: #4      resourceOwnerPasswordGrant
package:oauth2/src/resource_owner_password_grant.dart:83
flutter: #5      ResourceOwnerPasswordStrategy.execute
package:login_client/…/strategies/resource_owner_password_strategy.dart:44
flutter: #6      LoginClient.logIn
package:login_client/src/login_client.dart:127
flutter: #7      SignInFormCubit.submit
package:truffleboard/…/bloc/sign_in_form_cubit.dart:34
flutter: #8      SignInScreen._onSignIn
package:truffleboard/…/auth/sign_in_screen.dart:77
flutter: #9      SignInScreen.build.<anonymous closure>.<anonymous closure>
package:truffleboard/…/auth/sign_in_screen.dart:196
flutter: #10     _InkResponseState._handleTap
package:flutter/…/material/ink_well.dart:993
flutter: #11     _InkResponseState.build.<anonymous closure>
package:flutter/…/material/ink_well.dart:1111
flutter: #12     GestureRecognizer.invokeCallback
package:flutter/…/gestures/recognizer.dart:183
flutter: #13     TapGestureRecognizer.handleTapUp
package:flutter/…/gestures/tap.dart:598
flutter: #14     BaseTapGestureRecognizer._checkUp
package:flutter/…/gestures/tap.dart:287
flutter: #15     BaseTapGestureRecognizer.handlePrimaryPointer
package:flutter/…/gestures/tap.dart:222
flutter: #16     PrimaryPointerGestureRecognizer.handleEvent
package:flutter/…/gestures/recognizer.dart:476
flutter: #17     PointerRouter._dispatch
package:flutter/…/gestures/pointer_router.dart:77
flutter: #18     PointerRouter._dispatchEventToRoutes.<anonymous closure>
package:flutter/…/gestures/pointer_router.dart:122
flutter: #19     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
flutter: #20     PointerRouter._dispatchEventToRoutes
package:flutter/…/gestures/pointer_router.dart:120
flutter: #21     PointerRouter.route
package:flutter/…/gestures/pointer_router.dart:106
flutter: #22     GestureBinding.handleEvent
package:flutter/…/gestures/binding.dart:358
flutter: #23     GestureBinding.dispatchEvent
package:flutter/…/gestures/binding.dart:338
flutter: #24     RendererBinding.dispatchEvent
package:flutter/…/rendering/binding.dart:267
flutter: #25     GestureBinding._handlePointerEvent
package:flutter/…/gestures/binding.dart:295
flutter: #26     GestureBinding._flushPointerEventQueue
package:flutter/…/gestures/binding.dart:240
flutter: #27     GestureBinding._handlePointerDataPacket
package:flutter/…/gestures/binding.dart:213
flutter: #28     _rootRunUnary (dart:async/zone.dart:1206:13)
flutter: #29     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
flutter: #30     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
flutter: #31     _invoke1 (dart:ui/hooks.dart:265:10)
flutter: #32     _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.