Skip to content

Commit

Permalink
Merge pull request #15 from flagship-io/feature/support-flutter
Browse files Browse the repository at this point in the history
Feature/support flutter
  • Loading branch information
Chadiii authored Mar 27, 2023
2 parents 6ed3177 + ea0ab4a commit be652c0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ codebase-analyzer

### Supported file languages
- .cs .fs
- .dart
- .go
- .java
- .js .jsx
Expand Down
1 change: 1 addition & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Supported file languages
- .cs .fs
- .dart
- .go
- .java
- .js .jsx
Expand Down
21 changes: 21 additions & 0 deletions example/src/flutter/sample.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
////////////////////////////////
/////// Get Flag ///////
////////////////////////////////
import 'package:flagship/flagship.dart';
import 'package:flagship/model/flag.dart';


// Get the current visitor
var currentVisitor = Flagship.getCurrentVisitor();

// Fetch flags
currentVisitor?.fetchFlags().whenComplete(() {
// Ex: get flag for vip feature
Flag flag = currentVisitor.getFlag("displayVipFeature",false);
Flag flag = currentVisitor.getFlag("backgroundColor", "green");
Flag flag = currentVisitor.getFlag("backgroundSize", 16);
});

// The getFlag function can be directly called through the "currentVisitor" instance if you
// already fetched it elsewhere in the application
8 changes: 8 additions & 0 deletions internal/files/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ func TestSearchFiles(t *testing.T) {
{name: "vipFeatureColor", lineNumber: 10, codeLineHighlight: 6},
},
},
{
filePath: "../../example/src/flutter/sample.dart",
flags: []flag{
{name: "displayVipFeature", lineNumber: 15, codeLineHighlight: 6},
{name: "backgroundColor", lineNumber: 16, codeLineHighlight: 6},
{name: "backgroundSize", lineNumber: 17, codeLineHighlight: 6},
},
},
}

resultChannel := make(chan model.FileSearchResult)
Expand Down
6 changes: 6 additions & 0 deletions internal/model/language_regexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ var LanguageRegexes = []LanguageRegex{
`\.GetFlag\((?:\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\))?`, // SDK .NET V3
},
},
{
FileExtension: `\.dart$`,
Regexes: []string{
`getFlag[(](?:(?:\s*["'](.*)["']\s*,\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)])?`, // SDK Flutter V1-V2-V3
},
},
}

func AddCustomRegexes(customRegexJSON string) {
Expand Down

0 comments on commit be652c0

Please sign in to comment.