Warning: Agenda: Support for defaultProps will be removed from functi…

Resolve deprecation warning when using Agenda view.
When I am on the Agenda view, I keep getting this warning on the browser console:
Warning: Agenda: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.
    at Agenda (webpack-internal:///(app-pages-browser)/./node_modules/react-big-calendar/dist/react-big-calendar.esm.js:4299:24)
    at div
    at Calendar (webpack-internal:///(app-pages-browser)/./node_modules/react-big-calendar/dist/react-big-calendar.esm.js:4609:90)
    at UncontrolledComponent (webpack-internal:///(app-pages-browser)/./node_modules/uncontrollable/lib/esm/uncontrollable.js:45:37)
    at div
    at VolunteerProfile (webpack-internal:///(app-pages-browser)/./components/VolunteerProfile.tsx:18:11)
    at div
    at Page (Server)
    at InnerLayoutRouter (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:243:11)
    at RedirectErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:74:9)
    at RedirectBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:82:11)
    at NotFoundBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/not-found-boundary.js:84:11)
    at LoadingBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:348:11)
    at ErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/error-boundary.js:160:11)
    at InnerScrollAndFocusHandler (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:153:9)
    at ScrollAndFocusHandler (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:228:11)
    at RenderFromTemplateContext (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/render-from-template-context.js:16:44)
    at OuterLayoutRouter (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:369:11)
    at InnerLayoutRouter (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:243:11)
    at RedirectErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:74:9)
    at RedirectBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:82:11)
    at NotFoundBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/not-found-boundary.js:84:11)
    at LoadingBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:348:11)
    at ErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/error-boundary.js:160:11)
    at InnerScrollAndFocusHandler (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:153:9)
    at ScrollAndFocusHandler (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:228:11)
    at RenderFromTemplateContext (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/render-from-template-context.js:16:44)
    at OuterLayoutRouter (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:369:11)
    at InnerLayoutRouter (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:243:11)
    at RedirectErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:74:9)
    at RedirectBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:82:11)
    at NotFoundBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/not-found-boundary.js:84:11)
    at LoadingBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:348:11)
    at ErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/error-boundary.js:160:11)
    at InnerScrollAndFocusHandler (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:153:9)
    at ScrollAndFocusHandler (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:228:11)
    at RenderFromTemplateContext (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/render-from-template-context.js:16:44)
    at OuterLayoutRouter (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:369:11)
    at InnerLayoutRouter (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:243:11)
    at RedirectErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:74:9)
    at RedirectBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:82:11)
    at NotFoundErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/not-found-boundary.js:76:9)
    at NotFoundBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/not-found-boundary.js:84:11)
    at LoadingBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:348:11)
    at ErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/error-boundary.js:160:11)
    at InnerScrollAndFocusHandler (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:153:9)
    at ScrollAndFocusHandler (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:228:11)
    at RenderFromTemplateContext (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/render-from-template-context.js:16:44)
    at OuterLayoutRouter (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:369:11)
    at div
    at div
    at body
    at html
    at RootLayout (Server)
    at RedirectErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:74:9)
    at RedirectBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:82:11)
    at NotFoundErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/not-found-boundary.js:76:9)
    at NotFoundBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/not-found-boundary.js:84:11)
    at DevRootNotFoundBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/dev-root-not-found-boundary.js:33:11)
    at ReactDevOverlay (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/react-dev-overlay/app/ReactDevOverlay.js:87:9)
    at HotReload (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/react-dev-overlay/app/hot-reloader-client.js:321:11)
    at Router (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/app-router.js:207:11)
    at ErrorBoundaryHandler (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/error-boundary.js:113:9)
    at ErrorBoundary (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/error-boundary.js:160:11)
    at AppRouter (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/app-router.js:577:13)
    at ServerRoot (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/app-index.js:112:27)
    at Root (webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/app-index.js:117:11)

Versions used:
"next": "14.2.3",
"react": "^18",
"react-big-calendar": "^1.12.2",

Hi @cutterbl
Already applied the changes you suggested. Please check it out. Thank you!

@devx You'll need to pull in latest changes from master before I can properly review

Someone else provided an up to date fix, so closing this PR as a duplicate


Uchiwa not rendering properly in Firefox.

It appears that the Uchiwa is not rendering properly in Firefox. It does work properly in Chrome and Safari.
Your Environment

Uchiwa version used: Ubuntu packaged 0.26.3-1
Sensu version used: Ubuntu packaged 1.0.3-1
Operating System and version (e.g. Ubuntu 14.04): Ubuntu 14.04
Firefox version: 56.0

Please disregard. The issue was cached images in the browser. Clearing the cache resolves the rendering issue. My apologies.


EMonitorLockException at FMX.SVGIconImageList unit's PaintToBitmap procedure

