Flutter logs "is there any way to display console logs on my device listview flutter" , any library for displaying it in a listview

Viewed 37

i am new to flutter is there any way to display console logs on my device using listview in flutter , i am new to flutter please help.

here I am using fimber library but don't know to getting logs from that library. is there any way to get all logs in a list, to display it in listview.


void main() {
  Fimber.plantTree(DebugTree());
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      color: Colors.lightBlue,
      home: StreamBuilder<BluetoothState>(
          stream: FlutterBlue.instance.state,
          initialData: BluetoothState.unknown,
          builder: (c, snapshot) {
            final state = snapshot.data;
            if (state == BluetoothState.on) {
              print('state on');
              return FindDevicesScreen();
            }else if(state == BluetoothState.off)
              {
                BluetoothEnable.enableBluetooth.then((result) {
                  if (result == "true") {
                    // Bluetooth has been enabled
                    print("enable bluetooth");
                  }
                  else if (result == "false") {
                    // Bluetooth has not been enabled
                    print("disabled bluetooth");
                  }
                });
              }
            print("${snapshot.data} this is another state");
            return BluetoothOffScreen(state: state!);
          }),
    );
  }
}
class BluetoothOffScreen extends StatefulWidget {
  const BluetoothOffScreen({Key? key, required this.state }) : super(key: key);
  final BluetoothState state;
  @override
  _BluetoothOffScreenState createState() => _BluetoothOffScreenState();
}

class _BluetoothOffScreenState extends State<BluetoothOffScreen> {
 Future<void> requestLocationPermission() async {
    Map<Permission, PermissionStatus> status = await [
      Permission.bluetooth,
      Permission.bluetoothScan
    ].request();

    if (status == PermissionStatus.granted) {
      Fimber.d("Permission Granted");
      print('Permission Granted');
    } else if (status == PermissionStatus.denied) {
      ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
          content: Text("This permission is recommended")));
      print('Permission denied');
      Fimber.d("Permission denied");
    } else if (status == PermissionStatus.permanentlyDenied) {
      print('Permission Permanently Denied');
      Fimber.d("Permission Permanently Denied");
      await openAppSettings();
    }
  }
  @override
  void initState() {
    requestLocationPermission();
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.lightBlue,
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            const Icon(
              Icons.bluetooth_disabled,
              size: 200.0,
              color: Colors.white54,
            ),
            Text(
              'Bluetooth Adapter is ${widget.state.toString().substring(15)}.',
              style: Theme.of(context)
                  .primaryTextTheme
                  .caption!
                  .copyWith(color: Colors.white),
            ),
          ],
        ),
      ),
    );
  }
}


here I am using fimber library but don't know to getting logs from that library. is there any way to get all logs in a list, to display it in listview.

0 Answers
Related