This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:flutter/material.dart'; | |
import 'package:mobile_scanner/mobile_scanner.dart'; | |
class ScannerWidget extends StatefulWidget { | |
final String? title; | |
final void Function(String value) onScan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"numero": 1, | |
"nom": "الله", | |
"transliteration": "ALLAH", | |
"en": "Allah", | |
"fr": "Allah" | |
}, | |
{ | |
"numero": 2, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final String response = await rootBundle.loadString('assets/surah.json'); | |
final data = await json.decode(response); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{for (var v in products) v.id!: v}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Stack( | |
children: [ | |
Center( | |
child: Container( | |
height: 200, | |
width: 200, | |
decoration: new BoxDecoration( | |
borderRadius: BorderRadius.circular(20.0), | |
), | |
child: FlutterLogo(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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]!; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef Int2VoidFunc = void Function(int); | |
// or: typedef void Int2VoidFunc(int arg); | |
class MyOtherClass { | |
final Int2VoidFunc callback; | |
MyOtherClass(this.callback); | |
void callCallaback() { callback(5); } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
NewerOlder