Skip to content

Instantly share code, notes, and snippets.

View learnpainless's full-sized avatar

Learn Pain Less learnpainless

View GitHub Profile
@learnpainless
learnpainless / httpd-xamp.conf
Created October 2, 2023 05:38
How to generate secure SSL certificate for localhost in XAMPP and Enable HTTPS for localhost https://youtu.be/zrbaE1Wdviw
<VirtualHost *:80>
DocumentRoot "F:\xampp\htdocs"
ServerName sites.local
ServerAlias *.sites.local
SSLEngine on
SSLCertificateFile "crt/sites.local/server.crt"
SSLCertificateKeyFile "crt/sites.local/server.key"
</VirtualHost>
File? croppedfile = await ImageCropper.cropImage(
sourcePath: imagepath,
aspectRatioPresets: [
CropAspectRatioPreset.square,
CropAspectRatioPreset.ratio3x2,
CropAspectRatioPreset.original,
CropAspectRatioPreset.ratio4x3,
CropAspectRatioPreset.ratio16x9
],
androidUiSettings: AndroidUiSettings(
DropdownButton(
value: _selectedItem,
items: _dropdownItems,
onChanged: (value) {
setState(() {
_selectedItem = value;
});
},
style: TextStyle(color: Colors.white),
dropdownColor: Colors.blue,
import 'package:dio/dio.dart';
class ApiProvider {
Dio _dio;
String aToken = '';
final BaseOptions options = new BaseOptions(
baseUrl: 'http://3.8.141.177:6001/gateway',
connectTimeout: 15000,
receiveTimeout: 13000,
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
@learnpainless
learnpainless / home1.dart
Last active March 8, 2023 03:10
How to disable back button Flutt App complete guide https://learnpainless.com/disable-back-button-flutter-app/
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async => false,
child: Scaffold(
// Your app content goes here
),
);
}
ASN1Parser p = ASN1Parser(der);
ASN1Sequence signedCert = p.nextObject() as ASN1Sequence;
ASN1Sequence cert = signedCert.elements[0] as ASN1Sequence;
ASN1Sequence pubKeyElement = cert.elements[6] as ASN1Sequence;
ASN1BitString pubKeyBits = pubKeyElement.elements[1] as ASN1BitString;
List<int> encodedPubKey = pubKeyBits.stringValue;
// could stop here and compare the encoded key parts, or...
import 'dart:io';
import 'package:path_provider/path_provider.dart';
Future<void> main() async {
// Get the temporary directory
final directory = await getTemporaryDirectory();
final file = File('${directory.path}/my_file.txt');
// Write to the file
await file.writeAsString('Hello, World!');
ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: items.length,
itemBuilder: (context, index) {
return Container(
width: 160.0,
child: Card(
child: Text(items[index]),
),
);
import 'package:firebase_messaging/firebase_messaging.dart';
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
// ...
_firebaseMessaging.sendToTopic('your-topic',
'aps': {
'badge': 5, // Set the badge count to 5
},