Categories
Mastering Development

divide cart when different products with different shipping classes are added in woocommerce

I face a problem in woocommerce shipping class. To explain it better I describe it with an example: Product A has Air Shipping class Product B has Road Shipping class product C has Possible shipping in road and air I use the following code to split the order based on shipping class: add_filter( ‘woocommerce_cart_shipping_packages’, ‘wf_split_cart_by_shipping_class_group’ […]

Categories
Mastering Development

How to lookup or aggregate a field of an object in an array of javascript objects (in mongodb)?

I want have the field contractType in my mongoose schema, is an array of objects that each one has the property authorizedBy into the second level. contractType field could have many items and I want to know each authorizedBy finding it in other collection called admins (I’ll let it below too). const professionalSchema = new […]

Categories
Mastering Development

How to get value from an object which in the state (flutter_bloc)

in builder method I reach the value of state like return BlocBuilder<UsersOwnProfileBloc, UsersOwnProfileState>( cubit: widget.bloc, builder: (context, state) { if (state is FetchedUserSettingState) { bool account = state.userSettings.publicAccount } But I need to get the values from initState. I need to set the values of the widget. I tried something like this but I got […]

Categories
Mastering Development

Django rest-framework with mongodb not creating auto field primary key id

I am saving records in MongoDB using Django rest framework. Migration is as below – # Generated by Django 3.0.5 on 2021-01-17 10:39 from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name=’Demo’, fields=[ (‘id’, models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name=’ID’)), (‘description’, models.CharField(default=”, max_length=1000)), (‘user_id’, models.IntegerField()), (‘published’, models.BooleanField(default=False)), […]

Categories
Mastering Development

How to display texts in the middle of screen with Column in Flutter?

I am very new to Flutter. I want to display two text with Column in middle of the screen. But when I tried Center, it looks like this. It displays texts in top of the screen. Why this happens? My code: import ‘package:flutter/material.dart’; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget […]

Categories
Mastering Development

Could not find the correct Provider

could not find any solution in my case. This is my code: class FlashBottomContainer extends StatelessWidget { @override Widget build(BuildContext context) { return Builder( builder: (BuildContext context){ BuildContext rootContext = context; return Container( decoration: BoxDecoration(border: Border.all(color: Colors.grey)), padding: EdgeInsets.all(6), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ ReusableButton( onPressed: () {}, title: ‘Buy Now’, colour: Theme.of(rootContext).accentColor, ), […]

Categories
Mastering Development

Cannot deploy a small transformers model for prediction serving using Google Cloud AI Platform due to “Model requires more memory than allowed”

I have a fine tuned distilgpt2 model that I want to deploy using GCP ai-platform. I’ve followed all the documentation for deploying a custom prediction routine on GCP but when creating the model I get the error: Create Version failed. Bad model detected with error: Model requires more memory than allowed. Please try to decrease […]

Categories
Mastering Development

Create custom dropdown in flutter – or how to put custom dropdown options in a layer above everything else

I am looking for a way to create a custom dropdown so I can style it myself. I ran into this answer that seems pretty useful https://stackoverflow.com/a/63165793/3808307 The problem is that if the container is smaller than the dropdown, flutter complains about pixel overflowing. How can I get this dropdown to be on top of […]

Categories
Mastering Development

Dissmiss the context menu of SelectableText without clicking a menu item

In case of native, if I click any empty area or press the back button, the menu disappears. In case of Flutter, clicking empty area does nothing, and pressing the back button closes the app. Is there no way to dismiss the context menu without clicking an item like "Copy"? Also, when I ran the […]

Categories
Mastering Development

Stop Play Music after leaving the page in Flutter

In my Flutter app I’m using audioplayers: ^0.17.0 to play music. When I play music and want to leave the page I want to stop playing music. For that purpose I’m using dispose(). And it looks like it is working. The problem that I’m getting is that I’ve got an error in the console. I think it […]