The errors fires at CheckOwningThread after the following sequence (continuing from the place shown in the screenshot):
procedure TCanvas.EndScene;
begin
  try
    if FBeginSceneCount = 1 then
      DoEndScene;
    Dec(FBeginSceneCount);
  finally
    Unlock;
  end;
end;

class procedure TCanvas.Unlock;
begin
  TMonitor.Exit(FLock);
end;

class procedure TMonitor.Exit(const AObject: TObject);
begin
  CheckMonitorSupport;
  GetMonitor(AObject).Exit;
end;

procedure TMonitor.Exit;
var
  LockCount: Integer;
begin
  CheckOwningThread;
  Dec(FRecursionCount);
  if FRecursionCount = 0 then
  begin
    FOwningThread := 0;
    while True do
    begin
      LockCount := FLockCount;
      if AtomicCmpExchange(FLockCount, LockCount - 1, LockCount) = LockCount then
      begin
        // if LockCount is <> 0 after we dropped our lock, there were waiters, so signal them
        if LockCount and not 1 <> 0 then
          MonitorSupport.WaitOrSignalObject(GetEvent, nil, 0);
        Break;
      end;
    end;
  end;
end;

function TMonitor.CheckOwningThread: TThreadID;
begin
  Result := FOwningThread;
  if Result <> GetCurrentThreadId then
    Error(reMonitorNotLocked)
end;

Did you find any solution or the cause of this problem?

didn't happen again, but didn't try that case I mention above extensively (placing the TSVGIconImage inside a TSelection on an FMX TForm and dragging arround the selection corners), if I see it occuring again I will note it here (and for what version)

Ok, thanks.


Domain Management

Create/edit/modify domains
Related to:

#48: Users management
#47: Roles management

Added ~56 label

Can anyone add to the issue description:
Related to:

#48: Users management
#47: Roles management

Can anyone change the issue name for "Domain Management", the current text could be included in the description

mentioned in issue #65

Creation of new domains is now possible by the administrator.
What does it mean exactly "edit/modify domains"?

If a domain does not have any attribute, only creation has sense


Resource estimation for Quantized Models with vLLM backend is incorrect

Describe the bug
Resource estimation for vLLM backend is incorrect and ignores quantization.
Steps to reproduce

In a GPU server with 4 L20 (48G VRAM) cards without any model deployment, tried to deploy qwen2.5-72b-GPTQ-Int4. The model file is around 42G. The deployment is pending.
GPUStack log shows the resource claim is<PHONE_NUMBER>48 (around 162GB). It's based on FP16 and not correct.

Result
Quantized models can't be deployed, although there is enough VRAM.
Expected behavior
A quantized model should be deployed successfully if there are enough resources.
Environment

GPUStack version: 0.3.2

Additional context
Workaround is manually set --tensor-parallel-size.

We should check the quantization_config - bits to calculate if the quantization config exists. Not just the torch_dtype.
、、、
{
"architectures": [
"Qwen2ForCausalLM"
],
"attention_dropout": 0.0,
"bos_token_id": 151643,
"eos_token_id": 151645,
"hidden_act": "silu",
"hidden_size": 8192,
"initializer_range": 0.02,
"intermediate_size": 29696,
"max_position_embeddings": 32768,
"max_window_layers": 70,
"model_type": "qwen2",
"num_attention_heads": 64,
"num_hidden_layers": 80,
"num_key_value_heads": 8,
"quantization_config": {
"bits": 4,
"group_size": 128,
"modules_to_not_convert": null,
"quant_method": "awq",
"version": "gemm",
"zero_point": true
},
"rms_norm_eps": 1e-06,
"rope_theta": 1000000.0,
"sliding_window": 131072,
"tie_word_embeddings": false,
"torch_dtype": "float16",
"transformers_version": "4.44.1",
"use_cache": true,
"use_sliding_window": false,
"vocab_size": 152064
}
、、、
、、、
def get_ms_model_weight_size(model_id: str, trust_remote_code: bool = False) -> int:
"""
Get the modelscope model weight size in bytes.
"""
from modelscope import AutoConfig
# ModelScope does not provide the info in the API. Infer from the model name.
total_params = parse_model_size_by_name(model_id)

config = AutoConfig.from_pretrained(
    model_id,
    trust_remote_code=trust_remote_code,
)
torch_dtype = getattr(config, 'torch_dtype', "float16")
dtype_to_bytes = {
    "float32": 4,
    "float16": 2,
    "bfloat16": 2,
    "int8": 1,
}
bytes_per_param = dtype_to_bytes.get(torch_dtype, 2)
total_weight_size = total_params * bytes_per_param
return int(total_weight_size)

、、、

