Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usando .env e requisitando flag do unleash #12

Merged
merged 1 commit into from Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
@@ -0,0 +1,2 @@
URL_API=
INSTANCE_ID=
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -111,3 +111,4 @@ lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
.env
71 changes: 62 additions & 9 deletions lib/HomePage.dart
@@ -1,27 +1,80 @@
import 'package:flutter/material.dart';

import 'package:flutter_dotenv/flutter_dotenv.dart' as DotEnv;
import 'package:unleash/unleash.dart';

class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
Unleash unl;

@override
Widget build(BuildContext context) {
initConfigs();
String flagText;

return Scaffold(
appBar: AppBar(
title: Text('Unleash app'),
),
body: Center(
child: Container(
height: 80,
width: 300,
child: Text(
'Você está logado!!',
style: TextStyle(color: Colors.black, fontSize: 35),
),
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(15),
child: Container(
height: 80,
width: 300,
child: Text(
'Consulta de flags!!',
style: TextStyle(color: Colors.black, fontSize: 35),
),
),
),
Padding(
padding: const EdgeInsets.all(15),
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Flag'),
onChanged: (flag) {
flagText = flag;
},
),
),
Container(
height: 50,
width: 250,
decoration: BoxDecoration(
color: Colors.blue, borderRadius: BorderRadius.circular(20)),
child: FlatButton(
onPressed: () {
print('flag ativa? == ${unl.isEnabled(flagText)}');
},
child: Text(
'Consultar',
style: TextStyle(color: Colors.white, fontSize: 25),
),
),
),
],
),
)
);
}

Future<void> initConfigs() async {
await DotEnv.load();

unl = await Unleash.init(
UnleashSettings(
appName: '<appname>',
instanceId: '${DotEnv.env['INSTANCE_ID']}',
unleashApi: Uri.parse('${DotEnv.env['URL_API']}'),
),
);
}
}
}
35 changes: 35 additions & 0 deletions pubspec.lock
Expand Up @@ -76,11 +76,32 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_dotenv:
dependency: "direct main"
description:
name: flutter_dotenv
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.2"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.4"
intl:
dependency: transitive
description:
Expand Down Expand Up @@ -144,6 +165,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4+3"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.2"
platform:
dependency: transitive
description:
Expand Down Expand Up @@ -219,6 +247,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
unleash:
dependency: "direct main"
description:
name: unleash
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
vector_math:
dependency: transitive
description:
Expand Down
9 changes: 7 additions & 2 deletions pubspec.yaml
@@ -1,4 +1,4 @@
name: unleash
name: unleash_poc
description: A new Flutter project.

publish_to: 'none' # Remove this line if you wish to publish to pub.dev
Expand All @@ -15,11 +15,16 @@ dependencies:

path_provider: ^1.6.28
cupertino_icons: ^0.1.3
flutter_dotenv: ^3.1.0
unleash: ^0.1.2

dev_dependencies:
flutter_test:
sdk: flutter

flutter:

uses-material-design: true
uses-material-design: true

assets:
- .env
2 changes: 1 addition & 1 deletion test/widget_test.dart
Expand Up @@ -8,7 +8,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:unleash/main.dart';
import 'package:unleash_poc/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
Expand Down