Skip to content

Commit be652c0

Browse files
authored
Merge pull request #15 from flagship-io/feature/support-flutter
Feature/support flutter
2 parents 6ed3177 + ea0ab4a commit be652c0

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ codebase-analyzer
5858

5959
### Supported file languages
6060
- .cs .fs
61+
- .dart
6162
- .go
6263
- .java
6364
- .js .jsx

example/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## Supported file languages
22
- .cs .fs
3+
- .dart
34
- .go
45
- .java
56
- .js .jsx

example/src/flutter/sample.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
////////////////////////////////
2+
/////// Get Flag ///////
3+
////////////////////////////////
4+
5+
import 'package:flagship/flagship.dart';
6+
import 'package:flagship/model/flag.dart';
7+
8+
9+
// Get the current visitor
10+
var currentVisitor = Flagship.getCurrentVisitor();
11+
12+
// Fetch flags
13+
currentVisitor?.fetchFlags().whenComplete(() {
14+
// Ex: get flag for vip feature
15+
Flag flag = currentVisitor.getFlag("displayVipFeature",false);
16+
Flag flag = currentVisitor.getFlag("backgroundColor", "green");
17+
Flag flag = currentVisitor.getFlag("backgroundSize", 16);
18+
});
19+
20+
// The getFlag function can be directly called through the "currentVisitor" instance if you
21+
// already fetched it elsewhere in the application

internal/files/search_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,14 @@ func TestSearchFiles(t *testing.T) {
240240
{name: "vipFeatureColor", lineNumber: 10, codeLineHighlight: 6},
241241
},
242242
},
243+
{
244+
filePath: "../../example/src/flutter/sample.dart",
245+
flags: []flag{
246+
{name: "displayVipFeature", lineNumber: 15, codeLineHighlight: 6},
247+
{name: "backgroundColor", lineNumber: 16, codeLineHighlight: 6},
248+
{name: "backgroundSize", lineNumber: 17, codeLineHighlight: 6},
249+
},
250+
},
243251
}
244252

245253
resultChannel := make(chan model.FileSearchResult)

internal/model/language_regexes.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ var LanguageRegexes = []LanguageRegex{
8282
`\.GetFlag\((?:\s*["']([\w\-]+)['"]\s*,\s*(["'][^"]*['"]|[+-]?(?:\d*[.])?\d+|true|false|False|True)(?:\s*,\s*(?:true|false|\d+|"[^"]*"))?\s*\))?`, // SDK .NET V3
8383
},
8484
},
85+
{
86+
FileExtension: `\.dart$`,
87+
Regexes: []string{
88+
`getFlag[(](?:(?:\s*["'](.*)["']\s*,\s*(["'].*\s*[^"]*["']|[^)]*))\s*[)])?`, // SDK Flutter V1-V2-V3
89+
},
90+
},
8591
}
8692

8793
func AddCustomRegexes(customRegexJSON string) {

0 commit comments

Comments
 (0)