0.4.0 has same problem。when  deployment llama-3.3-70b-instruct-bnb-4bit in a H100 card:
2024-12-11T09:16:37+08:00 - modelscope - INFO - Creating symbolic link [/root/.cache/modelscope/hub/unsloth/Llama-3.3-70B-Instruct-bnb-4bit].

2024-12-11T09:16:37+08:00 - gpustack.scheduler.scheduler - DEBUG - Scheduling model instance llama-3.3-70b-instruct-bnb-4bit-mppnA
2024-12-11T09:16:37+08:00 - gpustack.policies.worker_filters.gpu_matching_filter - DEBUG - model llama-3.3-70b-instruct-bnb-4bit, filter gpus with gpu matching policy, instance llama-3.3-70b-instruct-bnb-4bit-mppnA

2024-12-11T09:16:37+08:00 - gpustack.policies.worker_filters.label_matching_filter - DEBUG - model llama-3.3-70b-instruct-bnb-4bit, filter workers with label matching policy, instance llama-3.3-70b-instruct-bnb-4bit-mppnA
2024-12-11T09:16:37+08:00 - gpustack.policies.worker_filters.status_filter - DEBUG - model llama-3.3-70b-instruct-bnb-4bit, filter workers with status policy, instance llama-3.3-70b-instruct-bnb-4bit-mppnA
2024-12-11T09:16:38+08:00 - modelscope - INFO - Target directory already exists, skipping creation.

2024-12-11T09:16:38+08:00 - gpustack.policies.candidate_selectors.vllm_resource_fit_selector - INFO - Calculated resource claim for model instance llama-3.3-70b-instruct-bnb-4bit-mppnA, claim:<PHONE_NUMBER>48.0

2024-12-11T09:16:38+08:00 - gpustack.policies.candidate_selectors.vllm_resource_fit_selector - DEBUG - model llama-3.3-70b-instruct-bnb-4bit, filter candidates with resource fit selector: find_single_worker_single_gpu_full_offloading_candidates, instance llama-3.3-70b-instruct-bnb-4bit-mppnA

2024-12-11T09:16:38+08:00 - gpustack.policies.utils - DEBUG - Worker dnpzomhfiu-77lxrs-d544cbbdc-h5cbt reserved memory:<PHONE_NUMBER>, reserved gpu memory: 0, allocatable memory:<PHONE_NUMBER>840, allocatable gpu memory: {0:<PHONE_NUMBER>4}
2024-12-11T09:16:38+08:00 - gpustack.policies.candidate_selectors.vllm_resource_fit_selector - DEBUG - model llama-3.3-70b-instruct-bnb-4bit, filter candidates with resource fit selector: find_single_worker_multi_gpu_full_offloading_candidates, instance llama-3.3-70b-instruct-bnb-4bit-mppnA

2024-12-11T09:16:38+08:00 - gpustack.policies.scorers.placement_scorer - DEBUG - model llama-3.3-70b-instruct-bnb-4bit, score canidates with scale_up placement policy, instance llama-3.3-70b-instruct-bnb-4bit-mppnA, model_instance: llama-3.3-70b-instruct-bnb-4bit-mppnA

2024-12-11T09:16:38+08:00 - gpustack.scheduler.scheduler - DEBUG - Pick highest score candidate from 0 candidates
2024-12-11T09:16:38+08:00 - gpustack.scheduler.scheduler - DEBUG - No suitable workers for model instance llama-3.3-70b-instruct-bnb-4bit-mppnA, state: pending

Please click advanced and set --tensor-parallel-size=1 as a workaround

Verified in main 364d7ac


Assign concrete values to cross-program constants

Since it is vital that these constants must match between the go and EBPF programs,
I believe it is clearer to use explicit values 1, 2, etc instead of relying on the iota behaviour,
which is more suitable for situations where the exist value doesn't matter as much as that they all be unique.

LGTM


Segmentation fault when compressing 16 bits RAW

Hi, thanks for your great project,
I got the segmentation fault when I was converting a RAW image into 16bits compressed DNG.
Seems bug from 'pack16tolj'
            tile = pack16tolj(rawFrame, int(width*2),
                              int(length/2), bpp, 0, 0, 0, "", 6)

I don't have the time to look at this currently, but if you just need a working DNG; you can work around this by disabling compression.


Bug with font weight when using GoogleFonts.xxxTextTheme?

