8000 get and set data from local · lineCode/flutter-webrtc@ffa7bda · GitHub
[go: up one dir, main page]

Skip to content

Commit ffa7bda

Browse files
committed
get and set data from local
1 parent 8e9f806 commit ffa7bda

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

example/lib/main.dart

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'dart:core';
33
import 'src/basic_sample/basic_sample.dart';
44
import 'src/call_sample/call_sample.dart';
55
import 'src/route_item.dart';
6+
import 'package:shared_preferences/shared_preferences.dart';
67

78
void main() => runApp(new MyApp());
89

@@ -14,10 +15,17 @@ class MyApp extends StatefulWidget {
1415

1516

1617
class _MyAppState extends State<MyApp> {
18+
19+
List<RouteItem> items;
20+
String _ip = '192.168.31.152';
21+
SharedPreferences prefs;
22+
1723
@override
1824
initState() {
1925
super.initState();
2026

27+
_initData();
28+
2129
_initItems();
2230

2331
}
@@ -50,8 +58,13 @@ class _MyAppState extends State<MyApp> {
5058
);
5159
}
5260

53-
List<RouteItem> items;
54-
String _ip = '192.168.31.152';
61+
62+
_initData() async{
63+
prefs = await SharedPreferences.getInstance();
64+
setState(() {
65+
_ip = prefs.getString('ip') ?? '';
66+
});
67+
}
5568

5669
_initItems(){
5770

@@ -92,6 +105,9 @@ class _MyAppState extends State<MyApp> {
92105
onPressed: () {},
93106
child: RaisedButton(
94107
onPressed: () {
108+
109+
prefs.setString('ip', _ip);
110+
95111
Navigator.push(
96112
context,
97113
MaterialPageRoute(

example/lib/src/call_sample/call_sample.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'dart:io';
23
import 'dart:core';
34
import 'dart:async';
45
import 'signaling.dart';
@@ -19,7 +20,7 @@ class _CallSampleState extends State<CallSample> {
1920
GlobalKey<FormState> _formKey = new GlobalKey<FormState>();
2021
Signaling _signaling;
2122
String _roomId;
22-
String _displayName = "flutter";
23+
String _displayName = Platform.operatingSystem + "_flutter";
2324
List<dynamic> _peers;
2425

2526
final _localRenderer = new RTCVideoRenderer();
@@ -118,7 +119,7 @@ class _CallSampleState extends State<CallSample> {
118119
actions: <Widget>[
119120
IconButton(
120121
icon: const Icon(Icons.settings),
121-
onPressed: _connect,
122+
onPressed: null,
122123
tooltip: 'setup',
123124
),
124125
],

example/pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ dev_dependencies:
1616
webrtc:
1717
path: ../
1818

19+
shared_preferences: ^0.4.2
20+
1921
# For information on the generic Dart part of this file, see the
2022
# following page: https://www.dartlang.org/tools/pub/pubspec
2123

0 commit comments

Comments
 (0)
0