Skip to content

Instantly share code, notes, and snippets.

View saliouseck2009's full-sized avatar

ckroot saliouseck2009

  • Senegal
View GitHub Profile
@saliouseck2009
saliouseck2009 / 99_names_Allah.json
Created April 4, 2023 12:26
The is a list of 99 names of Allah
[
{
"numero": 1,
"nom": "الله",
"transliteration": "ALLAH",
"en": "Allah",
"fr": "Allah"
},
{
"numero": 2,
final String response = await rootBundle.loadString('assets/surah.json');
final data = await json.decode(response);
{for (var v in products) v.id!: v};
Map<String, dynamic> toJson() {
List<Map>? orderProducts = this.orderProducts != null
? this.orderProducts!.map((i) => i.toJson()).toList()
: null;
return {
'pos_id': posId,
'sector_id': sectorId,
'seller_id': sellerId,
"date": date == null ? null : date!.toIso8601String(),
Stack(
children: [
Center(
child: Container(
height: 200,
width: 200,
decoration: new BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
),
child: FlutterLogo(),
//Set the value if it doesn't
//You may be tempted to implement some conditional logic to handle this:
class ShoppingCart {
final Map<String, int> items = {};
void add(String key, int quantity) {
if (items.containsKey(key)) {
// item exists: update it
items[key] = quantity + items[key]!;
@saliouseck2009
saliouseck2009 / VoidCallBackArgs.dart
Created April 15, 2022 15:49
Flutter : Create VoidCallBack with args
typedef Int2VoidFunc = void Function(int);
// or: typedef void Int2VoidFunc(int arg);
class MyOtherClass {
final Int2VoidFunc callback;
MyOtherClass(this.callback);
void callCallaback() { callback(5); }
}
@saliouseck2009
saliouseck2009 / bloc_observer.dart
Last active February 25, 2022 13:12
BlocObserver usage on flutter_bloc v8.0.0
class SimpleBlocObserver extends BlocObserver {
@override
void onEvent(Bloc bloc, Object? event) {
super.onEvent(bloc, event);
print(event);
}
@override
void onTransition(Bloc bloc, Transition transition) {
super.onTransition(bloc, transition);
@saliouseck2009
saliouseck2009 / flutter_navigation_with_bloc.dart
Created February 18, 2022 15:24
bloc navigation using builder
void main() {
runApp(
BlocProvider(
create: (context) => MyBloc(),
child: MyApp(),
),
);
}
@immutable
@saliouseck2009
saliouseck2009 / limite_double.dart
Created February 11, 2022 15:44
help you get closest string representation with exactly N digits after the decimal point, then parse the result to double
double num1 = double.parse((12.3412).toStringAsFixed(2));
// 12.34
double num2 = double.parse((12.5668).toStringAsFixed(2));
// 12.57
double num3 = double.parse((-12.3412).toStringAsFixed(2));
// -12.34
double num4 = double.parse((-12.3456).toStringAsFixed(2));