I can use only 2 font weight if I set it as textTheme.
Code
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        textTheme: GoogleFonts.mitrTextTheme(),
      ),
      home: Scaffold(
        body: SafeArea(
          child: Container(
            constraints: BoxConstraints.expand(),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Column(
                  children: <Widget>[
                    Text('w100',
                        style: GoogleFonts.mitr(
                            fontSize: 18.0, fontWeight: FontWeight.w100)),
                    Text('w200',
                        style: GoogleFonts.mitr(
                            fontSize: 18.0, fontWeight: FontWeight.w200)),
                    Text('w300',
                        style: GoogleFonts.mitr(
                            fontSize: 18.0, fontWeight: FontWeight.w300)),
                    Text('w400',
                        style: GoogleFonts.mitr(
                            fontSize: 18.0, fontWeight: FontWeight.w400)),
                    Text('w500',
                        style: GoogleFonts.mitr(
                            fontSize: 18.0, fontWeight: FontWeight.w500)),
                    Text('w600',
                        style: GoogleFonts.mitr(
                            fontSize: 18.0, fontWeight: FontWeight.w600)),
                    Text('w700',
                        style: GoogleFonts.mitr(
                            fontSize: 18.0, fontWeight: FontWeight.w700)),
                    Text('w800',
                        style: GoogleFonts.mitr(
                            fontSize: 18.0, fontWeight: FontWeight.w800)),
                    Text('w900',
                        style: GoogleFonts.mitr(
                            fontSize: 18.0, fontWeight: FontWeight.w900)),
                  ],
                ),
                SizedBox(
                  width: 20.0,
                ),
                Column(
                  children: <Widget>[
                    Text('w100',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w100)),
                    Text('w200',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w200)),
                    Text('w300',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w300)),
                    Text('w400',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w400)),
                    Text('w500',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w500)),
                    Text('w600',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w600)),
                    Text('w700',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w700)),
                    Text('w800',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w800)),
                    Text('w900',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w900)),
                  ],
                )
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Result
Left side: set it as textStyle
Right side: set it as textTheme

Oh man, I was seriously sitting here thinking I was going crazy because I could only see 2 different font weights regardless of what value I set (with the xxxTextTheme approach). Going to try the more explicit approach tonight.
@johnsonmh Is this something a beginner contributor could help with? I'm really loving Flutter and would love to help give back in some way

I was confused by this too. Perhaps the docs just need updating to make this more explicit? I managed to override the weight in a specific case using:
style: Theme.of(context).textTheme.headline.copyWith(
  fontWeight: FontWeight.w200
)

Same happening here. I have found a way around this—instead of setting the font weight in the fontWeight property, do it in the fontFamily property like this:
fontFamily: GoogleFonts.encodeSansExpanded(fontWeight: FontWeight.w200).fontFamily,

Same problem here

Thanks for the feedback everyone, right now we do not have concrete plans for adjusting the API on this. Again, the problem is that we need to know the font weight when you're requesting it from GoogleFonts in order to pick the right file.
@tomasbaran solution accomplishes this, but similarly you could use your first approach, and make sure you pass fontWeight to the GoogleFonts. method call. For example: GoogelFonts.mitr(fontWeight: FontWeight.w200).
If anyone has good ideas for how we can make the API for this more ergonomic, or how we might be able to document this better, we would be happy to review contributions!

Looks like the only way to make it works across the app is manually specify fonts on pubspec. For example:
fonts:
  - family: RobotoSlab
    fonts:
      - asset: google_fonts/RobotoSlab-Thin.ttf
        weight: 100
      - asset: google_fonts/RobotoSlab-ExtraLight.ttf
        weight: 200
      - asset: google_fonts/RobotoSlab-Light.ttf
        weight: 300
      - asset: google_fonts/RobotoSlab-Regular.ttf
        weight: 400
      - asset: google_fonts/RobotoSlab-Medium.ttf
        weight: 500
      - asset: google_fonts/RobotoSlab-SemiBold.ttf
        weight: 600
      - asset: google_fonts/RobotoSlab-Bold.ttf
        weight: 700
      - asset: google_fonts/RobotoSlab-ExtraBold.ttf
        weight: 800
      - asset: google_fonts/RobotoSlab-Black.ttf
        weight: 900

and then use fontFamily: 'RobotoSlab' for the app theme. Even generated methods won't work. (fontFamily: GoogleFonts.robotoSlab().fontFamily,).
I guess, it's better to specify it in documentation. Right now, the most confusing part is
Note: Since these files are listed as assets, there is no need to list them in the fonts section of the pubspec.yaml. This can be done because the files are consistently named from the Google Fonts API (so be sure not to rename them!)

My way of implementation:
// Setup
// NTheme.dart

class NTheme {
  static TextStyle fontWeightApplier(FontWeight fw, TextStyle ts) {
    return ts.merge(GoogleFonts.nunitoSans(
      fontWeight: fw,
    ));
  }

  static mainTheme(BuildContext context) {
    final textTheme = Theme.of(context).textTheme;
    return ThemeData(
      ...,
      textTheme: GoogleFonts.nunitoSansTextTheme(
        textTheme
            .apply(
              bodyColor: Colors.grey[800],
              displayColor: Colors.grey[800],
            ),
      ),
      ...,
    );
  }
}

