dart_gsheet_remote_config
एक पैकेज जो आपको अपने Dart/Flutter ऐप के व्यवहार, सेटिंग्स आदि को अपडेट किए बिना बदलने के लिए Google शीट्स का उपयोग करने की अनुमति देता है।
Dart Google Sheet रिमोट कॉन्फ़िग - Google शीट का उपयोग रिमोट कॉन्फ़िग के रूप में करें
यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।
This is a package that allows you to use Google Sheets as a remote config for changing your Dart/Flutter app's behaviors, settings,.. without updating. It is inspired by @theapache64's blog.
TO_TEXT fomular to convert value to String type:dart pub add dart_gsheet_remote_config
flutter pub add dart_gsheet_remote_config
Create your SheetRemoteConfig instance.
import 'package:dart_gsheet_remote_config/dart_gsheet_remote_config.dart';
final remoteConfig = SheetRemoteConfig();
SheetRemoteConfig has a param Client from http package so you can pass your custom Client object when create SheetRemoteConfig instance.
import 'package:dart_gsheet_remote_config/dart_gsheet_remote_config.dart';
import 'package:http/http.dart' as http;
final client = http.Client();
final remoteConfig = SheetRemoteConfig(client: client);
SheetRemoteConfig provides initilize function and you must pass id and sheetName to initilize remote config:
Document id you can find it in your Google Sheet document Url. For example your Sheet url is https://docs.google.com/spreadsheets/d/123456789, id will be 123456789.
sheetName is worksheet name, nullable, first worksheet will be used if null or passed value is not found.
import 'package:dart_gsheet_remote_config/dart_gsheet_remote_config.dart';
final remoteConfig = SheetRemoteConfig();
await remoteConfig.initilize(id: '123456789'); // First worksheet will be used
await remoteConfig.initilize(id: '123456789', sheetName: 'Sheet1'); // Use specific worksheet name
MUST READ: id mustn't be hardcode if you don't want others to use your remote config. You can use id as .env field or via dart-define and pass it to your app via environment variable. You can use some packages like flutter_dotenv, envied to load .env file.
SheetRemoteConfig fetchs data in CSV format, data is returned in key-value format, you can key to get value via
get functions, currently SheetRemoteConfig supports String, int, double, bool.
Example response:
"key1","TRUE"
"key2","10"
"key3","value from key 3"
"key4,"1.0"
And get data:
final valueKey1 = remoteConfig.getBool('key1');
print(valueKey1); // true
final valueKey2 = remoteConfig.getInt('key2');
print(valueKey2); // 10
final valueKey3 = remoteConfig.getString('key3');
print(valueKey3); // value from key 3
final valueKey4 = remoteConfig.getDouble('key4');
print(valueKey4); // 1.0
If provided key is not found or provided T is incorrect, get functions will return null.
final valueKey5 = remoteConfig.getString('key5');
print(valueKey5); // null
You can pass defaultValue when get functions returns null.
final valueKey5 = remoteConfig.getString('key5', defaultValue: 'this is default value');
print(valueKey5); // this is default value
SheetRemoteConfig provides getAll function to get all data from remote.
final allData = remoteConfig.getAll();
print(allData); // {key1: true, key2: 10, key3: value from key 3, key4: 1.0}
That's all for now! Want a feature? Found a bug? Create an issue!
उपयोग के अनुसार छाँटें, गतिविधि की तुलना करें और अपनाने से पहले मूल प्रोजेक्ट की आवश्यकताएँ जाँचें।
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