import 'package:flutter/material.dart'; import 'package:flutter_tracker/utils/app_util.dart'; import 'package:flutter_tracker/views/contact_card.dart'; class TrackPage extends StatefulWidget { const TrackPage({Key key}) : super(key: key); @override _TrackPageState createState() => _TrackPageState(); } class _TrackPageState extends State { String testText = ''; List contactTraces = []; List contactTimes = []; List contactLocations = []; @override Widget build(BuildContext context) { return Column( children: [ Expanded( child: Padding( padding: EdgeInsets.only( left: 25.0, right: 25.0, bottom: 10.0, top: 30.0, ), child: Container( height: 50.0, width: double.infinity, decoration: BoxDecoration( color: Colors.deepPurple[500], borderRadius: BorderRadius.circular(20.0), boxShadow: const [ BoxShadow( color: Colors.black, blurRadius: 4.0, spreadRadius: 0.0, offset: Offset(2.0, 2.0), // shadow direction: bottom right ) ], ), child: Row( children: const [ Expanded( child: Image( image: AssetImage('assets/images/corona.png'), ), ), Expanded( flex: 2, child: Text( '附近用户', textAlign: TextAlign.left, style: TextStyle( fontSize: 21.0, color: Colors.white, fontWeight: FontWeight.w500, ), ), ) ], ), ), ), ), Padding( padding: EdgeInsets.only(bottom: 200.0), child: RaisedButton( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0)), elevation: 5.0, color: Colors.deepPurple[400], onPressed: () async { startTrack(); }, child: const Text( '开始追踪', style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.bold, color: Colors.white, ), ), ), ), Expanded( flex: 2, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 25.0), child: ListView.builder( itemBuilder: (context, index) { return ContactCard( imagePath: 'assets/images/head.jpg', email: contactTraces[index], infection: 'Not-Infected', contactUsername: contactTraces[index], contactTime: contactTimes[index], contactLocation: contactLocations[index], ); }, itemCount: contactTraces.length, ), ), ), ], ); } void startTrack() async { // try { // bool a = await Nearby().startAdvertising( // loggedInUser.email, // strategy, // onConnectionInitiated: null, // onConnectionResult: (id, status) { // print(status); // }, // onDisconnected: (id) { // print('Disconnected $id'); // }, // ); // // print('ADVERTISING ${a.toString()}'); // } catch (e) { // print(e); // } discovery(); AppUtil.buildToast("正在搜索附近的人..."); AppUtil.buildToast("追踪用户状态中..."); } void discovery() {} }