// Usage Example
Text(
  data,
  style: NTheme.fontWeightApplier(
    FontWeight.w600,
    textTheme.bodyText1.copyWith(
      color: Colors.grey[800],
      fontSize: 18,
    ),
  ),
),

I have a use case where I need regular, italic, bold, and bold+italic, but for various reasons it's not feasible for me to call a GoogleFonts method to grab the variant TextStyle every time; I need to be able to get real italic (not synthetic italic) by 1) setting the default text style to something like GoogleFonts.getFont('MyFont') and then 2) later doing Theme.of(context).copyWith(fontStyle: FontStyle.italic) at the point of use where I need italic.
The reason this doesn't work with this package as it is currently implemented is because each variant is explicitly loaded as a separate font here:
https://github.com/material-foundation/google-fonts-flutter/blob/feb1f6da7603b1f4183f9fd0117b62f558631c9a/lib/src/google_fonts_base.dart#L178-L191
Thus you will always get synthetic bolds and italics in my use case.
The core challenge as I understand it is that in order to get the behavior I want (which I think most people would assume is how it should work already, but here we are), you need to eagerly download all variants together so that they can be loaded by the same FontLoader instance under a single family name. That goes against the design of this package, which seems to be aiming for maximal laziness, i.e. no variant should be downloaded unless the user explicitly requests it.
In my case I know that I want regular, italic, bold, and bold+italic, and I want to eagerly load them at whatever cost.
I maintain a modified version of this package called dynamic_fonts which is basically this package but instead of pulling from Google Fonts you can pull down your own privately hosted fonts (like from S3 or whatever). There, I am squaring this circle by introducing a flag that allows for optional eager loading when registering a font. It looks like this:
https://github.com/amake/dynamic-fonts-flutter/commit/1a5c09d08c143e74ff8824f15ef0a0fe49d12657
(There is no equivalent to DynamicFonts.register in GoogleFonts; instead I guess googleFontsTextStyle and anything that forwards to it would have to gain an eager flag, if you were to copy my approach.)
Of course in Google Fonts you have the issue that some fonts provide a huge number of variants, and users may only want to eagerly load a subset of them. That's an API challenge that I don't have: I assume that the user will only register variants that he or she wants to use, so eager loads everything.

Can we at least make the package throw with an informative error if the user tries to access a font family that isn't dynamically available? Making the package actually work would be ideal, but absent that it should at least throw with an informative error message instead of working improperly.

Can we at least make the package throw with an informative error if the user tries to access a font family that isn't dynamically available? Making the package actually work would be ideal, but absent that it should at least throw with an informative error message instead of working improperly.

Can we at least make the package throw with an informative error if the user tries to access a font family that isn't dynamically available? Making the package actually work would be ideal, but absent that it should at least throw with an informative error message instead of working improperly.

Thanks for the feedback everyone, right now we do not have concrete plans for adjusting the API on this. Again, the problem is that we need to know the font weight when you're requesting it from GoogleFonts in order to pick the right file.
@tomasbaran solution accomplishes this, but similarly you could use your first approach, and make sure you pass fontWeight to the GoogleFonts. method call. For example: GoogelFonts.mitr(fontWeight: FontWeight.w200).
If anyone has good ideas for how we can make the API for this more ergonomic, or how we might be able to document this better, we would be happy to review contributions!

This is our current thinking, happy to welcome contributions!

Any working solution

This workaround prevents Text widgets from being declared as const 😕
const Text(
  'Hi',
  style: TextStyle(
    fontSize: 16,
    fontWeight: FontWeight.w500,
  ),
);

Text(
  'Hi',
  style: GoogleFonts.mitr(
    fontSize: 16,
    fontWeight: FontWeight.w500,
  ),
);

Which at first does not seems a big of a deal but if your whole widget was const, we now need multiple const declarations to keep sub widgets const.

Same happening here. I have found a way around this—instead of setting the font weight in the fontWeight property, do it in the fontFamily property like this:
fontFamily: GoogleFonts.encodeSansExpanded(fontWeight: FontWeight.w200).fontFamily,

thanks to @tomasbaran I made a small improvement so that you don't have to write fontFamily: GoogleFonts.encodeSansExpanded(fontWeight: FontWeight.w200).fontFamily, every time, just .copyWith(fontWeight: FontWeight.w200):
typedef GoogleFontBuilder = TextStyle Function({
  TextStyle? textStyle,
  Color? color,
  Color? backgroundColor,
  double? fontSize,
  FontWeight? fontWeight,
  FontStyle? fontStyle,
  double? letterSpacing,
  double? wordSpacing,
  TextBaseline? textBaseline,
  double? height,
  Locale? locale,
  Paint? foreground,
  Paint? background,
  List<Shadow>? shadows,
  List<FontFeature>? fontFeatures,
  TextDecoration? decoration,
  Color? decorationColor,
  TextDecorationStyle? decorationStyle,
  double? decorationThickness,
});

class GoogleFontTextStyle extends TextStyle {
  GoogleFontTextStyle(
    TextStyle textStyle, {
    required this.builder,
  }) : super(
          inherit: textStyle.inherit,
          color: textStyle.color,
          backgroundColor: textStyle.backgroundColor,
          fontSize: textStyle.fontSize,
          fontWeight: textStyle.fontWeight,
          fontStyle: textStyle.fontStyle,
          letterSpacing: textStyle.letterSpacing,
          wordSpacing: textStyle.wordSpacing,
          textBaseline: textStyle.textBaseline,
          height: textStyle.height,
          leadingDistribution: textStyle.leadingDistribution,
          locale: textStyle.locale,
          foreground: textStyle.foreground,
          background: textStyle.background,
          shadows: textStyle.shadows,
          fontFeatures: textStyle.fontFeatures,
          fontVariations: textStyle.fontVariations,
          decoration: textStyle.decoration,
          decorationColor: textStyle.decorationColor,
          decorationStyle: textStyle.decorationStyle,
          decorationThickness: textStyle.decorationThickness,
          debugLabel: textStyle.debugLabel,
          fontFamily: textStyle.fontFamily,
          fontFamilyFallback: textStyle.fontFamilyFallback,
          overflow: textStyle.overflow,
        );

  final GoogleFontBuilder builder;

  @override
  TextStyle copyWith({
    bool? inherit,
    Color? color,
    Color? backgroundColor,
    double? fontSize,
    FontWeight? fontWeight,
    FontStyle? fontStyle,
    double? letterSpacing,
    double? wordSpacing,
    TextBaseline? textBaseline,
    double? height,
    TextLeadingDistribution? leadingDistribution,
    Locale? locale,
    Paint? foreground,
    Paint? background,
    List<Shadow>? shadows,
    List<FontFeature>? fontFeatures,
    List<FontVariation>? fontVariations,
    TextDecoration? decoration,
    Color? decorationColor,
    TextDecorationStyle? decorationStyle,
    double? decorationThickness,
    String? debugLabel,
    String? fontFamily,
    List<String>? fontFamilyFallback,
    String? package,
    TextOverflow? overflow,
  }) {
    return super.copyWith(
      inherit: inherit,
      color: color,
      backgroundColor: backgroundColor,
      fontSize: fontSize,
      fontWeight: fontWeight,
      fontStyle: fontStyle,
      letterSpacing: letterSpacing,
      wordSpacing: wordSpacing,
      textBaseline: textBaseline,
      height: height,
      leadingDistribution: leadingDistribution,
      locale: locale,
      foreground: foreground,
      background: background,
      shadows: shadows,
      fontFeatures: fontFeatures,
      fontVariations: fontVariations,
      decoration: decoration,
      decorationColor: decorationColor,
      decorationStyle: decorationStyle,
      decorationThickness: decorationThickness,
      debugLabel: debugLabel,
      fontFamily: fontFamily ??
          ((fontWeight != null || fontStyle != null)
              ? builder(fontWeight: fontWeight, fontStyle: fontStyle).fontFamily
              : null),
      fontFamilyFallback: fontFamilyFallback,
      package: package,
      overflow: overflow,
    );
  }
}

Then you can create your typography for ThemeData using GoogleFontTextStyle and use them normally.
Another solution instead of passing the GoogleFontBuilder builder you can pass the font name and use the GoogleFonts.getFont(googleFontName) method.
I will be happy if this helps someone, thanks 🙂

This is a terrible wont fix. Let's do the user journey

member wants to try out some fonts, installs google_fonts, sets the material text theme to GoogleFonts.interTextTheme()
member only gets w400 and w700, all other weights not working
member spends an hour trying to find a solution, finds out the best option is to add fonts to the asset folder and include them normally

This is clearly broken and in practice means google_fonts has very little value

Agreed this is not ideal. If you would like to improve this, please see https://github.com/material-foundation/flutter-packages/blob/main/CONTRIBUTING.md

I've found that I can use different font weights by applying the font family to the text theme.  This isn't fool-proof, for example, it didn't seem to work for "Dancing Script".
final theme = ThemeData.from(
  useMaterial3: false,
  colorScheme: colorScheme,
  textTheme: GoogleFonts.mitrTextTheme().apply(fontFamily: 'Mitr'),
  // textTheme: GoogleFonts.montserratTextTheme().apply(fontFamily: 'Montserrat'),
  // textTheme: GoogleFonts.interTextTheme().apply(fontFamily: 'Inter'),
);

Text(
  '...',
  style: Theme.of(context).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.w200),
);

Interesting, this issue is still here, let me try it

I have devised a workaround that I am currently using. I have not tested it on all fonts.
TextStyle mergeGoogleFontWeight(FontWeight fw, TextStyle ts) {
  // Insert spaces before capital letters and remove any leading spaces. Ex: 'WorkSans' -> 'Work Sans'
  final fontBaseName = ts.fontFamily!
      .split('_')[0]
      .replaceAllMapped(
        RegExp(r'(?<=[a-z])(?=[A-Z])'),
        (Match match) => ' ',
      )
      .trim();

  final googleFont = GoogleFonts.getFont(
    fontBaseName,
    fontWeight: fw,
  );

  return ts.merge(googleFont);
}

I have some base styles such as
class Styles {
  static TextStyle ui = GoogleFonts.workSans(
    fontWeight: FontWeight.normal,
    fontSize: 14,
  );
}

and I can merge the font weight while applying new styles:
Text(
  ...,
  style: mergeGoogleFontWeight(
    FontWeight.w600,
    Styles.ui.copyWith(
      color: Colors.black,
    ),
  ),
)

fonts:

family: RobotoSlab
fonts:

asset: google_fonts/RobotoSlab-Thin.ttf
weight: 100
asset: google_fonts/RobotoSlab-ExtraLight.ttf
weight: 200
asset: google_fonts/RobotoSlab-Light.ttf
weight: 300
asset: google_fonts/RobotoSlab-Regular.ttf
weight: 400
asset: google_fonts/RobotoSlab-Medium.ttf
weight: 500
asset: google_fonts/RobotoSlab-SemiBold.ttf
weight: 600
asset: google_fonts/RobotoSlab-Bold.ttf
weight: 700
asset: google_fonts/RobotoSlab-ExtraBold.ttf
weight: 800
asset: google_fonts/RobotoSlab-Black.ttf
weight: 900

Yes, this is a bit more effort, but the only reliable way to use these fonts.

I have the same problem for Android. Interestingly, it works on the virtual device but not on the real device.
I tried both options and neither works on the real device.

textTheme: GoogleFonts.sofiaSansTextTheme()
style: GoogleFonts.sofiaSans()

I also tried adding another font via pubspec.yaml and it works.
So. It seems that the problem is precisely in this package fonts.

Package: google_fonts 6.2.1
Flutter 3.24.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 80c2e84975 (6 weeks ago) • 2024-07-30 23:06:49 +0700
Engine • revision b8800d88be
Tools • Dart 3.5.0 • DevTools 2.37.2

Still can't fix. What is the point of this package? Only some weights work

I have made a solution for this.
Create a separate file e.g "text_theme_helper.dart" with below code:
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

class TextStyleHelper extends TextStyle {
  const TextStyleHelper({
    super.inherit = true,
    super.color,
    super.backgroundColor,
    super.fontSize,
    super.fontWeight,
    super.fontStyle,
    super.letterSpacing,
    super.wordSpacing,
    super.textBaseline,
    super.height,
    super.leadingDistribution,
    super.locale,
    super.foreground,
    super.background,
    super.shadows,
    super.fontFeatures,
    super.fontVariations,
    super.decoration,
    super.decorationColor,
    super.decorationStyle,
    super.decorationThickness,
    super.debugLabel,
    super.fontFamily,
    super.fontFamilyFallback,
    super.package,
    super.overflow,
  });

  @override
  TextStyle copyWith({
    bool? inherit,
    Color? color,
    Color? backgroundColor,
    double? fontSize,
    FontWeight? fontWeight,
    FontStyle? fontStyle,
    double? letterSpacing,
    double? wordSpacing,
    TextBaseline? textBaseline,
    double? height,
    TextLeadingDistribution? leadingDistribution,
    Locale? locale,
    Paint? foreground,
    Paint? background,
    List<Shadow>? shadows,
    List<FontFeature>? fontFeatures,
    List<FontVariation>? fontVariations,
    TextDecoration? decoration,
    Color? decorationColor,
    TextDecorationStyle? decorationStyle,
    double? decorationThickness,
    String? debugLabel,
    String? fontFamily,
    List<String>? fontFamilyFallback,
    String? package,
    TextOverflow? overflow,
  }) {
    // Apply GoogleFonts logic to handle the fontWeight and other parameters
    return GoogleFonts.poppins(
      color: color ?? this.color,
      backgroundColor: backgroundColor ?? this.backgroundColor,
      fontSize: fontSize ?? this.fontSize,
      fontWeight: fontWeight ?? this.fontWeight,
      fontStyle: fontStyle ?? this.fontStyle,
      letterSpacing: letterSpacing ?? this.letterSpacing,
      wordSpacing: wordSpacing ?? this.wordSpacing,
      textBaseline: textBaseline ?? this.textBaseline,
      height: height ?? this.height,
      locale: locale ?? this.locale,
      foreground: foreground ?? this.foreground,
      background: background ?? this.background,
      shadows: shadows ?? this.shadows,
      fontFeatures: fontFeatures ?? this.fontFeatures,
      decoration: decoration ?? this.decoration,
      decorationColor: decorationColor ?? this.decorationColor,
      decorationStyle: decorationStyle ?? this.decorationStyle,
      decorationThickness: decorationThickness ?? this.decorationThickness,
    );
  }
}

