Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tutorial in README #20

Merged
merged 3 commits into from
Jul 5, 2023
Merged

Update tutorial in README #20

merged 3 commits into from
Jul 5, 2023

Conversation

kj415j45
Copy link
Contributor

@kj415j45 kj415j45 commented Jun 7, 2023

Sync with latest API.

Copy link
Contributor

@PassionPenguin PassionPenguin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some minor changes #21

```

To reload the accent colors, use the method `load()`:

```dart
await SystemTheme.accentInstance.load();
await SystemTheme.accentColor.load();
```

You can load the colors before running the app, so the colors can't be wrong at runtime:

```dart
void main() async {
WidgetsFlutterBinding.ensureInitialized();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
WidgetsFlutterBinding.ensureInitialized();

The SystemAccentColor already invoke the method ensureInitialized, meaning it needless to execute it beforehand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why SystemAccentColor invoke that method since it should be invoked at user-developer's code. For example, firebase/flutterfire never call that in their lib code, but in their example code.

So here may be another issue. This suggestion will not be accepted.

Comment on lines 76 to +79
WidgetsFlutterBinding.ensureInitialized();

SystemTheme.fallbackColor = const Color(0xFF865432);
await SystemTheme.accentInstance.load();
await SystemTheme.accentColor.load();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's tested that the code above make NO SENSE as the assignment of fallback color have NO EFFECT on the accent color...

Suggested change
WidgetsFlutterBinding.ensureInitialized();
SystemTheme.fallbackColor = const Color(0xFF865432);
await SystemTheme.accentInstance.load();
await SystemTheme.accentColor.load();
var fallbackColor = const Color(0xFF865432);
SystemTheme.accentColor = await SystemAccentColor(fallbackColor)..load();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it does affect the accent color but only when platform channel call returns null.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it does affect the accent color but only when platform channel call returns null.

image

Uhhhh...
I didn't try in that way...I tried first load it, change the fallbackColor and load it again.
The fallbackColor setter works only when it's the first to be called in the whole runtime, meaning that the code below is invalid

//void main() {
// Retrieve user-stored color preference
// maybe some io or database conn
// will callback to set systemTheme fallback color later in that part
// Try to load color first
SystemTheme.accentColor.load()
// runApp()
}

And if the accentColor is not loaded(like in iOS), when the user change the color preference, the systemTheme.fallbackColor is changed, but it doesn't affect the systemTheme.accentColor, so developers have to define some separate code for it...

Anyway, present in the package are holes of the old-era, i have chosen to write one myself in my app yesterday...

README.md Outdated Show resolved Hide resolved
kj415j45 and others added 2 commits June 9, 2023 08:29
Co-authored-by: Hoarfroster <hoarfroster@outlook.com>
@bdlukaa bdlukaa merged commit 10bc562 into bdlukaa:master Jul 5, 2023
@kj415j45 kj415j45 deleted the patch-2 branch July 5, 2023 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants