I'm having issues writing an experiment for a flut...
# sdk-flutter
t
I'm having issues writing an experiment for a flutter app. I am just wanting to break it down to an easy change such as a text change but can't find much documentation or starting points to get me going. I did try and get chatGPT to help me write something but I never got anything working. Is there some example experiments somewhere I couldn't see anything in the docs but hoping I missed it.
c
Hi, @tall-glass-41437. Yes, we can provide that to you.
t
Great, where can I find this info?
c
Need to create a new feature in console. Select string value type if you want text.
Add experiment to feature rule
Add new text values for variations with the required percentage
Publish changes
Use in app like
t
Thanks so much for this. I will give it a go today.
🙌 1
c
You are welcome
t
Hey Maxim, Sorry to bother you with this but this I feel completely lost with this. I have set up the experiment and feature and when trying to add the code I get a heap of errors so I am guessing I have initialised something wrong. Can you see the issue here? I am mainly getting a lot of undefined issues.
c
You just need to use your api key and hostURl
t
Great I finally got this to work. I have some what of an understand what its doing so I want to move on to doing a visual on page change but I can't find any documentation on this. Can you help me change some text on the actual page.
🙌 1
c
Hi, @tall-glass-41437. Yes, please describe what you want exactly to change.
t
Hi I have created an experiment which just returns one of two string variations. I have tried to put something together with chatGPT
Copy code
Future<void> initializeSDK() async {
  if (_isInitialized) return; // Avoid re-initializing if already done

  // Initialize GrowthBook SDK
  gb = await GBSDKBuilderApp(
    apiKey: 'sdk-xxx', // Replace with your actual API key  
    hostURL: '<https://cdn.growthbook.io/>', // Replace with your actual GrowthBook URL
    growthBookTrackingCallBack: (exp, rst) {
      // Handle callback if needed
    },
    gbFeatures: {
      'flutter-pet-test': GBFeature(defaultValue: 'pet'),
    },
  ).initialize();

  // After evaluation, set the blurb text and log the value
  final expressBlurb = gb?.evalFeature('flutter-pet-test');

  setState(() {
    // Use the actual value returned from the feature evaluation
    expessBlurbText = expressBlurb?.value ?? 'Default Blurb';

    // Log the value (this could be the 'control' or any variant you defined)
    print('Feature Evaluation Value: ${expressBlurb?.value}');

    _isInitialized = true; // Mark as initialized
  });
}
I had it working some what and returning the control but now I am just getting the default text from the feature I created to set it up. I have no real idea what I am doing so any help would be great.
c
Hi, @tall-glass-41437. Please check if you correctly set up the features with experiments, I tried to run with your key.