TextStyle customStyle(TextStyle? baseStyle, {double? fontSize, FontWeight? fontWeight}) {
  return const TextStyleHelper().merge(baseStyle?.copyWith(fontSize: fontSize, fontWeight: fontWeight));
}

And define your theme using base text theme like this:
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:startup_repo/utils/colors.dart';
import '../../utils/text_theme.dart';

TextTheme textThemeLight(BuildContext context) {
  final baseTextTheme = Theme.of(context).textTheme;
  return TextTheme(
    displayLarge: customStyle(baseTextTheme.displayLarge, fontSize: 34.0.sp, fontWeight: FontWeight.bold),
    displayMedium: customStyle(baseTextTheme.displayMedium, fontSize: 32.0.sp, fontWeight: FontWeight.bold),
    displaySmall: customStyle(baseTextTheme.displaySmall, fontSize: 30.0.sp, fontWeight: FontWeight.bold),
    headlineLarge: customStyle(baseTextTheme.headlineLarge, fontSize: 28.0.sp, fontWeight: FontWeight.w600),
    headlineMedium: customStyle(baseTextTheme.headlineMedium, fontSize: 26.0.sp, fontWeight: FontWeight.w600),
    headlineSmall: customStyle(baseTextTheme.headlineSmall, fontSize: 24.0.sp, fontWeight: FontWeight.w600),
    titleLarge: customStyle(baseTextTheme.titleLarge, fontSize: 22.0.sp, fontWeight: FontWeight.w600),
    titleMedium: customStyle(baseTextTheme.titleMedium, fontSize: 20.0.sp, fontWeight: FontWeight.w600),
    titleSmall: customStyle(baseTextTheme.titleSmall, fontSize: 18.0.sp),
    bodyLarge: customStyle(baseTextTheme.bodyLarge, fontSize: 16.0.sp, fontWeight: FontWeight.normal),
    bodyMedium: customStyle(baseTextTheme.bodyMedium, fontSize: 14.0.sp, fontWeight: FontWeight.normal),
    bodySmall: customStyle(baseTextTheme.bodySmall, fontSize: 12.0.sp, fontWeight: FontWeight.normal),
    labelLarge: customStyle(baseTextTheme.labelLarge, fontSize: 10.0.sp, fontWeight: FontWeight.normal),
    labelMedium: customStyle(baseTextTheme.labelMedium, fontSize: 8.0.sp, fontWeight: FontWeight.normal),
    labelSmall: customStyle(baseTextTheme.labelSmall, fontSize: 6.0.sp, fontWeight: FontWeight.normal),
  ).apply(displayColor: textColorLight, bodyColor: textColorLight);
}

TextTheme textThemeDark(BuildContext context) =>
    textThemeLight(context).copyWith().apply(displayColor: textColorDark, bodyColor: textColorDark);

Now you can normally use
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        textTheme: GoogleFonts.mitrTextTheme(),
      ),
      home: Scaffold(
        body: SafeArea(
          child:  Column(
                  children: <Widget>[
                    Text('w100',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w100)),
                    Text('w200',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w200)),
                    Text('w300',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w300)),
                    Text('w400',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w400)),
                    Text('w500',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w500)),
                    Text('w600',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w600)),
                    Text('w700',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w700)),
                    Text('w800',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w800)),
                    Text('w900',
                        style: TextStyle(
                            fontSize: 18.0, fontWeight: FontWeight.w900)),
                  ],
                ),
         ),
    );
  }
}

Note: We have to use base text theme to merge with GoogleFonts i.e
 final baseTextTheme = Theme.of(context).textTheme;

because GoogleFonts styles need to explicitly handle fontWeight or other properties when merged with an existing TextStyle. The merge method does not automatically integrate GoogleFonts logic into the resulting style. So you cannot use:
 titleSmall: TextStyleHelper().merge(fontSize: 18.0.sp),


No module named 'transformers.adapters

Traceback (most recent call last):
  File "/mnt/lustre/sunyuhan/PEM_composition/examples/pytorch/text-classification/run_glue.py", line 31, in <module>
    import transformers.adapters.composition as ac
ModuleNotFoundError: No module named 'transformers.adapters'

cd PEM_composition
pip install .

can fix the problem